ソースコード
public static class GenericUtils { public static void Swap<T>( ref T a, ref T b ) { var tmp = a; a = b; b = tmp; } }
使用例
using UnityEngine; public class Example : MonoBehaviour { private void Awake() { int a = 1; int b = 2; GenericUtils.Swap( ref a, ref b ); Debug.Log( a ); Debug.Log( b ); } }