Exemplo n.º 1
0
        //�ڵ���layout֮ǰ����һ�£���������prefab���Ƿ����������壨ͬ�����£�����������ʾ
        public static bool ProcessBeforeImport(GameObject go)
        {
            if (go == null)
            {
                return(false);
            }

            HashSet <string>   path_name_dic = new HashSet <string>();
            Stack <GameObject> stack         = new Stack <GameObject>();

            stack.Push(go);
            while (stack.Count > 0)
            {
                GameObject   cur_go   = stack.Pop();
                GameObject[] children = EditorTool.GetSubChildren(cur_go);
                for (int i = 0; i < children.Length; ++i)
                {
                    stack.Push(children[i]);
                }

                if (HasUI(cur_go, false))
                {
                    string sPathName = EditorTool.GetGameObjectFullPathName(cur_go, go);
                    if (path_name_dic.Contains(sPathName))
                    {
                        EditorUtility.DisplayDialog("", "ѡ�е�Prefab���������գɽڵ�\"" + cur_go.name + "\"���ȴ���", "ȷ��");
                        return(false);
                    }
                    else
                    {
                        path_name_dic.Add(sPathName);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        // �����Ƿ�������UIԪ�أ�Ϊÿһ���ڵ�����UIElement
        public static bool ProcessBeforeExport(GameObject go)
        {
            if (go == null)
            {
                return(false);
            }

            HashSet <string>   name_dic      = new HashSet <string>();
            HashSet <string>   path_name_dic = new HashSet <string>();
            Stack <GameObject> stack         = new Stack <GameObject>();

            //bool bFirst = true;
            stack.Push(go);
            while (stack.Count > 0)
            {
                GameObject   cur_go   = stack.Pop();
                GameObject[] children = EditorTool.GetSubChildren(cur_go);

                for (int i = 0; i < children.Length; ++i)
                {
                    stack.Push(children[i]);
                }

                string sPathName = EditorTool.GetGameObjectFullPathName(cur_go, go);
                if (HasUI(cur_go, false))
                {
                    if (name_dic.Contains(cur_go.name))
                    {
                        if (path_name_dic.Contains(sPathName))
                        {
                            EditorUtility.DisplayDialog("", "�ڵ�����\"" + cur_go.name + "\"��Ψһ���޷�����", "ȷ��");
                            return(false);
                        }
                        else
                        {
                            path_name_dic.Add(sPathName);
                        }
                    }
                    else
                    {
                        name_dic.Add(cur_go.name);
                        path_name_dic.Add(sPathName);
                    }
                }

                UIElement ui_element = cur_go.GetComponent <UIElement>();
                if (ui_element == null)
                {
                    ui_element = cur_go.AddComponent <UIElement>();
                }

                ui_element.Hide = !cur_go.activeSelf;
                //UIWidget ui_widget = ui_element.GetWidget();

                if (cur_go.name == "UIRootTempPanel")
                {
                    sPathName = "UIRootTempPanel";
                }
                //else if (bFirst)
                //{
                //    int nIndex = cur_go.name.IndexOf("(Clone)");
                //    if (nIndex > 0)
                //    {
                //        sPathName = cur_go.name.Substring(0, nIndex);
                //    }
                //}

                ui_element.FullPathName = sPathName;
                //Debug.Log(sPathName);

                //SetWidgetSelfPivot(ui_widget, UIWidget.Pivot.BottomLeft);
                //bFirst = false;
            }

            return(true);
        }