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; }
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; }
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>(); }