Skip to content

Instantly share code, notes, and snippets.

@takashi1975
takashi1975 / Delegates.observable Sample.md
Last active November 7, 2024 04:35
Delegates.observable Sample

説明

Delegates.observable は、プロパティが変更されるたびに指定されたラムダ(監視関数)が呼び出されます。

ラムダは3つの引数を取ります:

  • prop : プロパティのメタデータ(プロパティ名など)。
  • old : プロパティの古い値。
  • new : プロパティの新しい値。

このように、Delegates.observable を使うとプロパティの変更を監視して、変更のたびに処理を実行できます。

@takashi1975
takashi1975 / RPScreenWriter.swift
Created December 7, 2020 11:18 — forked from mspvirajpatel/RPScreenWriter.swift
ScreenWriter With ReplayKit
import Foundation
import AVFoundation
import ReplayKit
class RPScreenWriter {
// Write video
var videoOutputURL: URL
var videoWriter: AVAssetWriter?
var videoInput: AVAssetWriterInput?
// Write audio
@takashi1975
takashi1975 / RoundTrip.cs
Created September 13, 2020 02:15
Unity ゲームオブジェクトの往復移動
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/
@takashi1975
takashi1975 / hanoi.js
Last active January 26, 2020 01:37
ハノイの塔
/**
* 「解く手順を考えた結果、再帰でできそうだ、という流れ」 の解説図がわかりやすいです。
* https://qiita.com/ting/items/134b37bbeb756655ca6b
*/
//ハノイの塔(再帰関数)
function hanoi(saucer, from, to, work) {
if (saucer == 0) return;
//ハノイの塔 再帰呼び出し
@takashi1975
takashi1975 / Aim1.cs
Last active November 14, 2019 01:52
Quaternion.LookRotation 例
//目標の方を向く例 1
public class Aim : MonoBehaviour
{
[SerializeField]
private GameObject _target;
void Update()
{
var directionToFace = this._target.transform.position - this.transform.position;
@takashi1975
takashi1975 / RayHit.cs
Created October 18, 2019 13:19
RayCast
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 July 24, 2019 00:08
Unity DrawLine multi (いったん描画したら機能停止させる)
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 July 23, 2019 00:14
Unity LineRender (マウスで線を描く)
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 July 18, 2018 02:45
[Swift] Userdefaults+Extension (デフォルト値の考慮)
extension UserDefaults {
//Get (デフォルト値あり)
internal static func get<T>(key: String, defaultValue: T) -> T {
let userdefaults = UserDefaults.standard
if userdefaults.object(forKey: key) != nil {
//Float
@takashi1975
takashi1975 / BallTap.cs
Created May 5, 2018 15:52
[Unity] RayCast
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallTap : MonoBehaviour, TapBehaviour {
/** タッチしたとき */
public void TapDown(ref RaycastHit hit) {
Debug.Log("TapDown : " + hit);