Esempio n. 1
0
        /// <summary>
        /// Edit texture
        /// </summary>
        /// <param name="tec">Member to save the current values</param>
        /// <param name="selected">Selected texture</param>
        private void DrawRemoveEditor(TextureEditContainer tec, int selected)
        {
            // Draw label
            GUILayout.Label(new GUIContent("Remove Texture"), EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();

            // Draw label
            GUILayout.Label("Are you sure?", EditorStyles.boldLabel);

            FlexibleSpace(5);

            // Remvoe splatprototype
            if (GUILayout.Button(new GUIContent("yes")))
            {
                tp_Utilities.RemoveSplatTexture(component.TerrainData, selected);
                tec.m_textureWindow = EditWindow.None;
            }

            // Draw cancel button
            if (GUILayout.Button(new GUIContent("no")))
            {
                tec.m_textureWindow = EditWindow.None;
            }
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 2
0
        /// <summary>
        /// Add texture
        /// </summary>
        /// <param name="tec">Member to save the current values</param>
        private void DrawTextureAdd(TextureEditContainer tec)
        {
            GUILayout.Label(new GUIContent("Add Texture"), EditorStyles.boldLabel);
            DrawTextureEditFields(tec);

            EditorGUILayout.BeginHorizontal();
            FlexibleSpace(5);

            // Draw cancel button
            if (GUILayout.Button("cancel"))
            {
                ResetTextureEditValues(tec);
            }

            // Add splatprototype
            if (GUILayout.Button("add"))
            {
                if (tec.m_mainTextureSelector && tec.m_textureSize.x > 0.0 && tec.m_textureSize.y > 0.0f)
                {
                    tp_Utilities.AddSplatTexture(
                        component.TerrainData,
                        tec.m_mainTextureSelector,
                        tec.m_normTextureSelector,
                        tec.m_textureSize,
                        tec.m_textureOffset,
                        tec.m_textureSpecialSettings.x,
                        tec.m_textureSpecialSettings.y,
                        tec.m_textureSpecularity);

                    ResetTextureEditValues(tec);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 3
0
        /// <summary>
        /// Draw texture edit
        /// Add, Edit, Remove buttons
        /// </summary>
        /// <param name="tec">Member to save the current values</param>
        /// <param name="selected"></param>
        private void DrawTextureEditor(TextureEditContainer tec, int selected)
        {
            EditorGUILayout.BeginHorizontal();
            FlexibleSpace(5);

            // Draw add button
            if (GUILayout.Button(new GUIContent("add")))
            {
                ResetTextureEditValues(tec);
                tec.m_textureWindow = EditWindow.Add;
            }

            // Check if texture is selected
            if (component.TerrainData.splatPrototypes.Length < 1 || selected < 0 || selected >= component.TerrainData.splatPrototypes.Length)
            {
                GUI.enabled = false;
            }

            // Draw edit button
            if (GUILayout.Button(new GUIContent("edit")))
            {
                // Get splatprototype data
                SplatPrototype sp = component.TerrainData.splatPrototypes[selected];
                tec.m_mainTextureSelector      = sp.texture;
                tec.m_normTextureSelector      = sp.normalMap;
                tec.m_textureSize              = sp.tileSize;
                tec.m_textureOffset            = sp.tileOffset;
                tec.m_textureSpecialSettings.x = sp.metallic;
                tec.m_textureSpecialSettings.y = sp.smoothness;
                tec.m_textureSpecularity       = sp.specular;
                tec.m_textureWindow            = EditWindow.Edit;
            }

            // Draw remove button
            if (GUILayout.Button(new GUIContent("remove")))
            {
                tec.m_textureWindow = EditWindow.Remove;
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            // Check which menu needs to be drawn
            switch (tec.m_textureWindow)
            {
            case EditWindow.Add:
                DrawTextureAdd(tec);
                break;

            case EditWindow.Edit:
                DrawTextureEdit(tec, selected);
                break;

            case EditWindow.Remove:
                DrawRemoveEditor(tec, selected);
                break;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Reset container
 /// </summary>
 /// <param name="tec">Member where splatprototypes values have been stored</param>
 private void ResetTextureEditValues(TextureEditContainer tec)
 {
     tec.m_mainTextureSelector      = null;
     tec.m_normTextureSelector      = null;
     tec.m_textureSize              = new Vector2(15.0f, 15.0f);
     tec.m_textureOffset            = Vector2.zero;
     tec.m_textureSpecialSettings.x = 0.0f;
     tec.m_textureSpecialSettings.y = 0.0f;
     tec.m_textureSpecularity       = Color.black;
     tec.m_textureWindow            = EditWindow.None;
 }
Esempio n. 5
0
 /// <summary>
 /// Draw splatprototype editor
 /// </summary>
 /// <param name="tec">Member to save values</param>
 private void DrawTextureEditFields(TextureEditContainer tec)
 {
     // Create texture fields
     EditorGUILayout.BeginVertical();
     tec.m_mainTextureSelector      = EditorGUILayout.ObjectField("Texture", tec.m_mainTextureSelector, typeof(Texture2D), false) as Texture2D;
     tec.m_normTextureSelector      = EditorGUILayout.ObjectField("Normal map", tec.m_normTextureSelector, typeof(Texture2D), false) as Texture2D;
     tec.m_textureSize              = EditorGUILayout.Vector2Field("Size", tec.m_textureSize);
     tec.m_textureOffset            = EditorGUILayout.Vector2Field("Offset", tec.m_textureOffset);
     tec.m_textureSpecialSettings.x = EditorGUILayout.Slider("Metalic", tec.m_textureSpecialSettings.x, 0.0f, 1.0f);
     tec.m_textureSpecialSettings.y = EditorGUILayout.Slider("Smoothness", tec.m_textureSpecialSettings.y, 0.0f, 1.0f);
     tec.m_textureSpecularity       = EditorGUILayout.ColorField("Specular", tec.m_textureSpecularity);
     Seperator(2);
     EditorGUILayout.EndVertical();
 }
Esempio n. 6
0
 /// <summary>
 /// Reset container
 /// </summary>
 /// <param name="tec">Member where splatprototypes values have been stored</param>
 private void ResetTextureEditValues(TextureEditContainer tec)
 {
     tec.m_mainTextureSelector = null;
     tec.m_normTextureSelector = null;
     tec.m_textureSize = new Vector2(15.0f, 15.0f);
     tec.m_textureOffset = Vector2.zero;
     tec.m_textureSpecialSettings.x = 0.0f;
     tec.m_textureSpecialSettings.y = 0.0f;
     tec.m_textureSpecularity = Color.black;
     tec.m_textureWindow = EditWindow.None;
 }
Esempio n. 7
0
 /// <summary>
 /// Draw splatprototype editor
 /// </summary>
 /// <param name="tec">Member to save values</param>
 private void DrawTextureEditFields(TextureEditContainer tec)
 {
     // Create texture fields
     EditorGUILayout.BeginVertical();
     tec.m_mainTextureSelector = EditorGUILayout.ObjectField("Texture", tec.m_mainTextureSelector, typeof(Texture2D), false) as Texture2D;
     tec.m_normTextureSelector = EditorGUILayout.ObjectField("Normal map", tec.m_normTextureSelector, typeof(Texture2D), false) as Texture2D;
     tec.m_textureSize = EditorGUILayout.Vector2Field("Size", tec.m_textureSize);
     tec.m_textureOffset = EditorGUILayout.Vector2Field("Offset", tec.m_textureOffset);
     tec.m_textureSpecialSettings.x = EditorGUILayout.Slider("Metalic", tec.m_textureSpecialSettings.x, 0.0f, 1.0f);
     tec.m_textureSpecialSettings.y = EditorGUILayout.Slider("Smoothness", tec.m_textureSpecialSettings.y, 0.0f, 1.0f);
     tec.m_textureSpecularity = EditorGUILayout.ColorField("Specular", tec.m_textureSpecularity);
     Seperator(2);
     EditorGUILayout.EndVertical();
 }
Esempio n. 8
0
        /// <summary>
        /// Edit texture
        /// </summary>
        /// <param name="tec">Member to save the current values</param>
        /// <param name="selected">Selected texture</param>
        private void DrawRemoveEditor(TextureEditContainer tec, int selected)
        {
            // Draw label
            GUILayout.Label(new GUIContent("Remove Texture"), EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();

            // Draw label
            GUILayout.Label("Are you sure?", EditorStyles.boldLabel);

            FlexibleSpace(5);

            // Remvoe splatprototype
            if (GUILayout.Button(new GUIContent("yes")))
            {
                tp_Utilities.RemoveSplatTexture(component.TerrainData, selected);
                tec.m_textureWindow = EditWindow.None;
            }

            // Draw cancel button
            if (GUILayout.Button(new GUIContent("no")))
            {
                tec.m_textureWindow = EditWindow.None;
            }
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 9
0
        /// <summary>
        /// Edit texture
        /// </summary>
        /// <param name="tec">Member to save the current values</param>
        /// <param name="selected">Selected texture</param>
        private void DrawTextureEdit(TextureEditContainer tec, int selected)
        {
            // Draw label
            GUILayout.Label(new GUIContent("Edit Texture"), EditorStyles.boldLabel);

            DrawTextureEditFields(tec);

            EditorGUILayout.BeginHorizontal();
            FlexibleSpace(5);

            // Draw calcel button
            if (GUILayout.Button("cancel")) { ResetTextureEditValues(tec); }

            // Set new values to splatprototype
            if (GUILayout.Button("edit"))
            {
                if (tec.m_mainTextureSelector && tec.m_textureSize.x > 0.0 && tec.m_textureSize.y > 0.0f)
                {
                    tp_Utilities.EditSplatTexture(
                        component.TerrainData,
                        selected,
                        tec.m_mainTextureSelector,
                        tec.m_normTextureSelector,
                        tec.m_textureSize,
                        tec.m_textureOffset,
                        tec.m_textureSpecialSettings.x,
                        tec.m_textureSpecialSettings.y,
                        tec.m_textureSpecularity);

                    ResetTextureEditValues(tec);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 10
0
        /// <summary>
        /// Draw texture edit
        /// Add, Edit, Remove buttons
        /// </summary>
        /// <param name="tec">Member to save the current values</param>
        /// <param name="selected"></param>
        private void DrawTextureEditor(TextureEditContainer tec, int selected)
        {
            EditorGUILayout.BeginHorizontal();
            FlexibleSpace(5);

            // Draw add button
            if (GUILayout.Button(new GUIContent("add")))
            {
                ResetTextureEditValues(tec);
                tec.m_textureWindow = EditWindow.Add;
            }

            // Check if texture is selected
            if (component.TerrainData.splatPrototypes.Length < 1 || selected < 0 || selected >= component.TerrainData.splatPrototypes.Length) { GUI.enabled = false; }

            // Draw edit button
            if (GUILayout.Button(new GUIContent("edit")))
            {
                // Get splatprototype data
                SplatPrototype sp = component.TerrainData.splatPrototypes[selected];
                tec.m_mainTextureSelector = sp.texture;
                tec.m_normTextureSelector = sp.normalMap;
                tec.m_textureSize = sp.tileSize;
                tec.m_textureOffset = sp.tileOffset;
                tec.m_textureSpecialSettings.x = sp.metallic;
                tec.m_textureSpecialSettings.y = sp.smoothness;
                tec.m_textureSpecularity = sp.specular;
                tec.m_textureWindow = EditWindow.Edit;
            }

            // Draw remove button
            if (GUILayout.Button(new GUIContent("remove")))
            {
                tec.m_textureWindow = EditWindow.Remove;
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            // Check which menu needs to be drawn
            switch (tec.m_textureWindow)
            {
                case EditWindow.Add:
                    DrawTextureAdd(tec);
                    break;
                case EditWindow.Edit:
                    DrawTextureEdit(tec, selected);
                    break;
                case EditWindow.Remove:
                    DrawRemoveEditor(tec, selected);
                    break;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Draw texture selector
        /// </summary>
        private void DrawSelectorEditor(TextureEditContainer tec, TextureSelectType type, bool drawEditor = true)
        {
            // Draw label
            string labelMsg;
            switch (type)
            {
                case TextureSelectType.Default: labelMsg = "Texture Selector"; break;
                case TextureSelectType.Cliff: labelMsg = "Cliff Selector"; break;
                case TextureSelectType.Multi: labelMsg = ""; break;
                default: labelMsg = ""; break;
            }
            GUILayout.Label(labelMsg, EditorStyles.boldLabel);

            Rect position = EditorGUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);

            // Settings
            Color tempBackColor = GUI.backgroundColor;
            const int imgSize = 50;
            const int spacing = 4;
            float totalSpacing = (float)spacing;
            position.width = Screen.width - (20.0f + spacing * 2.0f);

            // Set position
            Rect current = position;
            current.width = current.height = imgSize;
            current.x += spacing;
            current.y += spacing;

            // Get amount of columns
            int columnCount = (int)((position.width - (2 * spacing)) / (spacing + imgSize));

            for (int i = 0; i < component.TerrainData.splatPrototypes.Length; i++)
            {
                GUI.backgroundColor = TP.Colors.UnSelectedColor;
                if (i > 0 && i % columnCount == 0)
                {
                    // Do new line
                    totalSpacing += imgSize + spacing;
                    current.x = position.x + spacing;
                    current.y = position.y + totalSpacing;
                }
                else if (i != 0) { current.x += imgSize + spacing; }

                switch (type)
                {
                    case TextureSelectType.Default:
                        // Set colour
                        if (i == component.Textures.SelectedTexture) { GUI.backgroundColor = TP.Colors.SelectedPaintTextureColor; }
                        else if (i == component.Textures.SelectedCliffBrush && component.Ramp.Active) { GUI.backgroundColor = Color.Lerp(TP.Colors.UnSelectedColor, TP.Colors.SelectedCliffTextureColor, 0.3f); }
                        if (GUI.Button(current, component.TerrainData.splatPrototypes[i].texture))
                        {
                            // Set selected texture
                            if (component.Textures.SelectedCliffBrush == i) { component.Textures.SelectedCliffBrush = component.Textures.SelectedTexture; }
                            component.Textures.SelectedTexture = i;
                        }
                        break;

                    case TextureSelectType.Cliff:
                        // Set colour
                        if (i == component.Textures.SelectedCliffBrush) { GUI.backgroundColor = TP.Colors.SelectedCliffTextureColor; }
                        else if (i == component.Textures.SelectedTexture) { GUI.backgroundColor = Color.Lerp(TP.Colors.UnSelectedColor, TP.Colors.SelectedPaintTextureColor, 0.3f); }
                        if (GUI.Button(current, component.TerrainData.splatPrototypes[i].texture))
                        {
                            // Set selected texture
                            if (component.Textures.SelectedTexture == i) { component.Textures.SelectedTexture = component.Textures.SelectedCliffBrush; }
                            component.Textures.SelectedCliffBrush = i;
                        }
                        break;

                    case TextureSelectType.Multi:
                        if (component.Textures.IsSelected(i)) { GUI.backgroundColor = TP.Colors.SelectedCliffTextureColor; }
                        if (GUI.Button(current, component.TerrainData.splatPrototypes[i].texture))
                        {
                            if (component.Textures.IsSelected(i)) { component.Textures.SelectedTextures &= ~(1 << i); }
                            else { component.Textures.SelectedTextures |= 1 << i; }
                        }
                        break;
                }
            }

            // Reset settings
            GUI.backgroundColor = tempBackColor;
            totalSpacing += imgSize + spacing;
            current.x = position.x + spacing;
            current.y = position.y + totalSpacing;
            current.width = position.width;
            GUILayout.Space(totalSpacing);

            if (drawEditor)
            {
                switch (type)
                {
                    case TextureSelectType.Default:
                        DrawTextureEditor(tec, component.Textures.SelectedTexture);
                        break;
                    case TextureSelectType.Cliff:
                        DrawTextureEditor(tec, component.Textures.SelectedCliffBrush);
                        break;
                    case TextureSelectType.Multi:
                        //DrawTextureEditor(tec, component.Textures.SelectedTexture);
                        break;
                }
            }
            EditorGUILayout.EndVertical();
        }
Esempio n. 12
0
        /// <summary>
        /// Draw texture selector
        /// </summary>
        private void DrawSelectorEditor(TextureEditContainer tec, TextureSelectType type, bool drawEditor = true)
        {
            // Draw label
            string labelMsg;

            switch (type)
            {
            case TextureSelectType.Default: labelMsg = "Texture Selector"; break;

            case TextureSelectType.Cliff: labelMsg = "Cliff Selector"; break;

            case TextureSelectType.Multi: labelMsg = ""; break;

            default: labelMsg = ""; break;
            }
            GUILayout.Label(labelMsg, EditorStyles.boldLabel);

            Rect position = EditorGUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);

            // Settings
            Color     tempBackColor = GUI.backgroundColor;
            const int imgSize       = 50;
            const int spacing       = 4;
            float     totalSpacing  = (float)spacing;

            position.width = Screen.width - (20.0f + spacing * 2.0f);

            // Set position
            Rect current = position;

            current.width = current.height = imgSize;
            current.x    += spacing;
            current.y    += spacing;

            // Get amount of columns
            int columnCount = (int)((position.width - (2 * spacing)) / (spacing + imgSize));

            for (int i = 0; i < component.TerrainData.splatPrototypes.Length; i++)
            {
                GUI.backgroundColor = TP.Colors.UnSelectedColor;
                if (i > 0 && i % columnCount == 0)
                {
                    // Do new line
                    totalSpacing += imgSize + spacing;
                    current.x     = position.x + spacing;
                    current.y     = position.y + totalSpacing;
                }
                else if (i != 0)
                {
                    current.x += imgSize + spacing;
                }

                switch (type)
                {
                case TextureSelectType.Default:
                    // Set colour
                    if (i == component.Textures.SelectedTexture)
                    {
                        GUI.backgroundColor = TP.Colors.SelectedPaintTextureColor;
                    }
                    else if (i == component.Textures.SelectedCliffBrush && component.Ramp.Active)
                    {
                        GUI.backgroundColor = Color.Lerp(TP.Colors.UnSelectedColor, TP.Colors.SelectedCliffTextureColor, 0.3f);
                    }
                    if (GUI.Button(current, component.TerrainData.splatPrototypes[i].texture))
                    {
                        // Set selected texture
                        if (component.Textures.SelectedCliffBrush == i)
                        {
                            component.Textures.SelectedCliffBrush = component.Textures.SelectedTexture;
                        }
                        component.Textures.SelectedTexture = i;
                    }
                    break;

                case TextureSelectType.Cliff:
                    // Set colour
                    if (i == component.Textures.SelectedCliffBrush)
                    {
                        GUI.backgroundColor = TP.Colors.SelectedCliffTextureColor;
                    }
                    else if (i == component.Textures.SelectedTexture)
                    {
                        GUI.backgroundColor = Color.Lerp(TP.Colors.UnSelectedColor, TP.Colors.SelectedPaintTextureColor, 0.3f);
                    }
                    if (GUI.Button(current, component.TerrainData.splatPrototypes[i].texture))
                    {
                        // Set selected texture
                        if (component.Textures.SelectedTexture == i)
                        {
                            component.Textures.SelectedTexture = component.Textures.SelectedCliffBrush;
                        }
                        component.Textures.SelectedCliffBrush = i;
                    }
                    break;

                case TextureSelectType.Multi:
                    if (component.Textures.IsSelected(i))
                    {
                        GUI.backgroundColor = TP.Colors.SelectedCliffTextureColor;
                    }
                    if (GUI.Button(current, component.TerrainData.splatPrototypes[i].texture))
                    {
                        if (component.Textures.IsSelected(i))
                        {
                            component.Textures.SelectedTextures &= ~(1 << i);
                        }
                        else
                        {
                            component.Textures.SelectedTextures |= 1 << i;
                        }
                    }
                    break;
                }
            }

            // Reset settings
            GUI.backgroundColor = tempBackColor;
            totalSpacing       += imgSize + spacing;
            current.x           = position.x + spacing;
            current.y           = position.y + totalSpacing;
            current.width       = position.width;
            GUILayout.Space(totalSpacing);

            if (drawEditor)
            {
                switch (type)
                {
                case TextureSelectType.Default:
                    DrawTextureEditor(tec, component.Textures.SelectedTexture);
                    break;

                case TextureSelectType.Cliff:
                    DrawTextureEditor(tec, component.Textures.SelectedCliffBrush);
                    break;

                case TextureSelectType.Multi:
                    //DrawTextureEditor(tec, component.Textures.SelectedTexture);
                    break;
                }
            }
            EditorGUILayout.EndVertical();
        }