Example #1
0
            public FollowInstanceData EnableInstanceNext()
            {
                Debug.Assert(isActiveCount < followInstanceData.Count);

                FollowInstanceData instance = followInstanceData[isActiveCount++];

                instance.gameObject.SetActive(true);

                return(instance);
            }
Example #2
0
            private void AllocateInstance(GameObject prefab, Transform parent)
            {
                var instance = new FollowInstanceData();

                if (parent != null)
                {
                    instance.gameObject = Instantiate(prefab, parent);
                    instance.gameObject.SetActive(false);
                    instance.renderer = instance.gameObject.GetComponentInChildren <Renderer>(includeInactive: true);
                    Debug.Assert(instance.renderer != null);
                }

                followInstanceData.Add(instance);
            }
Example #3
0
            public void DisableInstance(FollowInstanceData instance)
            {
                int instanceIndex = followInstanceData.IndexOf(instance);

                Debug.Assert(instanceIndex >= 0 && instanceIndex < isActiveCount);

                --isActiveCount;
                if (isActiveCount > 0)
                {
                    FollowInstanceData instanceActiveLast = followInstanceData[isActiveCount];
                    followInstanceData[instanceIndex] = instanceActiveLast;
                    followInstanceData[isActiveCount] = instance;
                }

                instance.gameObject.SetActive(false);
            }