Пример #1
0
        public static void Add()
        {
            if (inprogress)
            {
                return;
            }
            inprogress = true;
            GameObject go;

            if (Selection.gameObjects.Length >= 1)
            {
                var parent = Selection.gameObjects[0];
                go = GameObjectEx.InstantiateEmptyToChild <AtlasImage>(parent, "AtlasButton").gameObject;
            }
            else
            {
                go = GameObjectEx.InstantiateEmptyToRoot <AtlasImage>("AtlasButton").gameObject;
            }
            go.GetRectTransform().sizeDelta = new Vector2(160, 30);
            go.AddComponent <Button>();
            var text = GameObjectEx.InstantiateEmptyToChild <Text>(go, "Text");

            text.text      = "Button";
            text.alignment = TextAnchor.MiddleCenter;
            text.color     = new Color(50f / 255f, 50f / 255f, 50f / 255f, 255);
            var textRT = text.rectTransform;

            textRT.sizeDelta = Vector2.zero;
            textRT.anchorMin = Vector2.zero;
            textRT.anchorMax = Vector2.one;
            Selection.SetActiveObjectWithContext(go, null);
            inprogress = false;
        }
Пример #2
0
        public static void Add()
        {
            if (inprogress)
            {
                return;
            }
            inprogress = true;
            GameObject go;

            if (Selection.gameObjects.Length >= 1)
            {
                var parent = Selection.gameObjects[0];
                go = GameObjectEx.InstantiateEmptyToChild <AtlasImage>(parent, "AtlasImage").gameObject;
            }
            else
            {
                go = GameObjectEx.InstantiateEmptyToRoot <AtlasImage>("AtlasImage").gameObject;
            }
            Selection.SetActiveObjectWithContext(go, null);
            inprogress = false;
        }
Пример #3
0
        void Initialize()
        {
            // プールを用意する.
            if (poolHierarchy == null)
            {
                var poolGO = GameObjectEx.InstantiateEmptyToRoot(POOL_NAME);
                DontDestroyOnLoad(poolGO);
                poolGO.SetActive(false);
                poolHierarchy = poolGO.transform;
            }
            // プールスタックを用意する.
            var prefabInstanceID = prefab.GetInstanceID();

            if (poolStackDic.ContainsKey(prefabInstanceID))
            {
                poolStack = poolStackDic[prefabInstanceID];
            }
            else
            {
                poolStack = new Stack <T>();
                poolStackDic[prefabInstanceID] = poolStack;
            }
            rentedList = new List <T>();
        }