Esempio n. 1
0
 protected virtual void OnDisable()
 {
     if (OnDisabled != null)
     {
         OnDisabled.Invoke();
     }
 }
Esempio n. 2
0
        private void OnDisable()
        {
#if UNITY_EDITOR
            EditorApplication.update     -= EditorAppUpdateCallback;
            SceneView.onSceneGUIDelegate -= HandleOnSceneGUI;
#endif
            OnDisabled?.Invoke();
#if UNITY_EDITOR && LOG_RELOAD_TIME
            Debug.Log("disabled" + EditorApplication.timeSinceStartup.ToString());
            startReloadTime = EditorApplication.timeSinceStartup;
#endif
        }
Esempio n. 3
0
    private void OnTriggerExit(Collider other)
    {
        WeightedObject o = other.GetComponent <WeightedObject>();

        if (o == null)
        {
            return;
        }
        bool wasActivated = Activated;

        activeObjects.Remove(o.gameObject);
        RemoveObject(o);
        if (wasActivated != Activated)
        {
            OnDisabled.Invoke();
        }
    }
Esempio n. 4
0
        /// <summary>
        /// Return an active pool member so that it can be used again later
        /// </summary>
        /// <param name="item">The reference to the item that is to be returned. This must be alive as currently marked by this pool</param>
        /// <returns>Returns true if the item was returned to the pool. Otherwise false</returns>
        /// <remarks>
        /// Using this functionality will modify the order of items in the pool from their original use order.
        /// This can effect functionality that is dependent on maintaining that order
        /// </remarks>
        public bool ReturnItem(T item)
        {
            // Find the index of the item in the pool
            int index = FindIndex(x => x == item);

            if (index == -1)
            {
                return(false);
            }

            // Swap it around with the last entry
            T temp = itemPool[AliveObjects - 1];

            itemPool[AliveObjects - 1] = item;
            itemPool[index]            = temp;
            --AliveObjects;

            // Disable the element as needed
            OnDisabled?.Invoke(item);
            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Reset the items that are in the pool to a default state
        /// </summary>
        /// <param="_destroyItems">Flags if the pooled items should be destroyed instead<param>
        public void ResetPool(bool _destroyItems)
        {
            if (_destroyItems)
            {
                // Just destroy and clear the list
                for (int i = 0; i < itemPool.Count; ++i)
                {
                    if (itemPool[i] != null)
                    {
                        if (i < AliveObjects)
                        {
                            OnDisabled?.Invoke(itemPool[i]);
                        }
                        OnDestroy?.Invoke(itemPool[i]);
                    }
                }
                itemPool.Clear();
            }
            else
            {
                // Disable the items for later re-use
                for (int i = itemPool.Count - 1; i >= 0; --i)
                {
                    if (itemPool[i] != null)
                    {
                        if (i < AliveObjects)
                        {
                            OnDisabled?.Invoke(itemPool[i]);
                        }
                    }
                    else
                    {
                        itemPool.RemoveAt(i);
                    }
                }
            }

            // Nothing left active
            AliveObjects = 0;
        }
 private void OnDisable()
 {
     OnDisabled.Invoke();
 }
Esempio n. 7
0
 private void OnDisable() => OnDisabled?.Invoke();
Esempio n. 8
0
        /// <summary>
        /// Disables firewall.
        /// </summary>
        public virtual void Disable()
        {
            _mEnabled = false;

            OnDisabled?.Invoke();
        }
Esempio n. 9
0
 public void Disable()
 {
     OnDisabled?.Invoke(this);
     gameObject.SetActive(false);
 }
Esempio n. 10
0
 private void OnDisable()
 {
     onDisabled?.Invoke();
 }
Esempio n. 11
0
 public void Close()
 {
     gameObject.SetActive(false);
     callbackAction?.Invoke();
     OnDisabled?.Invoke(this);
 }
Esempio n. 12
0
 public void PowerUpDisable(Motor motor)
 {
     OnDisabled?.Invoke();
     Disable(motor);
 }