internal void InitializeDefaults(Terrain terrain, int index)
        {
            this.m_Terrain        = terrain;
            this.m_PrototypeIndex = index;
            DetailPrototype detailPrototype = this.m_PrototypeIndex != -1 ? this.m_Terrain.terrainData.detailPrototypes[this.m_PrototypeIndex] : new DetailPrototype();

            this.m_Detail       = detailPrototype.prototype;
            this.m_NoiseSpread  = detailPrototype.noiseSpread;
            this.m_MinWidth     = detailPrototype.minWidth;
            this.m_MaxWidth     = detailPrototype.maxWidth;
            this.m_MinHeight    = detailPrototype.minHeight;
            this.m_MaxHeight    = detailPrototype.maxHeight;
            this.m_HealthyColor = detailPrototype.healthyColor;
            this.m_DryColor     = detailPrototype.dryColor;
            switch (detailPrototype.renderMode)
            {
            case DetailRenderMode.GrassBillboard:
                Debug.LogError((object)"Detail meshes can't be rendered as billboards");
                this.m_RenderMode = DetailMeshRenderMode.Grass;
                break;

            case DetailRenderMode.VertexLit:
                this.m_RenderMode = DetailMeshRenderMode.VertexLit;
                break;

            case DetailRenderMode.Grass:
                this.m_RenderMode = DetailMeshRenderMode.Grass;
                break;
            }
            this.OnWizardUpdate();
        }
 internal void InitializeDefaults(Terrain terrain, int index)
 {
   this.m_Terrain = terrain;
   this.m_PrototypeIndex = index;
   DetailPrototype detailPrototype = this.m_PrototypeIndex != -1 ? this.m_Terrain.terrainData.detailPrototypes[this.m_PrototypeIndex] : new DetailPrototype();
   this.m_Detail = detailPrototype.prototype;
   this.m_NoiseSpread = detailPrototype.noiseSpread;
   this.m_MinWidth = detailPrototype.minWidth;
   this.m_MaxWidth = detailPrototype.maxWidth;
   this.m_MinHeight = detailPrototype.minHeight;
   this.m_MaxHeight = detailPrototype.maxHeight;
   this.m_HealthyColor = detailPrototype.healthyColor;
   this.m_DryColor = detailPrototype.dryColor;
   switch (detailPrototype.renderMode)
   {
     case DetailRenderMode.GrassBillboard:
       Debug.LogError((object) "Detail meshes can't be rendered as billboards");
       this.m_RenderMode = DetailMeshRenderMode.Grass;
       break;
     case DetailRenderMode.VertexLit:
       this.m_RenderMode = DetailMeshRenderMode.VertexLit;
       break;
     case DetailRenderMode.Grass:
       this.m_RenderMode = DetailMeshRenderMode.Grass;
       break;
   }
   this.OnWizardUpdate();
 }
        internal void InitializeDefaults(Terrain terrain, int index)
        {
            m_Terrain = terrain;

            m_PrototypeIndex = index;
            DetailPrototype prototype;

            if (m_PrototypeIndex == -1)
            {
                prototype = new DetailPrototype()
                {
                    renderMode    = DetailRenderMode.VertexLit,
                    noiseSeed     = UnityEngine.Random.Range(1, int.MaxValue),
                    useInstancing = true
                };
            }
            else
            {
                prototype = m_Terrain.terrainData.detailPrototypes[m_PrototypeIndex];
            }

            m_DetailPrefab    = prototype.prototype;
            m_MinWidth        = prototype.minWidth;
            m_MaxWidth        = prototype.maxWidth;
            m_MinHeight       = prototype.minHeight;
            m_MaxHeight       = prototype.maxHeight;
            m_NoiseSeed       = prototype.noiseSeed;
            m_NoiseSpread     = prototype.noiseSpread;
            m_detailDensity   = prototype.density;
            m_HoleEdgePadding = Mathf.Clamp01(prototype.holeEdgePadding) * 100.0f;
            m_HealthyColor    = prototype.healthyColor;
            m_DryColor        = prototype.dryColor;
            switch (prototype.renderMode)
            {
            case DetailRenderMode.GrassBillboard:
                Debug.LogError("Detail meshes can't be rendered as billboards");
                m_RenderMode = DetailMeshRenderMode.Grass;
                break;

            case DetailRenderMode.Grass:
                m_RenderMode = DetailMeshRenderMode.Grass;
                break;

            case DetailRenderMode.VertexLit:
                m_RenderMode = DetailMeshRenderMode.VertexLit;
                break;
            }
            m_UseInstancing       = prototype.useInstancing;
            m_AlignToGround       = Mathf.Clamp01(prototype.alignToGround) * 100.0f;
            m_PositionOrderliness = Mathf.Clamp01(prototype.positionOrderliness) * 100.0f;

            OnWizardUpdate();
        }
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();

            m_DetailPrefab        = EditorGUILayout.ObjectField("Detail Prefab", m_DetailPrefab, typeof(GameObject), !TerrainDataIsPersistent) as GameObject;
            m_AlignToGround       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.alignToGround, m_AlignToGround, 0, 100);
            m_PositionOrderliness = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.positionOrderliness, m_PositionOrderliness, 0, 100);
            m_MinWidth            = EditorGUILayout.FloatField("Min Width", m_MinWidth);
            m_MaxWidth            = EditorGUILayout.FloatField("Max Width", m_MaxWidth);
            m_MinHeight           = EditorGUILayout.FloatField("Min Height", m_MinHeight);
            m_MaxHeight           = EditorGUILayout.FloatField("Max Height", m_MaxHeight);
            m_NoiseSeed           = EditorGUILayout.IntField(DetailWizardSharedStyles.Instance.noiseSeed, m_NoiseSeed);
            m_NoiseSpread         = EditorGUILayout.FloatField(DetailWizardSharedStyles.Instance.noiseSpread, m_NoiseSpread);
            m_HoleEdgePadding     = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.holeEdgePadding, m_HoleEdgePadding, 0, 100);

            GUI.enabled     = terrainData.detailScatterMode == DetailScatterMode.CoverageMode;
            m_detailDensity = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.detailDensity, m_detailDensity, 0, 3);
            GUI.enabled     = true;

            if (!m_UseInstancing)
            {
                m_HealthyColor = EditorGUILayout.ColorField("Healthy Color", m_HealthyColor);
                m_DryColor     = EditorGUILayout.ColorField("Dry Color", m_DryColor);
            }

            if (m_UseInstancing)
            {
                EditorGUI.BeginDisabled(true);
                EditorGUILayout.EnumPopup("Render Mode", DetailMeshRenderMode.VertexLit);
                EditorGUI.EndDisabled();
            }
            else
            {
                m_RenderMode = (DetailMeshRenderMode)EditorGUILayout.EnumPopup("Render Mode", m_RenderMode);
            }

            m_UseInstancing = EditorGUILayout.Toggle("Use GPU Instancing", m_UseInstancing);
            if (m_UseInstancing)
            {
                EditorGUILayout.HelpBox("Using GPU Instancing would enable using the Material you set on the prefab.", MessageType.Info);
            }

            if (!DetailPrototype.IsModeSupportedByRenderPipeline(ComputeRenderMode(), m_UseInstancing, out var message))
            {
                EditorGUILayout.LabelField(EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(MessageType.Error)), DetailWizardSharedStyles.Instance.helpBoxBig);
            }

            return(EditorGUI.EndChangeCheck());
        }
