Beispiel #1
0
        /// <summary>
        /// 死亡時の処理を追加
        /// </summary>
        /// <param name="gameObject"></param>
        /// <param name="callback"></param>
        public static void AddOnDestroyCallback(GameObject gameObject, Action callback)
        {
            OnDestroyCallback onDestroyCallback = gameObject.GetComponent <OnDestroyCallback>();

            if (!onDestroyCallback)
            {
                onDestroyCallback           = gameObject.AddComponent <OnDestroyCallback>();
                onDestroyCallback.hideFlags = HideFlags.HideAndDontSave;
            }
            onDestroyCallback.onDestroy += callback;
        }
Beispiel #2
0
 public static void AddOnDestroyCallback(this GameObject gameObject, Action callback)
 {
     OnDestroyCallback.AddOnDestroyCallback(gameObject, callback);
 }