private IEnumerator InvisibleTimeCoroutine(UnityEngine.GameObject obj, float time, bool deep, bool hide, bool ignoreLinked) { List <InvisibleObjectCache> objectsCaches = new List <InvisibleObjectCache>(); int invisiblingId = ++_invisiblingId; if (deep) { InvisibleFillCache(obj, ref objectsCaches, ignoreLinked); } else { InvisibleObjectCache mainObjCache = new InvisibleObjectCache(obj); if (mainObjCache.IsValid()) { objectsCaches.Add(mainObjCache); } } if (objectsCaches.Count == 0) { yield break; } if (!hide) // unhide => hide first { foreach (InvisibleObjectCache objectCache in objectsCaches) { objectCache.SetAlpha(0); } } bool done = false; float timeDelta; while (!done && invisiblingId == _invisiblingId) { done = true; timeDelta = Time.deltaTime / time; foreach (InvisibleObjectCache objectCache in objectsCaches) { if (objectCache.IsValid()) // can be invalidated (when linked object is destroyed before this effect ends) { done = objectCache.AddAlpha(timeDelta, hide) && done; } } yield return(null); } yield break; }
private void InvisibleFillCache(UnityEngine.GameObject obj, ref List <InvisibleObjectCache> objectsCaches, bool ignoreLinked) { InvisibleObjectCache mainObjCache = new InvisibleObjectCache(obj); if (mainObjCache.IsValid()) { objectsCaches.Add(mainObjCache); } int count = obj.transform.childCount; for (int i = 0; i < count; ++i) { Transform child = obj.transform.GetChild(i); if (!ignoreLinked || child.GetComponent <Picus.Utils.GO.TopInfo>() == null) { InvisibleFillCache(child.gameObject, ref objectsCaches, ignoreLinked); } } }
private IEnumerator InvisibleTimeCoroutine(UnityEngine.GameObject obj, float time, bool deep, bool hide, bool ignoreLinked) { List<InvisibleObjectCache> objectsCaches = new List<InvisibleObjectCache>(); int invisiblingId = ++_invisiblingId; if (deep) { InvisibleFillCache(obj, ref objectsCaches, ignoreLinked); } else { InvisibleObjectCache mainObjCache = new InvisibleObjectCache(obj); if (mainObjCache.IsValid()) objectsCaches.Add(mainObjCache); } if (objectsCaches.Count == 0) yield break; if (!hide) // unhide => hide first { foreach (InvisibleObjectCache objectCache in objectsCaches) { objectCache.SetAlpha(0); } } bool done = false; float timeDelta; while (!done && invisiblingId == _invisiblingId) { done = true; timeDelta = Time.deltaTime / time; foreach (InvisibleObjectCache objectCache in objectsCaches) { if (objectCache.IsValid()) // can be invalidated (when linked object is destroyed before this effect ends) { done = objectCache.AddAlpha(timeDelta, hide) && done; } } yield return null; } yield break; }
private void InvisibleFillCache(UnityEngine.GameObject obj, ref List<InvisibleObjectCache> objectsCaches, bool ignoreLinked) { InvisibleObjectCache mainObjCache = new InvisibleObjectCache(obj); if (mainObjCache.IsValid()) objectsCaches.Add(mainObjCache); int count = obj.transform.childCount; for(int i = 0; i < count; ++i) { Transform child = obj.transform.GetChild(i); if (!ignoreLinked || child.GetComponent<Picus.Utils.GO.TopInfo>() == null) InvisibleFillCache(child.gameObject, ref objectsCaches, ignoreLinked); } }