Skip to content

Instantly share code, notes, and snippets.

takashi1975 takashi1975

Block or report user

Report or block takashi1975

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@takashi1975
takashi1975 / hanoi.js
Last active Jan 26, 2020
ハノイの塔
View hanoi.js
/**
* 「解く手順を考えた結果、再帰でできそうだ、という流れ」 の解説図がわかりやすいです。
* https://qiita.com/ting/items/134b37bbeb756655ca6b
*/
//ハノイの塔(再帰関数)
function hanoi(saucer, from, to, work) {
if (saucer == 0) return;
//ハノイの塔 再帰呼び出し
@takashi1975
takashi1975 / Aim1.cs
Last active Nov 14, 2019
Quaternion.LookRotation 例
View Aim1.cs
//目標の方を向く例 1
public class Aim : MonoBehaviour
{
[SerializeField]
private GameObject _target;
void Update()
{
var directionToFace = this._target.transform.position - this.transform.position;
View RayHit.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RayHit : MonoBehaviour
{
[SerializeField]
private GameObject _hitObject = null;
public GameObject HitObject {
get { return this._hitObject; }
@takashi1975
takashi1975 / DrawLineManager.cs
Created Jul 24, 2019
Unity DrawLine multi (いったん描画したら機能停止させる)
View DrawLineManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawLineManager : MonoBehaviour
{
[field: SerializeField]
public GameObject prefabDrawLine { get; private set; }
[field: SerializeField]
@takashi1975
takashi1975 / DrawLine.cs
Created Jul 23, 2019
Unity LineRender (マウスで線を描く)
View DrawLine.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/**
* https://unitycoder.com/blog/2017/08/27/drawing-lines/
*
* Unity ver.2018.3.13f1 で確認
*/
@takashi1975
takashi1975 / Userdefaults+Extension.swift
Last active Jul 18, 2018
[Swift] Userdefaults+Extension (デフォルト値の考慮)
View Userdefaults+Extension.swift
extension UserDefaults {
//Get (デフォルト値あり)
internal static func get<T>(key: String, defaultValue: T) -> T {
let userdefaults = UserDefaults.standard
if userdefaults.object(forKey: key) != nil {
//Float
View BallTap.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallTap : MonoBehaviour, TapBehaviour {
/** タッチしたとき */
public void TapDown(ref RaycastHit hit) {
Debug.Log("TapDown : " + hit);
View sample.swift
override func viewWillDisappear(_ animated: Bool) {
/**
* UINavigationControllerの戻る[back]処理のイベントを取得する方法
* https://qiita.com/syamaoka/items/509ff50fcab485347600
* ... viewWillDisappearが呼ばれる時に、戻る処理を行っていれば、NavigationControllerのviewControllersの中にselfは存在していない
*/
if let viewControllers = self.navigationController?.viewControllers {
let existsSelfInViewControllers = viewControllers.filter{$0 == self}.count == 0
if existsSelfInViewControllers {
@takashi1975
takashi1975 / sample.swift
Last active Feb 20, 2018
Swift4 クロージャーの宣言?に名前をつけたい
View sample.swift
/**
* https://stackoverflow.com/questions/24077428/how-do-i-declare-typedef-in-swift
*/
//やりたかったこと
typealias FunctionClosure = (_ value: Int) -> Void
fileprivate var _closure: FunctionClosure? = nil
@takashi1975
takashi1975 / sample.swift
Last active Mar 5, 2018
Swift4 アラートの表示
View sample.swift
//警告表示
internal alertTest() {
let alert = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default) {
(action) in
print("OK")
}
alert.addAction(defaultAction)
You can’t perform that action at this time.