示例#1
0
        public void Resize(int count)
        {
            if (instance == null)
            {
                return;
            }

            if (count == cachedObjects.Count)
            {
                return;
            }

            if (count < cachedObjects.Count)
            {
                var deleteCount = cachedObjects.Count - count;

                for (var i = 0; i < deleteCount; i++)
                {
                    var item = cachedObjects.Dequeue();
                    UnityUtility.DeleteGameObject(item);
                }
            }
            else
            {
                var addCount = count - cachedObjects.Count;

                var items = UnityUtility.Instantiate <T>(instance, prefab, addCount);

                foreach (var item in items)
                {
                    Release(item);
                }
            }
        }
示例#2
0
        private void SetupHitBox()
        {
            if (hitBoxEnable)
            {
                var parent = scrollRect.viewport;

                if (hitBox == null)
                {
                    hitBox = UnityUtility.CreateGameObject <GraphicCast>(parent.gameObject, "HitBox");
                }
                else
                {
                    UnityUtility.SetParent(hitBox, parent);
                }

                // HitBoxは全域使用.

                var rt = hitBox.transform as RectTransform;

                rt.FillRect();
            }
            else
            {
                UnityUtility.DeleteGameObject(hitBox);
            }
        }
示例#3
0
        public void Delete(string identifier)
        {
            var advObject = advObjects.GetValueOrDefault(identifier);

            advObjects.Remove(identifier);

            UnityUtility.DeleteGameObject(advObject);
        }
示例#4
0
        public void DeleteAll()
        {
            foreach (var item in advObjects.Values)
            {
                UnityUtility.DeleteGameObject(item);
            }

            advObjects.Clear();
        }
示例#5
0
        //----- field -----

        //----- property -----

        //----- method -----

        protected static void ModifyComponent(GameObject rootObject)
        {
            var canvasRenderers = rootObject.DescendantsAndSelf().OfComponent <CanvasRenderer>();

            foreach (var canvasRenderer in canvasRenderers)
            {
                var gameObject = canvasRenderer.gameObject;

                var graphicComponents = gameObject.GetComponents <Graphic>();

                if (graphicComponents.Any())
                {
                    continue;
                }

                UnityUtility.DeleteGameObject(canvasRenderer);

                EditorUtility.SetDirty(gameObject);
            }
        }
示例#6
0
        public void Clean()
        {
            foreach (var scenePopup in scenePopups)
            {
                UnityUtility.DeleteGameObject(scenePopup);
            }

            scenePopups.Clear();

            UnityUtility.SetParent(touchBloc.gameObject, parentGlobal.Parent);
            UnityUtility.SetLayer(parentGlobal.Parent, touchBloc.gameObject, true);

            if (globalPopups.IsEmpty())
            {
                if (touchBlocDisposable != null)
                {
                    touchBlocDisposable.Dispose();
                    touchBlocDisposable = null;
                }

                touchBloc.Hide();
                touchBloc.transform.SetSiblingIndex(0);
            }
        }
示例#7
0
 void OnDestroy()
 {
     UnityUtility.DeleteGameObject(eventTrigger);
 }