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

        if (GUILayout.Button("Save unit types"))
        {
            EdiorMethods.WriteToEnum(filePath, fileName, unitsConfig.unitTypes);
        }

        DrawDamageMatrix();
    }
    private void DrawGUI()
    {
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add new", GUILayout.Height(25)))
        {
            string newItem = capacity > 0 ? customEnum.enumNames.Last() : "";
            customEnum.enumNames.Add(newItem);

            capacity++;
        }

        GUILayout.Space(20);
        if (GUILayout.Button("Remove last", GUILayout.Height(25)))
        {
            if (capacity > 0)
            {
                customEnum.enumNames.Remove(customEnum.enumNames.Last());
                capacity--;
            }
        }
        GUILayout.Space(10);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);


        GUI.enabled = false;
        filePath    = EditorGUILayout.TextField("Path", filePath);
        fileName    = EditorGUILayout.TextField("Name", fileName);

        GUI.enabled = isStringsValide && isStringsUnique;
        if (GUILayout.Button("Save", GUILayout.Height(30)))
        {
            EdiorMethods.WriteToEnum(filePath, fileName, customEnum.enumNames);

            EditorUtility.SetDirty(customEnum);
            AssetDatabase.SaveAssets();
        }
        GUI.enabled = true;
    }