Example #1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUILayout.LabelField(" ------- Create List String Field --------", EditorStyles.boldLabel);
        enumFilePath = EditorGUILayout.TextField("List Enum File Path", enumFilePath);
        enumFileName = EditorGUILayout.TextField("List Enum File Name ", enumFileName);

        if (GUILayout.Button("Add Enum"))
        {
            someClass.AddEnums();
        }

        if (GUILayout.Button("Remove Lastest Enum"))
        {
            someClass.RemoveLastEnum();
        }


        if (GUILayout.Button("Create Enums"))
        {
            if (someClass.ListEnums.Count == 0)
            {
                Debug.LogWarning("Warning, this list is empty");
                return;
            }
            data = new List <string>();
            var list = someClass.ListEnums;
            foreach (EnumGenerator.ENUM e in list)
            {
                data.Add("public enum " + e.name + "\n{");
                for (int i = 0; i < e.values.Count; i++)
                {
                    data.Add(string.Format("\t{0} = {1},", e.values[i], i));
                }
                data.Add("}\n");
            }

            if (EnumWriterEditor.CheckIfFileIsExist(enumFilePath, enumFileName))
            {
                if (EditorUtility.DisplayDialog("WARNING", WARNING_FILE_EXIST, "NO", "YES"))
                {
                    EnumWriterEditor.WriteToEnum(enumFilePath, enumFileName, data);
                }
            }
            else
            {
                EnumWriterEditor.WriteToEnum(enumFilePath, enumFileName, data);
            }
        }

        if (GUILayout.Button("Delete Enum"))
        {
            EnumWriterEditor.DeleteFile(enumFilePath, enumFileName);
        }
    }