Esempio n. 1
0
        internal static void RemoveSplat(MenuCommand item)
        {
            var terrain = (Terrain)item.context;

            TerrainLayerUtility.RemoveTerrainLayer(terrain, item.userData);
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            if (!target)
            {
                return;
            }

            if (m_CustomUI != null && m_CustomUITerrain != null &&
                m_CustomUI.OnTerrainLayerGUI(target as TerrainLayer, m_CustomUITerrain))
            {
                return;
            }

            serializedObject.Update();

            var  curMaskMap  = m_MaskMapTexture.objectReferenceValue as Texture2D;
            bool maskMapUsed = m_MaskMapUsed || curMaskMap != null;

            var r            = EditorGUILayout.GetControlRect(true, EditorGUI.kObjectFieldThumbnailHeight);
            var diffuseLabel = m_ShowMaskMap ? (maskMapUsed ? m_DiffuseMapMaskMapEnabledText : m_DiffuseMapText) : s_Styles.diffuseTexture;

            EditorGUI.BeginProperty(r, diffuseLabel, m_DiffuseTexture);
            EditorGUI.BeginChangeCheck();
            var diffuseTexture = EditorGUI.ObjectField(r, diffuseLabel, m_DiffuseTexture.objectReferenceValue as Texture2D, typeof(Texture2D), false) as Texture2D;

            if (EditorGUI.EndChangeCheck())
            {
                m_DiffuseTexture.objectReferenceValue = diffuseTexture;
            }
            EditorGUI.EndProperty();

            TerrainLayerUtility.ValidateDiffuseTextureUI(diffuseTexture);

            r = EditorGUILayout.GetControlRect(true, EditorGUI.kObjectFieldThumbnailHeight);
            EditorGUI.BeginProperty(r, s_Styles.normalMapTexture, m_NormalMapTexture);
            EditorGUI.BeginChangeCheck();
            var normalMapTexture = EditorGUI.ObjectField(r, s_Styles.normalMapTexture, m_NormalMapTexture.objectReferenceValue as Texture2D, typeof(Texture2D), false) as Texture2D;

            if (EditorGUI.EndChangeCheck())
            {
                m_NormalMapTexture.objectReferenceValue = normalMapTexture;
                m_NormalMapHasCorrectTextureType        = TerrainLayerUtility.CheckNormalMapTextureType(normalMapTexture);
            }
            EditorGUI.EndProperty();

            TerrainLayerUtility.ValidateNormalMapTextureUI(normalMapTexture, m_NormalMapHasCorrectTextureType);

            if (normalMapTexture != null)
            {
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_NormalScale);
                --EditorGUI.indentLevel;
                EditorGUILayout.Space();
            }

            if (m_ShowMaskMap)
            {
                r = EditorGUILayout.GetControlRect(true, EditorGUI.kObjectFieldThumbnailHeight);
                EditorGUI.BeginProperty(r, m_MaskMapText, m_MaskMapTexture);
                EditorGUI.BeginChangeCheck();
                var maskMapTexture = EditorGUI.ObjectField(r, m_MaskMapText, curMaskMap, typeof(Texture2D), false) as Texture2D;
                if (EditorGUI.EndChangeCheck())
                {
                    m_MaskMapTexture.objectReferenceValue = maskMapTexture;
                }
                EditorGUI.EndProperty();

                TerrainLayerUtility.ValidateMaskMapTextureUI(maskMapTexture);

                if (maskMapUsed)
                {
                    ++EditorGUI.indentLevel;
                    m_ShowMaskRemap = EditorGUILayout.Foldout(m_ShowMaskRemap, s_Styles.channelRemapping);
                    if (m_ShowMaskRemap)
                    {
                        DoMinMaxLabels(s_Styles.min, s_Styles.max, EditorStyles.miniLabel);
                        DoMinMaxFloatFields(m_MaskRemapRText, EditorStyles.miniLabel, m_MaskRemapMinR, m_MaskRemapMaxR, EditorStyles.miniTextField);
                        DoMinMaxFloatFields(m_MaskRemapGText, EditorStyles.miniLabel, m_MaskRemapMinG, m_MaskRemapMaxG, EditorStyles.miniTextField);
                        DoMinMaxFloatFields(m_MaskRemapBText, EditorStyles.miniLabel, m_MaskRemapMinB, m_MaskRemapMaxB, EditorStyles.miniTextField);
                        DoMinMaxFloatFields(m_MaskRemapAText, EditorStyles.miniLabel, m_MaskRemapMinA, m_MaskRemapMaxA, EditorStyles.miniTextField);
                    }
                    --EditorGUI.indentLevel;
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_Specular);
            EditorGUILayout.Slider(m_Metallic, 0.0f, 1.0f);
            EditorGUILayout.Slider(m_Smoothness, 0.0f, 1.0f);

            EditorGUILayout.Space();
            TerrainLayerUtility.TilingSettingsUI(m_TileSize, m_TileOffset);

            serializedObject.ApplyModifiedProperties();
        }