Delegates.observable は、プロパティが変更されるたびに指定されたラムダ(監視関数)が呼び出されます。
ラムダは3つの引数を取ります:
prop: プロパティのメタデータ(プロパティ名など)。old: プロパティの古い値。new: プロパティの新しい値。
このように、Delegates.observable を使うとプロパティの変更を監視して、変更のたびに処理を実行できます。
| import Foundation | |
| import AVFoundation | |
| import ReplayKit | |
| class RPScreenWriter { | |
| // Write video | |
| var videoOutputURL: URL | |
| var videoWriter: AVAssetWriter? | |
| var videoInput: AVAssetWriterInput? | |
| // Write audio |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| /// <summary> | |
| /// Lerpでゲームオブジェクトを移動させる | |
| /// | |
| /// [参考URL] | |
| /// UnityでLerpを使って収縮運動や往復運動をさせる | |
| /// https://getabakoclub.com/2020/01/30/lerp%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E5%8F%8E%E7%B8%AE%E9%81%8B%E5%8B%95%E3%82%84%E5%BE%80%E5%BE%A9%E9%81%8B%E5%8B%95%E3%82%92%E3%81%95%E3%81%9B%E3%82%8B/ |
| /** | |
| * 「解く手順を考えた結果、再帰でできそうだ、という流れ」 の解説図がわかりやすいです。 | |
| * https://qiita.com/ting/items/134b37bbeb756655ca6b | |
| */ | |
| //ハノイの塔(再帰関数) | |
| function hanoi(saucer, from, to, work) { | |
| if (saucer == 0) return; | |
| //ハノイの塔 再帰呼び出し |
| //目標の方を向く例 1 | |
| public class Aim : MonoBehaviour | |
| { | |
| [SerializeField] | |
| private GameObject _target; | |
| void Update() | |
| { | |
| var directionToFace = this._target.transform.position - this.transform.position; |
| 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; } |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class DrawLineManager : MonoBehaviour | |
| { | |
| [field: SerializeField] | |
| public GameObject prefabDrawLine { get; private set; } | |
| [field: SerializeField] |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| /** | |
| * https://unitycoder.com/blog/2017/08/27/drawing-lines/ | |
| * | |
| * Unity ver.2018.3.13f1 で確認 | |
| */ |
| extension UserDefaults { | |
| //Get (デフォルト値あり) | |
| internal static func get<T>(key: String, defaultValue: T) -> T { | |
| let userdefaults = UserDefaults.standard | |
| if userdefaults.object(forKey: key) != nil { | |
| //Float |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class BallTap : MonoBehaviour, TapBehaviour { | |
| /** タッチしたとき */ | |
| public void TapDown(ref RaycastHit hit) { | |
| Debug.Log("TapDown : " + hit); |