Ejemplo n.º 1
0
 public static void OpenGlobalUI(UIName ui)
 {
     //1.检查是否重复打开
     if (!Instance._globalUI.ContainsKey(ui))
     {
         string name = ui.ToString();
         UIPath path = Instance.FindPath(name);
         if (path != null)
         {
             GameObject obj = Instance.CreateGameObject(path);
             Instance._globalUI.Add(ui, obj);
         }
     }
     else
     {
         Debug.LogError("重复调用打开UI" + ui.ToString());
     }
 }
Ejemplo n.º 2
0
        private GameObject CreateGameObject(UIPath path)
        {
            GameObject preObj = Resources.Load(LocalPath + path.Path
                                               , typeof(GameObject)) as GameObject;

            GameObject obj = GameObject.Instantiate(preObj) as GameObject;

            GameObject root = GameObject.Find(LocalRoot);

            obj.transform.parent        = root.transform;
            obj.transform.localPosition = path.Position;
            obj.transform.localRotation = Quaternion.identity;
            obj.transform.localScale    = Vector3.one;
            obj.name = path.Name;
#if NGUI_3
            obj.GetComponent <UIPanel>().depth = path.Depth;
#else
            Vector3 zbuffer = obj.transform.localPosition;
            zbuffer.z = path.Depth;
            obj.transform.localPosition = zbuffer;
#endif
            return(obj);
        }
Ejemplo n.º 3
0
        protected override void FilterXml(System.Xml.XmlDocument doc, XmlNode root)
        {
            foreach (XmlNode item in root.ChildNodes)
            {
                UIPath vo = new UIPath();
                foreach (XmlAttribute attr in item.Attributes)
                {
                    string value = attr.Value;
                    switch (attr.Name)
                    {
                    case "Name":
                        vo.Name = value;
                        break;

                    case "Depth":
                        vo.Depth = int.Parse(value);
                        break;

                    case "Path":
                        vo.Path = value;
                        break;

                    case "Position":
                        string[] sps = value.Split(',');
                        vo.Position = new Vector3(
                            int.Parse(sps[0]),
                            int.Parse(sps[1]),
                            int.Parse(sps[2]));
                        break;

                    default:
                        break;
                    }
                }
                base.AddData(vo);
            }
        }