/** * 根据prefab或者模版来创建新的 widget */ public bool CreateByPrefab(UIWindowBase parent, GameObject goPrefab, Transform parentTrans, bool visible = true) { if (parentTrans == null) { parentTrans = parent.transform; } var widgetRoot = GameObject.Instantiate(goPrefab, parentTrans); return(CreateImp(parent, widgetRoot, true, visible)); }
/// <summary> 根据资源名创建 </summary> public bool CreateByPath(string resPath, UIWindowBase parent, Transform parentTrans = null, bool visible = true) { GameObject goInst = ResourceManagr.Instance.GetAssetCache <GameObject>(resPath);//DResources.AllocGameObject(resPath, parentTrans); if (goInst == null) { return(false); } if (!Create(parent, goInst, visible)) { return(false); } goInst.transform.localScale = Vector3.one; goInst.transform.localPosition = Vector3.zero; return(true); }
public void RmvChild(UIWindowBase child) { //如果已经销毁了或者销毁过程中,那么不掉用删除 if (m_destroyed) { return; } if (m_listChild != null) { if (m_listChild.Remove(child)) { MarkListChanged(); } } }
private void RestChildCanvas(UIWindowBase parent) { if (gameObject == null) { return; } if (parent == null || parent.gameObject == null) { return; } Canvas parentCanvas = parent.gameObject.GetComponentInParent <Canvas>(); if (parentCanvas == null) { return; } var listCanvas = gameObject.GetComponentsInChildren <Canvas>(true); for (var index = 0; index < listCanvas.Length; index++) { var childCanvas = listCanvas[index]; childCanvas.sortingOrder = parentCanvas.sortingOrder + childCanvas.sortingOrder % UIWindow.MaxCanvasSortingOrder; } }
/** * 创建窗口内嵌的界面 */ public bool Create(UIWindowBase parent, GameObject widgetRoot, bool visible = true) { return(CreateImp(parent, widgetRoot, false, visible)); }
/// <summary> 根据类型创建 </summary> public bool CreateByType <T>(UIWindowBase parent, Transform parentTrans = null) where T : UIWindowWidget { string resPath = string.Format("UI/{0}", typeof(T).Name); return(CreateByPath(resPath, parent, parentTrans)); }