private void Awake()
    {
        Animator.Looping = false;
        Animator.Reverse = false;
        generator        = Animator.Generator;
        startMesh        = generator.TargetMesh.mesh;
        for (int i = 0; i < Sequence.Length; i++)
        {
            if (Sequence[i].Settings != null)
            {
                generator.UsedProfile = Sequence[i].Settings;
                generator.LoadSettings();
                generator.ApplyBlur();
                generator.GenerateMesh();
                Debug.Log("generate Mesh");
                Sequence[i].Mesh      = generator.TargetMesh.mesh;
                Sequence[i].Mesh.name = "Sequence: " + i;
            }
        }

        //Start condition again
        generator.TargetMesh.mesh = startMesh;
        if (Sequence[0].Mesh != null)
        {
            generator.TargetMesh.mesh = Sequence[0].Mesh;
        }
        generator.UsedProfile = Sequence[0].Settings;
        generator.LoadSettings();
        generator.ApplyBlur();


        NextAnimation();
    }
    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();
        }
    }
Beispiel #3
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();
        }
    }