Esempio n. 5
0
        internal void InitializeDefaults(Terrain terrain, int index)
        {
            this.m_Terrain        = terrain;
            this.m_PrototypeIndex = index;
            DetailPrototype detailPrototype;

            if (this.m_PrototypeIndex == -1)
            {
                detailPrototype = new DetailPrototype();
            }
            else
            {
                detailPrototype = this.m_Terrain.terrainData.detailPrototypes[this.m_PrototypeIndex];
            }
            this.m_Detail       = detailPrototype.prototype;
            this.m_NoiseSpread  = detailPrototype.noiseSpread;
            this.m_MinWidth     = detailPrototype.minWidth;
            this.m_MaxWidth     = detailPrototype.maxWidth;
            this.m_MinHeight    = detailPrototype.minHeight;
            this.m_MaxHeight    = detailPrototype.maxHeight;
            this.m_HealthyColor = detailPrototype.healthyColor;
            this.m_DryColor     = detailPrototype.dryColor;
            DetailRenderMode renderMode = detailPrototype.renderMode;

            if (renderMode != DetailRenderMode.GrassBillboard)
            {
                if (renderMode != DetailRenderMode.Grass)
                {
                    if (renderMode == DetailRenderMode.VertexLit)
                    {
                        this.m_RenderMode = DetailMeshRenderMode.VertexLit;
                    }
                }
                else
                {
                    this.m_RenderMode = DetailMeshRenderMode.Grass;
                }
            }
            else
            {
                Debug.LogError("Detail meshes can't be rendered as billboards");
                this.m_RenderMode = DetailMeshRenderMode.Grass;
            }
            this.OnWizardUpdate();
        }
        internal void InitializeDefaults(Terrain terrain, int index)
        {
            m_Terrain = terrain;

            m_PrototypeIndex = index;
            DetailPrototype prototype;

            if (m_PrototypeIndex == -1)
            {
                prototype = new DetailPrototype();
            }
            else
            {
                prototype = m_Terrain.terrainData.detailPrototypes[m_PrototypeIndex];
            }

            m_Detail = prototype.prototype;

            m_NoiseSpread  = prototype.noiseSpread;
            m_MinWidth     = prototype.minWidth;
            m_MaxWidth     = prototype.maxWidth;
            m_MinHeight    = prototype.minHeight;
            m_MaxHeight    = prototype.maxHeight;
            m_HealthyColor = prototype.healthyColor;
            m_DryColor     = prototype.dryColor;
            switch (prototype.renderMode)
            {
            case DetailRenderMode.GrassBillboard:
                Debug.LogError("Detail meshes can't be rendered as billboards");
                m_RenderMode = DetailMeshRenderMode.Grass;
                break;

            case DetailRenderMode.Grass:
                m_RenderMode = DetailMeshRenderMode.Grass;
                break;

            case DetailRenderMode.VertexLit:
                m_RenderMode = DetailMeshRenderMode.VertexLit;
                break;
            }

            OnWizardUpdate();
        }