Exemple #1
0
 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);
 }
Exemple #2
0
        public static AObjectBase CreateView(Type type, GameObject gameObject, object data = null)
        {
            AObjectBase aObjectBase = (AObjectBase)Activator.CreateInstance(type);

            aObjectBase.InitObject(gameObject, data);
            return(aObjectBase);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 public static T GetComponent <T>(this AObjectBase aObjectBase) where T : AObjectBase
 {
     if (aObjectBase == null)
     {
         return(null);
     }
     return(LccViewFactory.GetView <T>(aObjectBase.gameObject));
 }
Exemple #5
0
 public static void SafeDestroy(this AObjectBase aObjectBase)
 {
     if (aObjectBase == null)
     {
         return;
     }
     Object.Destroy(aObjectBase.gameObject);
 }
Exemple #6
0
        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));
        }
Exemple #7
0
 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);
 }
Exemple #8
0
        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);
        }
Exemple #9
0
 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);
 }
Exemple #10
0
 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);
 }
Exemple #11
0
        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);
        }
Exemple #12
0
 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);
 }
Exemple #13
0
 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);
 }