public void SaveEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); foreach (Condition condition in ConditionList) { Mods.Get.Editor.SaveMod <Condition>(condition, "Condition", condition.Name); } foreach (StatusKeeper keeper in StatusKeepers) { Mods.Get.Editor.SaveMod <StatusKeeper>(keeper, "StatusKeeper", keeper.Name); } foreach (DifficultySetting setting in DifficultySettings) { Mods.Get.Editor.SaveMod <DifficultySetting>(setting, "DifficultySetting", setting.Name); } }
public void LoadEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); DefaultSkillStartupSettings.Clear(); //load all skills from mods List <string> skillNames = Mods.Get.ModDataNames("Skill"); foreach (string skillName in skillNames) { Transform parentObject = gameObject.FindOrCreateChild("Skills"); SkillSaveState skillSaveState = null; if (Mods.Get.Editor.LoadMod <SkillSaveState>(ref skillSaveState, "Skill", skillName)) { GameObject newSkillObject = new GameObject(skillName); Skill newSkill = null; if (!string.IsNullOrEmpty(skillSaveState.ClassName)) { //if we use a custom script then add it now Component skillComponent = newSkillObject.AddComponent(Type.GetType("Frontiers.World.Gameplay." + skillSaveState.ClassName)); //UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(newSkillObject, "Assets/Scripts/Managers/Skills.cs (533,40)", skillSaveState.ClassName); newSkill = skillComponent as Skill; } else { //otherwise just use the normal skill newSkill = newSkillObject.AddComponent <Skill>(); } if (newSkill != null) { //load the state' newSkill.CheckExtensionProps(); newSkill.SaveState = skillSaveState; //add it to the list SkillList.Add(newSkill); //create the subgroup lookup and parent it underneath if (!string.IsNullOrEmpty(newSkill.Info.SkillGroup)) { parentObject = parentObject.gameObject.FindOrCreateChild(newSkill.Info.SkillGroup); if (!string.IsNullOrEmpty(newSkill.Info.SkillSubgroup)) { parentObject = parentObject.gameObject.FindOrCreateChild(newSkill.Info.SkillSubgroup); } } newSkill.transform.parent = parentObject.transform; } DefaultSkillStartupSettings.Add(new SkillStartupSetting(skillName, newSkill.State.KnowledgeState, newSkill.HasBeenMastered)); } } }
public void Apply() { if (!Manager.IsAwake <Frontiers.Mats> ()) { return; } Frontiers.Mats.Get.PushDefaultFont(DefaultFont); }
public void SaveBlueprint() { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); BlueprintName = Blueprint.Name; Mods.Get.Editor.SaveMod <WIBlueprint>(Blueprint, "Blueprint", BlueprintName); CreatingNewBlueprint = false; }
public void EditorSaveLightTemplates() { if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); foreach (WorldLightTemplate wlt in Templates) { Mods.Get.Editor.SaveMod <WorldLightTemplate> (wlt, "Light", wlt.Name); } }
public void RefreshPostFX() { if (Manager.IsAwake <CameraFX> ()) { PostFXBloom = CameraFX.Get.Default.BloomEffect.enabled; PostFXGodRays = CameraFX.Get.Default.SunShaftsEffect.enabled; PostFXSSAO = CameraFX.Get.Default.SSAO.enabled; PostFXGrain = CameraFX.Get.Default.Grain.enabled; //PostFXMBlur = CameraFX.Get.Default.MotionBlur.enabled; PostFXAA = CameraFX.Get.Default.AA.enabled; HDR = GameManager.Get.GameCamera.hdr; AdjustBrightness = CameraFX.Get.AdjustBrightness; } }
public void LoadBlueprintsEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); RefreshCategoriesEditor(); }
public override void WakeUp() { base.WakeUp(); Get = this; mPotionLookup = new Dictionary <string, Potion>(); mPotionLookup.Clear(); PotionList.Clear(); if (!Application.isPlaying) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); List <string> potionNames = Mods.Get.Available("Potion"); for (int i = 0; i < potionNames.Count; i++) { Potion potion = null; if (Application.isPlaying) { if (Mods.Get.Runtime.LoadMod <Potion>(ref potion, "Potion", potionNames[i])) { mPotionLookup.Add(potion.Name.ToLower().Trim().Replace(" ", ""), potion); PotionList.Add(potion); } } else { if (Mods.Get.Editor.LoadMod <Potion>(ref potion, "Potion", potionNames[i])) { mPotionLookup.Add(potion.Name.ToLower().Trim().Replace(" ", ""), potion); PotionList.Add(potion); } } } } gPotionGenericWorldItem = new GenericWorldItem(); gPotionGenericWorldItem.PackName = "MedicalSupplies"; gPotionGenericWorldItem.PrefabName = "Potion Bottle 1"; //gPotionGenericWorldItem.State = "Default"; gPotionGenericWorldItem.DisplayName = "Potion"; gPotionGenericWorldItem.Subcategory = "HealingPotion"; }
public void LoadEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); LoadConditions(); LoadStatusKeepers(); LoadDifficultySettings(); }
public void LoadBlueprint(bool force) { if (CreatingNewBlueprint && !force) { return; } if (Blueprint.Name != BlueprintName || force) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); Mods.Get.Editor.LoadMod <WIBlueprint>(ref Blueprint, "Blueprint", BlueprintName); } }
public void InitializeEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); if (mCategories == null) { RefreshCategoriesEditor(); } }
public void EditorLoadLightTemplates() { if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); Templates.Clear(); List <string> availableTemplates = Mods.Get.Editor.Available("Light"); foreach (string availableTemplate in availableTemplates) { WorldLightTemplate template = null; if (Mods.Get.Editor.LoadMod <WorldLightTemplate> (ref template, "Light", availableTemplate)) { Templates.Add(template); } } }
public void DrawEditor() { UnityEngine.GUI.color = Color.gray; if (GUILayout.Button("Fix prepared foods")) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); Mods.Get.Editor.LoadAvailableMods <PreparedFood>(PreparedFoodList, "PreparedFood"); foreach (PreparedFood pf in PreparedFoodList) { if (!string.IsNullOrEmpty(pf.BaseTextureName) && pf.BaseTextureName.Length > 1) { pf.BaseTextureName = pf.BaseTextureName.Substring(pf.BaseTextureName.Length - 1, 1); //only take the last character Mods.Get.Editor.SaveMod <PreparedFood>(pf, "PreparedFood", pf.Name); } } } }
public void DrawEditor() { UnityEngine.GUI.color = Color.cyan; if (GUILayout.Button("\nLoad Conditions from Disk\n")) { LoadEditor(); } if (GUILayout.Button("\nSave Conditions to Disk\n")) { SaveEditor(); } if (GUILayout.Button("\nCreate Conditions from Potions\n")) { bool foundCondition = false; if (!Manager.IsAwake <Potions>()) { Manager.WakeUp <Potions>("Frontiers_ObjectManagers"); } foreach (Potion potion in Potions.Get.PotionList) { if (!string.IsNullOrEmpty(potion.EdibleProps.ConditionName)) { foreach (Condition condition in ConditionList) { if (potion.EdibleProps.ConditionName == condition.Name) { foundCondition = true; break; } } if (!foundCondition) { Condition newCondition = new Condition(); newCondition.Name = potion.EdibleProps.ConditionName; ConditionList.Add(newCondition); } } } } }
public void SaveBlueprintsEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); foreach (WIBlueprint blueprint in mLoadedBlueprints.Values) { Mods.Get.Editor.SaveMod <WIBlueprint>(blueprint, "Blueprint", blueprint.Name); } foreach (WIBlueprint newBlueprint in mEditorBlueprints) { Mods.Get.Editor.SaveMod <WIBlueprint>(newBlueprint, "Blueprint", newBlueprint.Name); } }
public void DrawEditor() { if (GUILayout.Button("Save Potions")) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); foreach (Potion potion in PotionList) { Mods.Get.Editor.SaveMod <Potion>(potion, "Potion", potion.Name); } } if (GUILayout.Button("Load Potions")) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); PotionList.Clear(); mPotionLookup.Clear(); List <string> potionNames = Mods.Get.Available("Potion"); for (int i = 0; i < potionNames.Count; i++) { Potion potion = null; if (Mods.Get.Editor.LoadMod <Potion>(ref potion, "Potion", potionNames[i])) { mPotionLookup.Add(potion.Name.ToLower().Trim().Replace(" ", ""), potion); PotionList.Add(potion); } } } }
public void DrawEditor() { UnityEngine.GUI.color = Color.cyan; if (GUILayout.Button("\nSave Museum\n")) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); Mods.Get.Editor.SaveMod(ActiveMuseum, "Museum", ActiveMuseum.Name); } if (GUILayout.Button("\nRe-Load Museum\n")) { if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(true); Mods.Get.Editor.LoadMod(ref ActiveMuseum, "Museum", ActiveMuseum.Name); } }
public void SaveEditor() { if (Application.isPlaying) { return; } if (!Manager.IsAwake <Mods>()) { Manager.WakeUp <Mods>("__MODS"); } Mods.Get.Editor.InitializeEditor(); foreach (Skill skill in SkillList) { if (skill != null) { skill.CheckExtensionProps(); SkillSaveState skillSaveState = skill.SaveState; Mods.Get.Editor.SaveMod <SkillSaveState>(skillSaveState, "Skill", skillSaveState.Name); } } }
public void RebuildPacks() { if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); Mods.Get.Editor.InitializeEditor(); } if (!Manager.IsAwake <Structures> ()) { Manager.WakeUp <Structures> ("Frontiers_Structures"); } //Debug.Log ("Rebuilding structure manager packs from paths"); Structures.Get.StructurePacks.Clear(); foreach (StructurePackPaths packPaths in Structures.Get.PackPaths) { //Debug.Log ("Loading pack " + packPaths.PackPath); StructurePack structurePack = new StructurePack(); structurePack.Name = System.IO.Path.GetFileName(packPaths.PackPath); foreach (string staticPrefabPath in packPaths.StaticPrefabs) { string finalPath = ("Assets" + staticPrefabPath); //Debug.Log ("Adding statpre " + finalPath); UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(finalPath, typeof(UnityEngine.Object)) as UnityEngine.Object; GameObject prefabAsGameObject = prefab as GameObject; if (prefabAsGameObject != null) { structurePack.StaticPrefabs.Add(prefabAsGameObject); } } foreach (string dynamicPrefab in packPaths.DynamicPrefabs) { string finalPath = ("Assets" + dynamicPrefab); //Debug.Log ("Adding dynpre " + finalPath); UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(finalPath, typeof(UnityEngine.Object)) as UnityEngine.Object; if (prefab != null) { GameObject prefabGameObject = prefab as GameObject; DynamicPrefab dynPrefab = prefabGameObject.GetComponent <DynamicPrefab> (); if (dynPrefab != null && dynPrefab.worlditem != null) { dynPrefab.worlditem.OnEditorRefresh(); dynPrefab.worlditem.Props.Name.FileName = prefabGameObject.name; dynPrefab.worlditem.Props.Name.PrefabName = prefabGameObject.name; dynPrefab.worlditem.Props.Name.PackName = structurePack.Name; } structurePack.DynamicPrefabs.Add(prefabGameObject); } else { //Debug.Log ("PREFAB WAS NULL " + System.IO.Path.GetFileName (dynamicPrefab)); } } //Debug.Log ("Added structure pack FINISHED"); Structures.Get.StructurePacks.Add(structurePack); } ColliderMeshPrefabs.Clear(); foreach (string colliderMeshPrefabPath in ColliderMeshPaths) { string finalPath = ("Assets" + colliderMeshPrefabPath); //Debug.Log ("Adding statpre " + finalPath); UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(finalPath, typeof(UnityEngine.Object)) as UnityEngine.Object; GameObject prefabAsGameObject = prefab as GameObject; if (prefabAsGameObject != null) { ColliderMeshPrefabs.SafeAdd(prefabAsGameObject); } } LodMeshPrefabs.Clear(); foreach (string lodMeshPrefabPath in LODPrefabPaths) { string finalPath = ("Assets" + lodMeshPrefabPath); //Debug.Log ("Adding statpre " + finalPath); UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(finalPath, typeof(UnityEngine.Object)) as UnityEngine.Object; GameObject prefabAsGameObject = prefab as GameObject; if (prefabAsGameObject != null) { LodMeshPrefabs.SafeAdd(prefabAsGameObject); } } SharedMaterials.Clear(); foreach (string sharedMaterialPath in SharedMaterialPaths) { string finalPath = ("Assets" + sharedMaterialPath); //Debug.Log ("Adding statpre " + finalPath); UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(finalPath, typeof(UnityEngine.Object)) as UnityEngine.Object; Material prefabAsMaterial = prefab as Material; if (prefabAsMaterial != null) { SharedMaterials.SafeAdd(prefabAsMaterial); } } }
public IEnumerator PlayMusic(MusicType music, MusicVolume volume) { //TEMP //TODO UNITY 5 yield break; //TEMP while (!Manager.IsAwake <Mods> ()) { yield return(null); } CurrentMusic = music; CurrentVolume = volume; while (mUpdatingMusicFade) { yield return(null); } //see if we're still needed if (CurrentMusic != music) { //Debug.Log("AUDIOMANAGER: whoops, we got changed in the meantime, no longer trying to play " + music.ToString()); yield break; } //start updating! mUpdatingMusicFade = true; //figure out which clip we're using string fileName = PlayList.GetByType(music); //this is the audio source we're fading out FadingOutAudio = ActiveMusic; if (FadingOutAudio == Music2) { FadingInAudio = Music1; } else { FadingInAudio = Music2; } if (music == MusicType.MainMenu) { FadingInAudio.loop = false; } else { FadingInAudio.loop = true; } yield return(null); //load the new clip FadeInAudioTargetVolume = 1.0f; if (volume == MusicVolume.Quiet) { FadeInAudioTargetVolume = 0.5f; } //reset fade in audio FadingInAudio.volume = 0f; //if it has a clip destroy it to prevent memory leaks if (FadingInAudio.clip != null && FadingInAudio.clip.name != fileName) { FadingInAudio.Stop(); //Debug.Log("Destroying clip " + FadingInAudio.clip.name + " because it doesn't match " + fileName); GameObject.Destroy(FadingInAudio.clip); FadingInAudio.clip = null; } if (FadingInAudio.clip == null) { string fullPath = Mods.Get.Runtime.FullPath(fileName, "Music", Frontiers.Data.GameData.IO.gAudioExtension, DataType.World); if (!System.IO.File.Exists(fullPath)) { fullPath = Mods.Get.Runtime.FullPath(fileName, "Music", Frontiers.Data.GameData.IO.gAudioExtension, DataType.Base); } if (!System.IO.File.Exists(fullPath)) { Debug.Log("AUDIO MANAGER: Couldn't find music " + fullPath); mUpdatingMusicFade = false; yield break; } WWW loader = null; //Debug.Log(fullPath); loader = new WWW("file:///" + System.Uri.EscapeDataString(fullPath)); //Debug.Log("AUDIO MANAGER: loading " + fullPath); //TODO UNITY 5 try { FadingInAudio.clip = loader.GetAudioClip(false, true, AudioType.OGGVORBIS); } catch (Exception e) { Debug.Log("AUDIO MANAGER: ERROR when loading audio clip: " + e.ToString()); yield break; } if (!string.IsNullOrEmpty(loader.error)) { Debug.Log("AUDIO MANAGER: ERROR when loading audio clip: " + loader.error); loader.Dispose(); //GameObject.Destroy(loader); loader = null; mUpdatingMusicFade = false; yield break; } FadingInAudio.clip.name = fileName; //convenience while (!loader.isDone) { if (loader == null) { Debug.Log("AUDIO MANAGER: Loader was NULL in audio manager, quitting"); mUpdatingMusicFade = false; yield break; } double waitUntil = WorldClock.RealTime + 0.1f; while (WorldClock.RealTime < waitUntil) { yield return(null); } yield return(null); } //also kill the loader since we don't need it any more if (loader != null) { loader.Dispose(); //GameObject.Destroy(loader); loader = null; } } if (!FadingInAudio.isPlaying) { Debug.Log("AUDIO MANAGER: Playing audio clip " + FadingInAudio.clip.name); FadingInAudio.Play(); } bool doneFadingIn = false; bool doneFadingOut = false; float fadeInTargetAudioVolume = FadeInAudioTargetVolume; while (!(doneFadingIn && doneFadingOut)) { //fade in new audio over time if (!GameManager.Is(FGameState.GameLoading)) { float musicCrossFadeSpeed = Globals.MusicCrossfadeSpeed; if (CurrentMusic != music) { //whoops, we're waiting on something to load, make it fade faster musicCrossFadeSpeed *= 5; } FadingInAudio.volume = Mathf.Clamp01(Mathf.Lerp(FadingInAudio.volume, fadeInTargetAudioVolume, (float)(WorldClock.RTDeltaTimeSmooth * musicCrossFadeSpeed))); doneFadingIn = Mathf.Abs(FadingInAudio.volume - fadeInTargetAudioVolume) < 0.01f; //fade out existing audio over time if (FadingOutAudio != null) { FadingOutAudio.volume = Mathf.Clamp01(Mathf.Lerp(FadingOutAudio.volume, 0f, (float)(WorldClock.RTDeltaTimeSmooth * musicCrossFadeSpeed))); doneFadingOut = (FadingOutAudio.volume < 0.01f); } else { doneFadingOut = true; } } yield return(null); } //before we leave set everything one last time //and destroy the fading out clip FadingInAudio.volume = FadeInAudioTargetVolume; if (FadingOutAudio != null) { FadingOutAudio.volume = 0f; } FadingOutAudio = null; mUpdatingMusicFade = false; yield break; }
public void Apply() { try { if (!Application.isEditor) { if (mSupportedResolutions.Count == 0) { RefreshSupportedResolutions(); } } bool applyShadows = Manager.IsAwake <Biomes> (); switch (Shadows) { case 0: QualitySettings.SetQualityLevel(0); QualitySettings.pixelLightCount = 0; QualitySettings.shadowDistance = 8f; QualitySettings.shadowCascades = 0; if (applyShadows) { DefaultShadowSetting = LightShadows.None; } break; case 1: QualitySettings.SetQualityLevel(1); QualitySettings.pixelLightCount = 0; QualitySettings.shadowDistance = 32f; QualitySettings.shadowCascades = 1; if (applyShadows) { DefaultShadowSetting = LightShadows.Hard; } break; case 2: QualitySettings.SetQualityLevel(2); QualitySettings.pixelLightCount = 0; QualitySettings.shadowDistance = 64f; QualitySettings.shadowCascades = 1; if (applyShadows) { DefaultShadowSetting = LightShadows.Soft; } break; case 3: QualitySettings.SetQualityLevel(3); QualitySettings.pixelLightCount = 0; QualitySettings.shadowDistance = 128f; QualitySettings.shadowCascades = 2; if (applyShadows) { DefaultShadowSetting = LightShadows.Soft; } break; case 4: QualitySettings.SetQualityLevel(4); QualitySettings.pixelLightCount = 0; QualitySettings.shadowDistance = 256f; QualitySettings.shadowCascades = 4; if (applyShadows) { DefaultShadowSetting = LightShadows.Soft; } break; case 5: QualitySettings.SetQualityLevel(5); QualitySettings.pixelLightCount = 0; QualitySettings.shadowDistance = 512f; QualitySettings.shadowCascades = 4; if (applyShadows) { DefaultShadowSetting = LightShadows.Soft; } break; default: break; } Biomes.Get.SunLight.shadows = DefaultShadowSetting; if (!Application.isEditor) { if (!OculusMode && !VRManager.VRMode) { Debug.Log("Not oculus or vr mode, applying screen resolution / full screen"); if (!IsCurrentResolutionSupported) { RefreshSupportedResolutions(); FindDefaultResolution(); } if (Screen.currentResolution.width != ResolutionWidth || Screen.currentResolution.height != ResolutionHeight || Screen.fullScreen != Fullscreen) { Screen.SetResolution(ResolutionWidth, ResolutionHeight, Fullscreen); } } } if (Manager.IsAwake <Player> ()) { GameManager.Get.GameCamera.hdr = true; //HDR; GameManager.Get.GameCamera.fieldOfView = FieldOfView; CameraFX.Get.AdjustBrightness = AdjustBrightness; if (OculusMode && VRDisableScreenEffects) { SetOrDisablePostEffect(CameraFX.Get.Default.BloomEffect, false, ref PostFXBloom); CameraFX.Get.Default.SunShaftsEffect.enabled = false; CameraFX.Get.Default.SSAO.enabled = false; CameraFX.Get.Default.Grain.enabled = false; SetOrDisablePostEffect(CameraFX.Get.Default.AA, true, ref PostFXAA); if (Application.platform == RuntimePlatform.LinuxPlayer | Application.platform == RuntimePlatform.OSXPlayer) { bool fogOff = false; SetOrDisablePostEffect(CameraFX.Get.Default.Fog, true, ref fogOff); } else { SetOrDisablePostEffect(CameraFX.Get.Default.Fog, true, ref PostFXGlobalFog); } CameraFX.Get.Default.ColorGrading.enabled = true; } else { SetOrDisablePostEffect(CameraFX.Get.Default.BloomEffect, false, ref PostFXBloom); SetOrDisablePostEffect(CameraFX.Get.Default.SunShaftsEffect, false, ref PostFXGodRays); SetOrDisablePostEffect(CameraFX.Get.Default.SSAO, true, ref PostFXSSAO); SetOrDisablePostEffect(CameraFX.Get.Default.Grain, true, ref PostFXGrain); SetOrDisablePostEffect(CameraFX.Get.Default.AA, true, ref PostFXAA); if (Application.platform == RuntimePlatform.LinuxPlayer | Application.platform == RuntimePlatform.OSXPlayer) { bool fogOff = false; SetOrDisablePostEffect(CameraFX.Get.Default.Fog, true, ref fogOff); } else { SetOrDisablePostEffect(CameraFX.Get.Default.Fog, true, ref PostFXGlobalFog); } } } QualitySettings.masterTextureLimit = TextureResolution; QualitySettings.lodBias = ((float)LodDistance + 0.75f); if (Manager.IsAwake <GameWorld> ()) { GameWorld.Get.RefreshTerrainDetailSettings(); } if (Manager.IsAwake <WorldItems> ()) { WorldItems.Get.RefreshWorlditemShadowSettings(ObjectShadows); } if (Manager.IsAwake <Characters> ()) { Characters.Get.RefreshCharacterShadowSettings(ObjectShadows); } if (Manager.IsAwake <Creatures> ()) { Creatures.Get.RefreshCreatureShadowSettings(ObjectShadows); } if (Manager.IsAwake <Structures> ()) { Structures.Get.RefreshStructureShadowSettings(StructureShadows, TerrainShadows); } if (!OculusMode && !VRManager.VRMode) { if (VSync) { QualitySettings.vSyncCount = 1; } else { QualitySettings.vSyncCount = 0; } } } catch (Exception e) { Debug.LogException(e); } }
public void DrawEditor() { UnityEngine.GUI.color = Color.cyan; if (GUILayout.Button("\nLoad Paths\n")) { foreach (PathEditor pathEditor in PathEditors) { GameObject.DestroyImmediate(pathEditor.gameObject); } PathEditors.Clear(); LoadedPaths.Clear(); ChunkTransforms.Clear(); if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); } Mods.Get.Editor.InitializeEditor(true); ChunkParentTransform = gameObject.FindOrCreateChild("Chunks"); PathParentTransform = gameObject.FindOrCreateChild("Paths"); List <string> chunkNames = Mods.Get.ModDataNames("Chunk"); foreach (string chunkName in chunkNames) { ChunkState chunkState = null; if (Mods.Get.Runtime.LoadMod <ChunkState> (ref chunkState, "Chunk", chunkName)) { GameObject newChunkGameObject = ChunkParentTransform.gameObject.FindOrCreateChild(chunkState.ID.ToString()).gameObject; //look up the chunk terrain data and apply the offset Vector3 chunkPosition = chunkState.TileOffset; //chunkPosition.y = chunkState.YOffset; newChunkGameObject.transform.position = chunkPosition; //we'll use the ID for looking up path chunks later ChunkTransforms.Add(newChunkGameObject.transform); //now look for any terrain GameObject terrainObject = GameObject.Find(chunkState.XTilePosition.ToString() + " " + chunkState.ZTilePosition.ToString()); if (terrainObject != null) { terrainObject.transform.parent = newChunkGameObject.transform; terrainObject.transform.ResetLocal(); Terrain terrain = terrainObject.GetComponent <Terrain> (); terrain.heightmapPixelError = 50; } } } Mods.Get.Editor.LoadAvailableMods <Path> (LoadedPaths, "Path"); foreach (Path path in LoadedPaths) { GameObject pathEditorGameObject = PathParentTransform.gameObject.FindOrCreateChild(path.Name).gameObject; PathEditor pathEditor = pathEditorGameObject.GetOrAdd <PathEditor> (); pathEditor.DoNotRefreshOrSave = false; pathEditor.Name = path.Name; pathEditor.State = path; pathEditor.EditorRefresh(); pathEditor.BuildSpline(); } MergeOverlappingTemplates(); } if (GUILayout.Button("\nSnap Nearby Templates\n")) { SnapNearbyTemplates(); MergeOverlappingTemplates(); } if (GUILayout.Button("\nMinimum Height\n")) { AdjustMinimumHeight(); } if (GUILayout.Button("\nRefreshAll\n")) { foreach (PathEditor pe in PathEditors) { Debug.Log(pe.Name); pe.EditorRefresh(); } } if (GUILayout.Button("\nSave Paths\n")) { PathEditors.Clear(); PathEditors.AddRange(PathParentTransform.GetComponentsInChildren <PathEditor> ()); foreach (PathEditor editor in PathEditors) { editor.EditorSave(); } } }
public void RefreshPaths() { if (!Manager.IsAwake <Mods> ()) { Manager.WakeUp <Mods> ("__MODS"); Mods.Get.Editor.InitializeEditor(); } if (!Manager.IsAwake <Structures> ()) { Manager.WakeUp <Structures> ("Frontiers_Structures"); } string structurePacksPath = Structures.Get.LocalStructurePacksPath; structurePacksPath = System.IO.Path.Combine(Application.dataPath, structurePacksPath); if (Directory.Exists(structurePacksPath)) { //Debug.Log ("Found path " + structurePacksPath); } else { //Debug.Log ("Path " + structurePacksPath + " does not exist"); return; } string[] pathNames = Directory.GetDirectories(structurePacksPath); Structures.Get.PackPaths.Clear(); foreach (string packPath in pathNames) { //Debug.Log ("Checking structure pack " + packPath); string[] subDirectoryNames = Directory.GetDirectories(packPath); if (subDirectoryNames.Length == 0) { //Debug.Log ("No subfolders in structure pack - skipping"); } else { StructurePackPaths packPaths = new StructurePackPaths(); packPaths.PackPath = packPath.Replace(Application.dataPath, string.Empty); packPaths.Name = System.IO.Path.GetFileName(packPaths.PackPath); int numAssets = 0; foreach (string subDirectory in subDirectoryNames) { //Debug.Log ("Checking sub directory " + subDirectory); string currentFolderName = System.IO.Path.GetFileName(subDirectory); string[] assetPaths = Directory.GetFiles(subDirectory); List <string> ListToAddTo = null; switch (currentFolderName) { case "StaticPrefabs": ListToAddTo = packPaths.StaticPrefabs; foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); //Debug.Log ("Extension: " + extension); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".prefab", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); if (!ListToAddTo.Contains(prefabAssetPath)) { ListToAddTo.Add(prefabAssetPath); } numAssets++; } } break; case "DynamicPrefabs": ListToAddTo = packPaths.DynamicPrefabs; foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".prefab", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); if (!ListToAddTo.Contains(prefabAssetPath)) { ListToAddTo.Add(prefabAssetPath); } numAssets++; } } break; case "Meshes": ListToAddTo = packPaths.Meshes; foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".FBX", string.Empty); // prefabAssetPath = prefabAssetPath.Replace (".fbx", string.Empty); // prefabAssetPath = prefabAssetPath.Replace (".lxo", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); if (!ListToAddTo.Contains(prefabAssetPath)) { ListToAddTo.Add(prefabAssetPath); } numAssets++; } } break; case "Textures": ListToAddTo = packPaths.Textures; foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".PSD", string.Empty); // prefabAssetPath = prefabAssetPath.Replace (".psd", string.Empty); // prefabAssetPath = prefabAssetPath.Replace (".jpg", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); if (!ListToAddTo.Contains(prefabAssetPath)) { ListToAddTo.Add(prefabAssetPath); } numAssets++; } } break; case "Materials": ListToAddTo = packPaths.Materials; foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".material", string.Empty); // prefabAssetPath = prefabAssetPath.Replace (".mat", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); if (!ListToAddTo.Contains(prefabAssetPath)) { ListToAddTo.Add(prefabAssetPath); } numAssets++; } } break; default: //Debug.Log ("Folder name " + currentFolderName + " not recognized"); break; } } //Debug.Log ("Num assets in pack: " + numAssets); Structures.Get.PackPaths.Add(packPaths); } } //get mesh collider paths ColliderMeshPaths.Clear(); string colliderMeshesPath = LocalColliderMeshesPath; colliderMeshesPath = System.IO.Path.Combine(Application.dataPath, colliderMeshesPath); if (Directory.Exists(structurePacksPath)) { string[] assetPaths = Directory.GetFiles(colliderMeshesPath); foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); //Debug.Log ("Extension: " + extension); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".prefab", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); ColliderMeshPaths.SafeAdd(prefabAssetPath); } } } else { Debug.Log("Path " + colliderMeshesPath + " does not exist"); } LODMeshPaths.Clear(); string lodMeshesPath = LocalLODMeshesPath; lodMeshesPath = System.IO.Path.Combine(Application.dataPath, lodMeshesPath); if (Directory.Exists(lodMeshesPath)) { string[] assetPaths = Directory.GetFiles(lodMeshesPath); foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); //Debug.Log ("Extension: " + extension); if (extension != ".meta" && extension != string.Empty) { //string prefabAssetPath = assetPath.Replace (".prefab", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); LODMeshPaths.SafeAdd(prefabAssetPath); } } } else { Debug.Log("Path " + lodMeshesPath + " does not exist"); } //get LOD prefab paths LODPrefabPaths.Clear(); string lodPrefabsPath = LocalLODPrefabsPath; lodPrefabsPath = System.IO.Path.Combine(Application.dataPath, lodPrefabsPath); if (Directory.Exists(lodPrefabsPath)) { string[] assetPaths = Directory.GetFiles(lodPrefabsPath); foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); //Debug.Log ("Extension: " + extension); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".prefab", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); LODPrefabPaths.SafeAdd(prefabAssetPath); } } } else { Debug.Log("Path " + lodPrefabsPath + " does not exist"); } //get shared material paths SharedMaterialPaths.Clear(); string sharedMaterialsPath = LocalSharedMaterialsPath; sharedMaterialsPath = System.IO.Path.Combine(Application.dataPath, sharedMaterialsPath); if (Directory.Exists(sharedMaterialsPath)) { string[] subDirectoryNames = Directory.GetDirectories(sharedMaterialsPath); foreach (string subDirectory in subDirectoryNames) { string[] assetPaths = Directory.GetFiles(subDirectory); foreach (string assetPath in assetPaths) { string extension = System.IO.Path.GetExtension(assetPath); //Debug.Log ("Extension: " + extension); if (extension != ".meta" && extension != string.Empty) { // string prefabAssetPath = assetPath.Replace (".prefab", string.Empty); string prefabAssetPath = assetPath.Replace(Application.dataPath, string.Empty); SharedMaterialPaths.SafeAdd(prefabAssetPath); } } } } else { Debug.Log("Path " + sharedMaterialsPath + " does not exist"); } }