示例#1
0
        void ShowBasicSettings()
        {
            m_Settings.GroupingID        = EditorGUILayout.IntField(Styles.GroupingID, m_Settings.GroupingID);
            m_Settings.AutoConnect       = EditorGUILayout.Toggle(Styles.AllowAutoConnect, m_Settings.AutoConnect);
            m_Settings.DrawHeightmap     = EditorGUILayout.Toggle(Styles.DrawTerrain, m_Settings.DrawHeightmap);
            m_Settings.DrawInstanced     = EditorGUILayout.Toggle(Styles.DrawInstancedTerrain, m_Settings.DrawInstanced);
            m_Settings.PixelError        = EditorGUILayout.Slider(Styles.PixelError, m_Settings.PixelError, 1, 200);
            m_Settings.BaseMapDistance   = EditorGUILayout.Slider(Styles.BaseMapDist, m_Settings.BaseMapDistance, 0, kBaseMapDistMax);
            m_Settings.ShadowCastingMode = (ShadowCastingMode)EditorGUILayout.EnumPopup(Styles.CastShadows, m_Settings.ShadowCastingMode);
#if UNITY_2019_2_OR_NEWER
            m_Settings.MaterialTemplate = EditorGUILayout.ObjectField("Material", m_Settings.MaterialTemplate, typeof(Material), false) as Material;
#if UNITY_2021_2_OR_NEWER
            TerrainInspectorUtility.TerrainShaderValidationGUI(m_Settings.MaterialTemplate);
#endif
            m_Settings.ReflectionProbeUsage = (ReflectionProbeUsage)EditorGUILayout.EnumPopup(Styles.ReflectionProbes, m_Settings.ReflectionProbeUsage);
#else
            m_Settings.MaterialType = (Terrain.MaterialType)EditorGUILayout.EnumPopup(Styles.Material, m_Settings.MaterialType);

            if (m_Settings.MaterialType == Terrain.MaterialType.Custom)
            {
                m_Settings.MaterialTemplate     = EditorGUILayout.ObjectField("Material", m_Settings.MaterialTemplate, typeof(Material), false) as Material;
                m_Settings.ReflectionProbeUsage = (ReflectionProbeUsage)EditorGUILayout.EnumPopup(Styles.ReflectionProbes, m_Settings.ReflectionProbeUsage);
            }

            if (m_Settings.MaterialType == Terrain.MaterialType.BuiltInLegacySpecular)
            {
                m_Settings.LegacySpecular  = EditorGUILayout.ColorField("Specular Color", m_Settings.LegacySpecular);
                m_Settings.LegacyShininess = EditorGUILayout.Slider("Shininess", m_Settings.LegacyShininess, 0, 1);
            }
#endif
        }
示例#2
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();

            commonUI.OnInspectorGUI(terrain, editContext);

            m_TargetStrength = EditorGUILayout.Slider(Styles.targetStrengthTxt, m_TargetStrength, 0.0f, 1.0f);

            if (m_TemplateMaterialEditor == null)
            {
                m_TemplateMaterialEditor = Editor.CreateEditor(terrain.materialTemplate);                                   // fix - 1306604
            }
#if UNITY_2019_2_OR_NEWER
            // Material GUI
            m_ShowMaterialEditor = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.materialControls, m_ShowMaterialEditor);
            if (m_ShowMaterialEditor)
            {
                Editor.DrawFoldoutInspector(terrain.materialTemplate, ref m_TemplateMaterialEditor);
#if UNITY_2021_2_OR_NEWER
                TerrainInspectorUtility.TerrainShaderValidationGUI(terrain.materialTemplate);
#endif
                EditorGUILayout.Space();
            }
#endif
            // Layers GUI
            m_ShowLayerInspector = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.layerControls, m_ShowLayerInspector);
            if (m_ShowLayerInspector)
            {
                LayersGUI(terrain, editContext);

#if UNITY_2019_2_OR_NEWER
                m_ShowLayerProperties = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.layerProperties, m_ShowLayerProperties);
                if (m_ShowLayerProperties)
                {
                    if (!m_LayerRepaintFlag)
                    {
                        TerrainLayerUtility.ShowTerrainLayerGUI(terrain, m_SelectedTerrainLayer, ref m_SelectedTerrainLayerInspector,
                                                                (m_TemplateMaterialEditor as MaterialEditor)?.customShaderGUI as ITerrainLayerCustomUI);
                    }
                    else
                    {
                        m_LayerRepaintFlag = false; // flag to skip layer property repaint when layer list modified
                    }
                }
#endif
            }

            if (EditorGUI.EndChangeCheck())
            {
                TerrainToolsAnalytics.OnParameterChange();
            }
        }