private void Awake() { if (instance == null) { instance = this; } else { Debug.Log("l'instance de MasterPath existe deja. :)"); Destroy(gameObject); } }
/* * public static MstBulletRecord[] MstBulletRecordTable = { * new MstBulletRecord(){id = 10,gravy = -20f,gravx = 0.95f,rad = 10,weight = 1f} * };*/ /* * protected override void Awake() * { * * base.Awake(); * InitMasterdata(FindMasterdata()); * } */ //initialize void InitRecord <T>() where T : class, IMasterRecord { Attribute[] attributes = Attribute.GetCustomAttributes(typeof(T), typeof(MasterPath)); //object[] attributes = typeof(T).GetCustomAttributes(typeof(MasterPath),false); if (attributes == null || attributes.Length == 0) { throw new InvalidOperationException("The provided object is not serializable"); } MasterPath path = attributes[0] as MasterPath; if (path == null) { return; } // Debug.Log(typeof(T) + "Init"); MasterTable <T> .Instance.Init(path.Path); }