public override void OnInspectorGUI() { serializedObject.Update(); // TODO: Fix that it will look good. //if (p_radiusMode.boolValue) //{ // p_useLocalRotation.boolValue = EditorGUILayout.Toggle("UseLocalRotation", p_useLocalRotation.boolValue); //} //else //{ // p_dynamicLoadingRadius.intValue = EditorGUILayout.IntField(p_dynamicLoadingRadius.intValue); //} if (availableTerrains == null) { availableTerrains = new Dictionary <string, DynamicTerrainBundles>(); DynamicTerrainBundles TerrainName_Bundles = new DynamicTerrainBundles(); TerrainName_Bundles.TerrainBundlePath = @"C:\DB\Unity\ImpovedAndDynamic\TerrainName\Improved_TerrainName\terrainwithmodels"; TerrainName_Bundles.OriginalsBundlePath = @"C:\DB\Unity\ImpovedAndDynamic\TerrainName\Improved_TerrainName\terrainoriginalsnew"; TerrainName_Bundles.ImrovedTerrainBundlePath = @"C:\DB\Unity\ImpovedAndDynamic\TerrainName\Improved_TerrainName\improved_TerrainName"; TerrainName_Bundles.MapOffsetX = -3770; TerrainName_Bundles.MapOffsetZ = -6; availableTerrains["TerrainName"] = TerrainName_Bundles; } TerrainLoader_Dynamic targetTerrainLoader = (TerrainLoader_Dynamic)target; DrawDefaultInspector(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Available Terrains:"); foreach (var terrain in availableTerrains) { if (GUILayout.Button(terrain.Key)) { serializedObject.FindProperty("TerrainBundlePath").stringValue = terrain.Value.TerrainBundlePath; serializedObject.FindProperty("TerrainOriginalsBundlePath").stringValue = terrain.Value.OriginalsBundlePath; serializedObject.FindProperty("ImprovedTerrainBundlePath").stringValue = terrain.Value.ImrovedTerrainBundlePath; serializedObject.FindProperty("MapOffsetX").floatValue = terrain.Value.MapOffsetX; serializedObject.FindProperty("MapOffsetZ").floatValue = terrain.Value.MapOffsetZ; serializedObject.ApplyModifiedProperties(); } } }
/// <summary> /// Looks for the relevant references when adding this script to the scene/using the Reset option /// </summary> void Reset() { // TerrainLoader = FindObjectOfType<TerrainLoader>(); ExerciseConnection = FindObjectOfType<ExerciseConnection>(); NightLoader = FindObjectOfType<NightLoader>(); TerrainLoaderFull = FindObjectOfType<TerrainLoader_Full>(); TerrainLoaderDynamic = FindObjectOfType<TerrainLoader_Dynamic>(); SetEditorConfig(true, new Configuration() { ExerciseId = ExerciseConnection ? ExerciseConnection.exerciseId : 0, FullTerrain = true, ImprovedTerrain = TerrainLoaderFull.ImprovedTerrain, ImprovedTerrainBundlePath = TerrainLoaderFull.ImprovedTerrainBundlePath, LoadingRadius = TerrainLoaderDynamic.DynamicLoadingRadius, NightMode = NightLoader.Mode.DayOnly, OriginalsBundlePath = TerrainLoaderDynamic.TerrainOriginalsBundlePath, TerrainPath = TerrainLoaderFull.TerrainBundlePath }); }
override protected void ApplyConfiguration(bool GotConfiguration) { //Try finding references if (!ExerciseConnection) ExerciseConnection = FindObjectOfType<ExerciseConnection>(); if (!NightLoader) NightLoader = FindObjectOfType<NightLoader>(); if (!TerrainLoaderFull) TerrainLoaderFull = FindObjectOfType<TerrainLoader_Full>(); if (!TerrainLoaderDynamic) TerrainLoaderDynamic = FindObjectOfType<TerrainLoader_Dynamic>(); //Load command line arguments as overrides PutArg("FullTerrain", ref Config.FullTerrain, "FullTerrain"); PutArg("LoadingRadius", ref Config.LoadingRadius, "LoadingRadius"); PutArg("ImprovedTerrain", ref Config.ImprovedTerrain, "ImprovedTerrain"); PutArg("TerrainPath", ref Config.TerrainPath, "TerrainPath"); PutArg("NavMeshBundlePath", ref Config.TerrainPath, "NavMeshBundlePath"); PutArg("ImprovedTerrainBundlePath", ref Config.ImprovedTerrainBundlePath, "ImprovedTerrainBundlePath"); PutArg("ExerciseId", ref Config.ExerciseId, "ExerciseId"); PutArg("NightMode", ref Config.NightMode, EnumParser<NightLoader.Mode>(), "NightMode"); //forces improved terrain on TerrainName if (GotConfiguration && null != Config.TerrainPath) { string lowerTerrainPath = Config.TerrainPath.ToLower(); if (lowerTerrainPath.Contains("terrainname")) Config.ImprovedTerrain = true; } //Apply ExerciseId if (ExerciseConnection) TryApplyTo(Config.ExerciseId, ref ExerciseConnection.exerciseId, "ExerciseId"); //Override if in editor if (Application.isEditor) Config.FullTerrain = FullTerrain; //Apply terrain values, destroy the loader that wasn't picked if (Config.FullTerrain) { Destroy(TerrainLoaderDynamic); TerrainLoader.Instance = TerrainLoaderFull; TryApplyTo(Config.ImprovedTerrain, ref TerrainLoaderFull.ImprovedTerrain, "ImprovedTerrain"); } else { Destroy(TerrainLoaderFull); TerrainLoader.Instance = TerrainLoaderDynamic; TryApplyTo(Config.LoadingRadius, ref TerrainLoaderDynamic.DynamicLoadingRadius, "LoadingRadius"); TryApplyTo(Config.ImprovedTerrain, ref TerrainLoaderDynamic.ImprovedTerrain, "ImprovedTerrain"); } //apply NightMode, add "_night" to terrain path if (NightLoader && WasConfigured("NightMode")) { /*switch (Config.NightMode) { case "DayOnly": { NightLoader.NightLoadingMode = NightLoader.Mode.DayOnly; break; } case "NightOnly": { if (!Config.TerrainPath.EndsWith("_night")) Config.TerrainPath += "_night"; NightLoader.NightLoadingMode = NightLoader.Mode.NightOnly; break; } case "Dual": { NightLoader.NightLoadingMode = NightLoader.Mode.Dual; break; } }*/ NightLoader.NightLoadingMode = Config.NightMode; } //Apply paths if (TerrainLoader.Instance) { TryApplyTo(Config.TerrainPath, ref TerrainLoader.Instance.TerrainBundlePath, "TerrainPath"); TryApplyTo(Config.NavMeshBundlePath, ref TerrainLoader.Instance.NavMeshBundlePath, "NavMeshBundlePath"); TryApplyTo(Config.ImprovedTerrainBundlePath, ref TerrainLoader.Instance.ImprovedTerrainBundlePath, "ImprovedTerrainBundlePath"); if (!Config.FullTerrain) { PutArg("OriginalsBundlePath", ref Config.OriginalsBundlePath, "OriginalsBundlePath"); TryApplyTo(Config.OriginalsBundlePath, ref TerrainLoaderDynamic.TerrainOriginalsBundlePath, "OriginalsBundlePath"); } } }