public override void OnInspectorGUI()
    {
        // Let the default inspecter draw all the values
        DrawDefaultInspector();

        // Spawn buttons

        if (GUILayout.Button("Apply Blur effect to the Texture to Blur"))
        {
            targetScript.ApplyBlur();
        }

        if (GUILayout.Button("Apply your own effect to the Texture to Blur"))
        {
            targetScript.ApplyYourOwnEffect();
        }

        /*
         *
         * if (GUILayout.Button("Generate 2D Data")) {
         *  targetScript.Generate2DData();
         * }
         *
         * if (GUILayout.Button("Generate 3D Data")) {
         *  targetScript.Generate3DDataFrom2DData();
         * }
         *
         */

        if (GUILayout.Button("Generate a terrain with the chosen visualisation method"))
        {
            targetScript.GenerateMesh();
        }

        if (GUILayout.Button("Color the terrain with the current settings"))
        {
            targetScript.ColorMesh();
        }

        if (GUILayout.Button("Save the terrain as a mesh"))
        {
            AssetDatabase.CreateAsset(targetScript.GeneratedMesh, targetScript.GenerateSavePath());
            AssetDatabase.SaveAssets();
        }

        if (GUILayout.Button("Save settings to file"))
        {
            targetScript.SaveSettings();
        }

        if (GUILayout.Button("Load settings from file"))
        {
            targetScript.LoadSettings();
        }
    }
예제 #2
0
    public override void OnInspectorGUI()
    {
        // Let the default inspecter draw all the values
        DrawDefaultInspector();

        // Spawn buttons

        if (GUILayout.Button("Apply Blur effect to the Texture to Blur"))
        {
            if (targetScript.InputTexture != null && !AssetDatabase.Contains(targetScript.InputTexture))
            {
                Texture2D.DestroyImmediate(targetScript.InputTexture);
                Resources.UnloadUnusedAssets();
            }
            targetScript.ApplyBlur();
        }

        if (GUILayout.Button("Apply your own effect to the Texture to Blur"))
        {
            if (targetScript.InputTexture != null && !AssetDatabase.Contains(targetScript.InputTexture))
            {
                Texture2D.DestroyImmediate(targetScript.InputTexture);
                Resources.UnloadUnusedAssets();
            }
            targetScript.ApplyYourOwnEffect();
        }

        if (GUILayout.Button("Generate a terrain with the chosen visualisation method"))
        {
            if (targetScript.GeneratedMesh != null && !AssetDatabase.Contains(targetScript.GeneratedMesh))
            {
                Mesh.DestroyImmediate(targetScript.GeneratedMesh);
                Resources.UnloadUnusedAssets();
            }
            targetScript.GenerateMesh();
        }

        if (GUILayout.Button("Recalculate image data for new settings."))
        {
            targetScript.Generate2DData();
            targetScript.Generate3DDataFrom2DData();
        }

        if (GUILayout.Button("Color the terrain with the current settings"))
        {
            targetScript.ColorMesh();
        }

        if (GUILayout.Button("Save the terrain as a mesh"))
        {
            AssetDatabase.CreateAsset(targetScript.GeneratedMesh, targetScript.GenerateSavePath());
            AssetDatabase.SaveAssets();
        }

        if (GUILayout.Button("Save settings to file"))
        {
            targetScript.SaveSettings();
        }

        if (GUILayout.Button("Load settings from file"))
        {
            targetScript.LoadSettings();
        }
    }
    public override void OnInspectorGUI()
    {
        // Let the default inspecter draw all the values
        DrawDefaultInspector();

        // Spawn buttons

        if (GUILayout.Button("Apply Blur effect to the Texture to Blur"))
        {
            targetScript.ApplyBlur();
        }

        //if (GUILayout.Button("Apply your own effect to the Texture to Blur")) {
        //targetScript.ApplyYourOwnEffect();
        //}

        /*
         *
         * if (GUILayout.Button("Generate 2D Data")) {
         *  targetScript.Generate2DData();
         * }
         *
         * if (GUILayout.Button("Generate 3D Data")) {
         *  targetScript.Generate3DDataFrom2DData();
         * }
         *
         */

        if (GUILayout.Button("Generate a terrain with the chosen visualisation method"))
        {
            targetScript.GenerateMesh();
        }

        if (GUILayout.Button("Color the terrain with the current settings"))
        {
            targetScript.ColorMesh();
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("Show Advanced Setting", GUILayout.Width(145));
        targetScript.showAdvanced = EditorGUILayout.Toggle(targetScript.showAdvanced);
        GUILayout.EndHorizontal();

        if (targetScript.showAdvanced)
        {
            EditorGUILayout.PropertyField(generatedMesh, new GUIContent("GeneratedMesh : "));



            //Todo do it using a better fitting object
            //EditorGUILayout.LabelField("Handling Saving and Loading");

            EditorGUILayout.PropertyField(fileName, new GUIContent("Mesh Name : "));


            if (GUILayout.Button("Save the terrain as a mesh"))
            {
                AssetDatabase.CreateAsset(targetScript.GeneratedMesh, targetScript.GenerateSavePath());
                AssetDatabase.SaveAssets();
            }

            EditorGUILayout.PropertyField(usedProfile, new GUIContent("UsedProfile : "));

            if (GUILayout.Button("Save settings to local settings file"))
            {
                targetScript.SaveSettings();
            }

            if (GUILayout.Button("Load settings from local settings file"))
            {
                targetScript.LoadSettings();
            }

            EditorGUILayout.PropertyField(jsonFileName, new GUIContent("JsonFileName : "));

            if (GUILayout.Button("Export settings to json"))
            {
                targetScript.ExportSettingsFile();
                AssetDatabase.Refresh();
            }

            if (GUILayout.Button("Import settings from json"))
            {
                targetScript.ImportSettingsFile();
            }

            // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
            serializedObject.ApplyModifiedProperties();
        }
    }