private IPooledMonoBehaviour[] GetPooledMonoBehaviours(GameObject gameObject) { IPooledMonoBehaviour[] behaviourArray = null; MonoBehaviour[] componentsInChildren = gameObject.GetComponentsInChildren <MonoBehaviour>(); if ((componentsInChildren == null) || (componentsInChildren.Length <= 0)) { return(new IPooledMonoBehaviour[0]); } int index = 0; for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i] is IPooledMonoBehaviour) { index++; } } behaviourArray = new IPooledMonoBehaviour[index]; index = 0; for (int j = 0; j < componentsInChildren.Length; j++) { IPooledMonoBehaviour behaviour2 = componentsInChildren[j] as IPooledMonoBehaviour; if (behaviour2 != null) { behaviourArray[index] = behaviour2; index++; } } return(behaviourArray); }
public void AddCachedMono(MonoBehaviour mono, bool defaultEnabled) { if ((mono != null) && (mono is IPooledMonoBehaviour)) { IPooledMonoBehaviour[] behaviourArray = new IPooledMonoBehaviour[this.m_cachedIPooledMonos.Length + 1]; for (int i = 0; i < this.m_cachedIPooledMonos.Length; i++) { behaviourArray[i] = this.m_cachedIPooledMonos[i]; } behaviourArray[this.m_cachedIPooledMonos.Length] = mono as IPooledMonoBehaviour; this.m_cachedIPooledMonos = behaviourArray; } }
public void AddCachedMono(MonoBehaviour mono, bool defaultEnabled) { if (mono == null) { return; } if (mono is IPooledMonoBehaviour) { IPooledMonoBehaviour[] array = new IPooledMonoBehaviour[this._cachedIPooledMonos.Length + 1]; for (int i = 0; i < this._cachedIPooledMonos.Length; i++) { array[i] = this._cachedIPooledMonos[i]; } array[this._cachedIPooledMonos.Length] = (mono as IPooledMonoBehaviour); this._cachedIPooledMonos = array; } }
private void HandlePooledMonoBehaviour(IPooledMonoBehaviour[] pooledMonoBehaviours, enPooledMonoBehaviourAction pooledMonoBehaviourAction) { for (int i = 0; i < pooledMonoBehaviours.Length; i++) { IPooledMonoBehaviour behaviour = pooledMonoBehaviours[i]; if ((behaviour != null) && (behaviour as MonoBehaviour).enabled) { switch (pooledMonoBehaviourAction) { case enPooledMonoBehaviourAction.Create: behaviour.OnCreate(); break; case enPooledMonoBehaviourAction.Get: behaviour.OnGet(); break; case enPooledMonoBehaviourAction.Recycle: behaviour.OnRecycle(); break; } } } }