public static void Setup(GStylizedTerrain t) { if (t.TerrainData == null) { return; } t.TerrainData.Shading.ShadingSystem = GShadingSystem.MicroSplat; GMicroSplatIntegrationSettings settings = GMicroSplatIntegrationSettings.Instance; MicroSplatPolarisMesh pm = t.gameObject.GetComponent <MicroSplatPolarisMesh>(); if (pm != null) { GUtilities.DestroyObject(pm); } MeshRenderer[] renderers = t.GetOrCreateChunkRoot().GetComponentsInChildren <MeshRenderer>(); List <MeshRenderer> rendererList = new List <MeshRenderer>(); rendererList.AddRange(renderers); MicroSplatPolarisMeshEditor.PolarisData data = new MicroSplatPolarisMeshEditor.PolarisData(); data.basePath = settings.DataDirectory; data.name = settings.ShaderNamePrefix; data.additionalKeywords = new string[0]; data.rootObject = t.gameObject; data.renderers = rendererList; MicroSplatPolarisMeshEditor.Setup(data); pm = t.gameObject.GetComponent <MicroSplatPolarisMesh>(); t.TerrainData.Shading.CustomMaterial = pm.templateMaterial; string materialPath = AssetDatabase.GetAssetPath(pm.templateMaterial); string directory = Path.GetDirectoryName(materialPath); string configPath = string.Format("{0}/MicroSplatConfig.asset", directory); TextureArrayConfig config = AssetDatabase.LoadAssetAtPath <TextureArrayConfig>(configPath); t.TerrainData.Shading.MicroSplatTextureArrayConfig = config; currentTAConfig = config; }
private void DrawGeneralSettings() { string label = "General"; string id = "editor-settings-general"; GEditorCommon.Foldout(label, false, id, () => { instance.general.enableAnalytics = EditorGUILayout.Toggle("Allow Anonymous Editor Analytic", instance.general.enableAnalytics); instance.general.debugMode = EditorGUILayout.Toggle("Debug Mode", instance.general.debugMode); EditorGUI.BeginChangeCheck(); instance.general.showGeometryChunkInHierarchy = EditorGUILayout.Toggle("Show Geometry Chunks In Hierarchy", instance.general.showGeometryChunkInHierarchy); if (EditorGUI.EndChangeCheck()) { IEnumerator <GStylizedTerrain> terrains = GStylizedTerrain.ActiveTerrains.GetEnumerator(); while (terrains.MoveNext()) { GStylizedTerrain t = terrains.Current; Transform chunkRoot = t.GetOrCreateChunkRoot(); chunkRoot.gameObject.hideFlags = instance.general.showGeometryChunkInHierarchy ? HideFlags.None : HideFlags.HideInHierarchy; } GUtilities.MarkCurrentSceneDirty(); } }); }