//实例化当前场景所有面板,并存入字典.因为它这个其实是切换场景以后,清空字典并重新添加面板 public void InitDict() { foreach (var item in mUIManager.currentScenePanelDict) { //注意这个地方的item是一个键值对,不是单纯的string,是字典的一个完整元素,包含了string和gameObject item.Value.transform.SetParent(canvasTransform); item.Value.transform.localPosition = Vector3.zero; item.Value.transform.localScale = Vector3.one; IBasePanel basePanel = item.Value.GetComponent <IBasePanel>(); if (basePanel == null) { Debug.Log("获取UI面板:" + item + "的脚本失败"); } //else //{ // Debug.Log("成功获取UI面板:" + item ); //} basePanel.InitPanel(); currentScenePanelDict.Add(item.Key, basePanel);//存储面板上面的脚本 if (item.Key == StringManager.HelpPanel) { //Debug.Log("帮助面板已添加"); } } }
public void InitDict() { foreach (var item in mUIManager.currentScenePanelDict) { item.Value.transform.SetParent(canvasTransform); item.Value.transform.localPosition = Vector3.zero; item.Value.transform.localScale = Vector3.one; IBasePanel basePanel = item.Value.GetComponent <IBasePanel>(); if (basePanel == null) { Debug.Log("获取Ibasepanel脚本失败,该物体为" + item.Value.name); } basePanel.InitPanel(); currentScenePanelDict.Add(item.Key, basePanel); } }
/// <summary> /// 实例化当前场景的所有面板并存入字典 /// </summary> public void InitDict() { foreach (KeyValuePair <string, GameObject> item in mUIManager.currentScenePanelDict) { item.Value.transform.SetParent(canvasTrans); item.Value.transform.localPosition = Vector3.zero; item.Value.transform.localScale = Vector3.one; IBasePanel basePanel = item.Value.GetComponent <IBasePanel>(); if (basePanel == null) { Debug.Log("获取UI面板上IBasePanel脚本失败"); } basePanel.InitPanel(); currentScenePanelDict.Add(item.Key, basePanel); } }
// 实例化当前场景下的UIPanel并存入字典 public void InitUIPanelDict() { foreach (var item in mUIManager.currentScenePanelDict) { item.Value.transform.SetParent(canvas); item.Value.transform.localPosition = Vector3.zero; item.Value.transform.localScale = Vector3.one; IBasePanel basePanel = item.Value.GetComponent <IBasePanel>(); if (basePanel == null) { Debug.LogWarning(string.Format("{0}上的IBasePanel脚本丢失!", item.Key)); } basePanel.InitPanel(); // UIPanel初始化UI currentScenePanelDict.Add(item.Key, basePanel); // 将该场景下的UIPanel身上的Panel脚本添加进字典中 } }
//实例化当前场景所有面板(在UIManager中),并存入字典 public void InitPanel() { foreach (var item in uiManager.currentScenePanelDict) { item.Value.transform.SetParent(canvasTransform); item.Value.transform.localPosition = Vector3.zero; item.Value.transform.localScale = Vector3.one; IBasePanel basePanel = item.Value.GetComponent <IBasePanel>(); //Debug.Log(item.Key); if (basePanel == null) { Debug.Log("获取面板上IBasePanel脚本失败: " + item.Key); } basePanel.InitPanel(); //调用Panel初始化方法 currentScenePanelDict.Add(item.Key, basePanel); } }
/// <summary> /// 实例化当前场景所有面板,并存入字典 /// </summary> public void InitDict() { foreach (var gameObject in uiManger.currentScenePanelDict) { gameObject.Value.transform.SetParent(canvasTransform); gameObject.Value.transform.localPosition = Vector3.zero; gameObject.Value.transform.localScale = Vector3.one; IBasePanel basePanel = gameObject.Value.GetComponent <IBasePanel>(); if (basePanel == null) { Debug.Log("获取面板脚本失败"); } else { basePanel.InitPanel(); currentScenePanelDict.Add(gameObject.Key, basePanel); } } }