예제 #1
0
        internal static void RegisterComponent(Component cmp)
        {
            LifecycleEvent(cmp, "Consider for awake");

            if (cmp is IInitializable)
            {
                IInitializable init = cmp as IInitializable;
                if (!cmp.isPrefab || (cmp.isPrefab && init.ShouldPrefabsBeInitialized()))
                {
                    init.Initialize(assetHelper);
                }
            }

            if (cmp.gameObject != null && !cmp.isPrefab)
            {
                LifecycleEvent(cmp, "Add to objects");
                objects.Add(cmp.GetInstanceID(), cmp);
                if (!cmp.isPrefab)
                {
                    LifecycleEvent(cmp, "Add to start");
                    componentsToStart.Enqueue(cmp);
                }
                if (!objects.ContainsKey(cmp.gameObject.GetInstanceID()))
                {
                    objects.Add(cmp.gameObject.GetInstanceID(), cmp.gameObject);
                }
                if (!cmp.isPrefab && typeCaps.HasCaps(cmp.GetType(), TypeSet.TypeCapabilities.Awake))
                {
                    componentsToAwake.Enqueue(cmp);
                }
            }
        }