//-------Export Java Class File
    public void exportClassJava()
    {
        string fileName  = "";
        string classname = "ConV" + root.tag.Replace(" ", "");

                #if UNITY_EDITOR
        fileName = EditorUtility.SaveFilePanel("choose the path you save", Application.dataPath, classname, "java");
                #endif
        if (string.IsNullOrEmpty(fileName))
        {
            return;
        }
        classname = fileName.Substring(fileName.LastIndexOf("/") + 1);
        classname = classname.Replace(".java", "");
        string buffer = "public class " + classname + "\r\n{";
        for (int i = 0; i < this.paramlist.Count; i++)
        {
            List <FixClassCircle.UseParam> detail = this.paramlist[i].Detail;
            for (int j = 0; j < detail.Count; j++)
            {
                buffer += "\r\n\tpublic final String " + detail[j].NameEng.Replace(" ", "_").ToUpper() + "_" + i + " = \"" + detail[j].NameEng + "\";";
            }
        }
        buffer += "\r\n}";
        FixClassCircle.Save(fileName, buffer);
    }
 public void ImportByString(string content)
 {
     CanNot_OnBeforeSerialize = true;
     fileResult = FixClassCircle.LoadContent(content);
     whenImport();
     CanNot_OnBeforeSerialize = false;
 }
 void OnEnable()
 {
     _target = (FixClassCircle)target;
     if (_target != null && _target.root.home == null)
     {
         _target.root.home = _target;
     }
 }
 void copyNode(object obj)
 {
     FixClassCircle.Node node = obj as FixClassCircle.Node;
     if (node != null)
     {
         clipboardNode = FixClassCircle.DuplicateNode(node);
     }
 }
 public void Import(string filePath)
 {
     CanNot_OnBeforeSerialize = true;
     fileResult = FixClassCircle.Load(filePath);
     if (fileResult != null)
     {
         whenImport();
     }
     CanNot_OnBeforeSerialize = false;
 }
    public void Export(string filePath)
    {
        string result = ExportString();

        FixClassCircle.Save(filePath, result);
    }
