Exemplo n.º 1
0
        private static bool DestroyingMethod <DestroyedT>(DestroyedT DestroyedObject, string destroyerName) where DestroyedT : UnityObject
        {
            DestroyingObjectEventArgs <DestroyedT>  DestroyingArgs     = new DestroyingObjectEventArgs <DestroyedT>(DestroyedObject, destroyerName);
            DestroyingObjectEventArgs <UnityObject> SentDestroyingArgs = (DestroyingObjectEventArgs <UnityObject>)DestroyingArgs;

            _destroyingObject?.Invoke(SentDestroyingArgs);
            return(!SentDestroyingArgs.Cancel);
        }
Exemplo n.º 2
0
        public static async Task DestroyImmediate <DestroyedT>(DestroyedT DestroyedObject, int msDelay = 0, [CallerFilePath, DontProvide] string destroyerPath = "") where DestroyedT : UnityObject
        {
            string destroyerName = destroyerPath.Remove(destroyerPath.Length - 3).Split('\\').Last();
            await Task.Delay(msDelay);

            DestroyingObjectEventArgs <DestroyedT>  DestroyingArgs     = new DestroyingObjectEventArgs <DestroyedT>(DestroyedObject, destroyerName);
            ObjectDestroyedEventArgs <DestroyedT>   DestroyedArgs      = new ObjectDestroyedEventArgs <DestroyedT>(DestroyedObject, destroyerName); //might be useless
            DestroyingObjectEventArgs <UnityObject> SentDestroyingArgs = (DestroyingObjectEventArgs <UnityObject>)DestroyingArgs;
            ObjectDestroyedEventArgs <UnityObject>  SentDestroyedArgs  = (ObjectDestroyedEventArgs <UnityObject>)DestroyedArgs;                     //might be useless

            _destroyingObject?.Invoke(SentDestroyingArgs);
            if (!SentDestroyingArgs.Cancel)
            {
                UnityObject.DestroyImmediate(DestroyedObject);
            }
        }