private void Start() { while (start.Count > 0) { long id = start.Dequeue(); if (aObjectBases.ContainsKey(id)) { AObjectBase aObjectBase = (AObjectBase)aObjectBases[id]; if (aObjectBase.lccView == null) { continue; } if (aObjectBase.gameObject.activeSelf && aObjectBase.lccView.enabled && !aObjectBase.isStart) { aObjectBase.isStart = true; aObjectBase.Start(); } else { startCopy.Enqueue(id); } } } ObjectUtil.Swap(ref start, ref startCopy); }
public static AObjectBase CreateView(Type type, GameObject gameObject, object data = null) { AObjectBase aObjectBase = (AObjectBase)Activator.CreateInstance(type); aObjectBase.InitObject(gameObject, data); return(aObjectBase); }
public static T CreateView <T>(GameObject gameObject, object data = null) where T : AObjectBase { AObjectBase aObjectBase = Activator.CreateInstance <T>(); aObjectBase.InitObject(gameObject, data); return((T)aObjectBase); }
public static T GetComponent <T>(this AObjectBase aObjectBase) where T : AObjectBase { if (aObjectBase == null) { return(null); } return(LccViewFactory.GetView <T>(aObjectBase.gameObject)); }
public static void SafeDestroy(this AObjectBase aObjectBase) { if (aObjectBase == null) { return; } Object.Destroy(aObjectBase.gameObject); }
public static T AddChildComponent <T>(this AObjectBase aObjectBase, params string[] childs) where T : AObjectBase { GameObject childGameObject = aObjectBase.GetChildGameObject(childs); if (childGameObject == null) { return(null); } return(LccViewFactory.CreateView <T>(childGameObject)); }
public void Register(AObjectBase aObjectBase) { aObjectBases.Add(aObjectBase.id, aObjectBase); awake.Enqueue(aObjectBase.id); onEnable.Enqueue(aObjectBase.id); start.Enqueue(aObjectBase.id); fixedUpdate.Enqueue(aObjectBase.id); update.Enqueue(aObjectBase.id); lateUpdate.Enqueue(aObjectBase.id); onDisable.Enqueue(aObjectBase.id); destroy.Enqueue(aObjectBase.id); }
public static void SafeDestroy <T>(this AObjectBase aObjectBase) where T : AObjectBase { if (aObjectBase == null) { return; } T component = aObjectBase.GetComponent <T>(); if (component == null) { return; } Object.Destroy(component.gameObject); }
private void Awake() { while (awake.Count > 0) { long id = awake.Dequeue(); if (aObjectBases.ContainsKey(id)) { AObjectBase aObjectBase = (AObjectBase)aObjectBases[id]; if (aObjectBase.gameObject.activeSelf && !aObjectBase.isAwake) { aObjectBase.isAwake = true; aObjectBase.Awake(); } else { awakeCopy.Enqueue(id); } } } ObjectUtil.Swap(ref awake, ref awakeCopy); }
private void LateUpdate() { while (lateUpdate.Count > 0) { long id = lateUpdate.Dequeue(); if (aObjectBases.ContainsKey(id)) { AObjectBase aObjectBase = (AObjectBase)aObjectBases[id]; if (aObjectBase.lccView == null) { continue; } if (aObjectBase.gameObject.activeSelf && aObjectBase.lccView.enabled) { aObjectBase.LateUpdate(); } lateUpdateCopy.Enqueue(id); } } ObjectUtil.Swap(ref lateUpdate, ref lateUpdateCopy); }
public static GameObject GetChildGameObject(this AObjectBase aObjectBase, params string[] childs) { if (aObjectBase == null) { return(null); } string child = string.Empty; for (int i = 0; i < childs.Length - 1; i++) { child = $"{child}{childs[i]}/"; } child += childs[childs.Length - 1]; Transform childTransform = aObjectBase.gameObject.transform.Find(child); if (childTransform == null) { return(null); } return(childTransform.gameObject); }
private void Destroy() { while (destroy.Count > 0) { long id = destroy.Dequeue(); if (aObjectBases.ContainsKey(id)) { AObjectBase aObjectBase = (AObjectBase)aObjectBases[id]; if (aObjectBase.gameObject == null || aObjectBase.lccView == null) { aObjectBase.OnDestroy(); aObjectBases.Remove(aObjectBase.id); aObjectBase = null; } else { destroyCopy.Enqueue(id); } } } ObjectUtil.Swap(ref destroy, ref destroyCopy); }
private void OnEnable() { while (onEnable.Count > 0) { long id = onEnable.Dequeue(); if (aObjectBases.ContainsKey(id)) { AObjectBase aObjectBase = (AObjectBase)aObjectBases[id]; if (aObjectBase.lccView == null) { continue; } if (aObjectBase.gameObject.activeSelf && aObjectBase.lccView.enabled && !aObjectBase.isOnEnable) { aObjectBase.isOnEnable = true; aObjectBase.isOnDisable = false; aObjectBase.OnEnable(); } onEnableCopy.Enqueue(id); } } ObjectUtil.Swap(ref onEnable, ref onEnableCopy); }