public void CreatePanel <T>(string path) where T : UIBase { GameObject ass = ResourcesMgr.GetAsset <GameObject>(path); GameObject go = GameObject.Instantiate(ass); go.AddComponent <T>(); go.transform.SetParent(uiCanvas.transform); RectTransform rt = go.transform as RectTransform; rt.localPosition = Vector3.zero; rt.localScale = Vector3.one; rt.sizeDelta = Vector2.zero; go.name = typeof(T).ToString(); }
public void CreateChildPanel <T>(string childName, string path) where T : UIBase { GameObject ass = ResourcesMgr.GetAsset <GameObject>(path); GameObject go = GameObject.Instantiate(ass); go.AddComponent <T>(); Transform parentTr = transform; if (uicomponents.ContainsKey(childName)) { parentTr = uicomponents[childName].transform; } go.transform.SetParent(parentTr); RectTransform rt = go.transform as RectTransform; rt.localPosition = Vector3.zero; rt.localScale = Vector3.one; rt.sizeDelta = Vector2.zero; go.name = typeof(T).ToString(); }