Exemplo n.º 1
0
        //called when the window is closed
        private void OnDestroy()
        {
            if (!saveComplete)
            {
                switch (mapType)
                {
                case MapType.GrassColor: grassFlow.colorMap = prevTex; break;

                case MapType.GrassParameters: grassFlow.paramMap = prevTex; break;
                }

                grassFlow.RevertDetailMaps();

                grassFlow.UpdateShaders();

                DestroyImmediate(resultTex);
            }
        }
    void DrawMapsInspector()
    {
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Detail Maps", bold);

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.BeginHorizontal();
        if (addMapIcon == null)
        {
            _toolIcons = GetToolIcons();
        }

        EditorGUILayout.LabelField(GetContent(() => grassFlow.colorMap), GUILayout.Width(100));
        if (GUILayout.Button(addMapIcon, new GUIStyle(EditorStyles.miniButton)
        {
            fontSize = 13, padding = new RectOffset()
        }, GUILayout.Width(16), GUILayout.Height(16)))
        {
            SaveData();
            GrassFlowMapEditor.Open(grassFlow, GrassFlowMapEditor.MapType.GrassColor);
        }
        Texture2D colorMap = EditorGUILayout.ObjectField(grassFlow.colorMap, typeof(Texture2D), true) as Texture2D;

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(GetContent(() => grassFlow.paramMap), GUILayout.Width(100));
        if (GUILayout.Button(addMapIcon, new GUIStyle(EditorStyles.miniButton)
        {
            fontSize = 13, padding = new RectOffset()
        }, GUILayout.Width(16), GUILayout.Height(16)))
        {
            SaveData();
            GrassFlowMapEditor.Open(grassFlow, GrassFlowMapEditor.MapType.GrassParameters);
        }
        Texture2D paramMap = EditorGUILayout.ObjectField(grassFlow.paramMap, typeof(Texture2D), true) as Texture2D;

        EditorGUILayout.EndHorizontal();

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(grassFlow, "GrassFlow Set Detail Map");

            grassFlow.colorMap = colorMap;
            grassFlow.paramMap = paramMap;

            if (grassFlow.drawMat)
            {
                if (!colorMap)
                {
                    grassFlow.drawMat.SetTexture("colorMap", null);
                }
                if (!paramMap)
                {
                    grassFlow.drawMat.SetTexture("dhfParamMap", null);
                }
            }

            grassFlow.RevertDetailMaps();
            grassFlow.UpdateShaders();

            Undo.FlushUndoRecordObjects();
        }
    }