Exemple #1
0
    private void OnGUI()
    {
        GUILayout.Label("Animal creation tool", EditorStyles.boldLabel);
        GUILayout.Label("Tool setup", EditorStyles.boldLabel);

        //--------------------------------------------------------------------------------Tool settings-------------------------------------------------------//
        #region tool settings
        animalPrefab       = ExtensionMethods.GameObjectField("Animal Template", animalPrefab);
        animalPrefabFolder = ExtensionMethods.GetFolder("Animal prefab folder", animalPrefabFolder);
        animalPrefabPath   = ExtensionMethods.GetPath("target path", animalInfoPath, animalPrefabFolder);

        animalInfoFolder = ExtensionMethods.GetFolder("Animal info folder", animalInfoFolder);
        animalInfoPath   = ExtensionMethods.GetPath("target path", animalInfoPath, animalInfoFolder);



        showCreateNewAnimal = ExtensionMethods.GetToggle("Create new Animal?", showCreateNewAnimal);

        #endregion

        if (showCreateNewAnimal)
        {
            GUILayout.Label("Animal stats", EditorStyles.boldLabel);
            //-----------------------------------------------------------------------------Animal stats--------------------------------------------------------//
            #region stats
            animalSprite  = ExtensionMethods.Spritefield("animal sprite", animalSprite);
            animalName    = ExtensionMethods.GetText("Animal name", animalName);
            animalSpecies = ExtensionMethods.GetText("Animal species", animalSpecies);
            helloText     = ExtensionMethods.GetText("Hello text", helloText);
            thankText     = ExtensionMethods.GetText("thankText", thankText);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Speed", GUILayout.Width(Screen.width / 2));
            speed = EditorGUILayout.IntField(speed, GUILayout.Width(Screen.width / 2));
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Select eating type", GUILayout.Width(Screen.width / 2));
            eatingType = (ScriptableAnimal.AnimalType)EditorGUILayout.EnumPopup("", eatingType, GUILayout.Width(Screen.width * 0.45f));
            EditorGUILayout.EndHorizontal();

            #endregion
            //---------------------------------------------------------------------------Moves and tricks------------------------------------------------------//
            #region tricks and moves
            GUILayout.Label("Animal moves and tricks", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Amount of Actions", GUILayout.Width(Screen.width / 4));
            amountOfActions = EditorGUILayout.IntField(amountOfActions, GUILayout.Width(Screen.width / 4));
            actions         = ExtensionMethods.SelectActions("", actions, amountOfActions);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Amount of tricks", GUILayout.Width(Screen.width / 4));
            amountOfTricks = EditorGUILayout.IntField(amountOfTricks, GUILayout.Width(Screen.width / 4));
            tricks         = ExtensionMethods.SelectTricks("", tricks, amountOfTricks);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            #endregion

            //---------------------------------------------------------------------------create animal--------------------------------------------------------//
            if (GUILayout.Button("create animal"))
            {
                CreateNew(CreateAnimalScriptableObject());
            }
        }
        else
        {
            animalInfo = ExtensionMethods.AnimalInfoField("", animalInfo);
            if (GUILayout.Button("create animal"))
            {
                CreateNew(animalInfo);
            }
        }
    }