예제 #7
0
 public Node(FixClassCircle parent)
 {
     this.home = parent;
 }
    //draw data part
    bool Display(FixClassCircle.Node node)      //return if Display should do next time
    {
        Rect   titleRect = EditorGUILayout.BeginHorizontal();
        string titlename = node.tagCh;

        if (!string.IsNullOrEmpty(node.tagCh))
        {
            titlename += " / ";
        }
        titlename += node.tag;
        if (_target.ShowSize)
        {
            titlename += " / size:" + node.children.Count;
        }
        if (node.forSearch)
        {
            node.foldout = EditorGUILayout.Foldout(node.foldout, titlename, EditorStyles.foldoutPreDrop);
        }
        else
        {
            node.foldout = EditorGUILayout.Foldout(node.foldout, titlename);
        }
        if (node.editMode)
        {
            if (GUILayout.Button(forbutton6_2, EditorStyles.toolbarButton, GUILayout.Width(20)))
            {
                node.editMode = false;
                //опо├╦Л╦э
                node.searchStr = "";
                foreach (var child in node.children)
                {
                    child.forSearch = false;
                }
                _target.Record2SerializeOnce();
            }
        }
        else
        {
            if (GUILayout.Button(forbutton6, GUILayout.Width(20)))
            {
                node.editMode = true;
            }
        }
        if (Event.current.isMouse && Event.current.button == 1 && titleRect.Contains(Event.current.mousePosition))
        {
            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("Copy Node"), false, copyNode, node);
            if (node.father != null)
            {
                menu.AddItem(new GUIContent("Cut Node"), false, cutNode, node);
            }
            menu.AddItem(new GUIContent("Paste Node as a child"), false, pasteNode, node);
            menu.AddItem(new GUIContent("Empty clipboard"), false, emptyClipboard, null);
            menu.ShowAsContext();
            Event.current.Use();
        }

        if (GUILayout.Button(forbutton1, GUILayout.Width(20)))
        {
            node.children.Add(new FixClassCircle.Node(_target)
            {
                father = node
            });
            _target.Record2SerializeOnce();
            node.foldout = true;
        }

        /*
         *      if (GUILayout.Button (forbutton2,GUILayout.Width(20)))
         *      {
         *              node.children.Clear();
         *              _target.Record2SerializeOnce();
         *      }
         */
        if (node.father != null)
        {
            if (GUILayout.Button(forbutton5, GUILayout.Width(22)))
            {
                FixClassCircle.Node nodetmp = FixClassCircle.DuplicateNode(node);
                nodetmp.father = node.father;
                int index = node.father.children.IndexOf(node);
                node.father.children.Insert(index, nodetmp);
                _target.Record2SerializeOnce();
                return(true);
            }
            if (GUILayout.Button(forbutton3, GUILayout.Width(20)))
            {
                node.father.children.Remove(node);
                _target.Record2SerializeOnce();
                return(true);
            }
        }

        /******Delete child by tag***************
         * if (GUILayout.Button (forbutton3,GUILayout.Width(20)) && node.delTag.Length >0)
         * {
         *      for(int i=0;i<node.children.Count;i++)
         *      {
         *              if(node.children[i].tag.Equals(node.delTag))
         *              {
         *                      node.children.RemoveAt(i);
         *                      i=-1;
         *                      _target.Record2SerializeOnce();
         *              }
         *      }
         *      node.delTag = "";
         * }
         * //node.delTag = GUILayout.TextField(node.delTag,GUILayout.Width(100));
         * node.delTag = EditorGUILayout.TextField(node.delTag,GUILayout.Width(100));
         ******************************************/
        EditorGUILayout.EndHorizontal();
        if (!node.foldout)
        {
            EditorGUIUtility.labelWidth -= indentation;
        }
        if (node.editMode)
        {
            GUILayout.BeginHorizontal();
            GUI.color = color_Edit;
            GUILayout.Space(indentation);

            node.tagCh = EditorGUILayout.TextField(node.tagCh, GUILayout.Width(90));
            node.tag   = EditorGUILayout.TextField(node.tag, GUILayout.Width(95));
            if (GUILayout.Button(forbutton4, EditorStyles.radioButton, GUILayout.Width(20)))
            {
                FixClassCircle.ParamMore temp = _target.paramlist[node.paramIndex];
                if (temp.Detail.Count > 0 && temp.Detail[0].type == FixClassCircle.ParamType.IntEnum)
                {
                    string[] ss    = temp.Detail[0].EnumDesc.Split(',');
                    int      index = 0;
                    int.TryParse(node.otherParamValues[0], out index);
                    node.tag = ss[index];
                    _target.Record2SerializeOnce();
                }
            }
            //EditorGUILayout.LabelField("Param",GUILayout.Width(40));
            node.paramIndex = EditorGUILayout.Popup(node.paramIndex, getParamlistEnumStrArr(), GUILayout.Width(70));
            if (node.paramIndex < 0)
            {
                node.paramIndex = 0;
            }
            node.searchStr = EditorGUILayout.TextField(node.searchStr, GUILayout.Width(70));
            if (GUILayout.Button(forbutton7, GUILayout.Width(20)))
            {
                foreach (var child in node.children)
                {
                    if (node.searchStr.Length > 0 && (child.tag.Contains(node.searchStr) || child.tagCh.Contains(node.searchStr)))
                    {
                        child.forSearch = true;
                    }
                    else
                    {
                        child.forSearch = false;
                        child.foldout   = false;
                    }
                }
            }
            GUI.color = color_normal;
            GUILayout.EndHorizontal();
        }
        if (!node.foldout)
        {
            return(false);
        }
        if (_target.paramlist.Count - 1 < node.paramIndex)
        {
            EditorGUIUtility.labelWidth -= indentation;
            return(false);           //wait until list count is enough
        }
        for (int i = 0; i < _target.paramlist[node.paramIndex].Detail.Count && i < node.otherParamValues.Count; i++)
        {
            FixClassCircle.ParamType tempT = _target.paramlist[node.paramIndex].Detail[i].type;
            if (hidebelowparam && tempT != FixClassCircle.ParamType.BoolHideBelow && tempT != FixClassCircle.ParamType.BoolShowBelow)
            {
                continue;
            }
            GUILayout.BeginHorizontal();
            GUILayout.Space(indentation);
            drawParams(node, i);
            GUILayout.EndHorizontal();
        }
        hidebelowparam = false;

        //---------------------------------------------------
        GUILayout.BeginHorizontal();
        GUILayout.Space(indentation);
        EditorGUIUtility.labelWidth -= indentation;
        GUILayout.BeginVertical();

        foreach (var child in node.children)
        {
            if (Display(child) || forceQuitDraw)
            {
                forceQuitDraw = false;
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                return(true);
            }
            EditorGUIUtility.labelWidth += indentation;             // not plus not reduce
        }

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        return(false);
    }