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 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 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() { 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 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 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 void DrawEditor() { if (WorldItems.Get == null) { Manager.WakeUp <WorldItems>("Frontiers_WorldItems"); WorldItems.Get.Initialize(); } GUILayout.Label("Blueprint categories:"); if (openWindow) { SelectWorldItem(); } UnityEngine.GUI.color = Color.cyan; if (!string.IsNullOrEmpty(selectedCategory)) { GUILayout.Label("Selected category: " + selectedCategory); List <WIBlueprint> blueprintList = BlueprintsByCategory(selectedCategory); foreach (WIBlueprint blueprint in blueprintList) { // GUILayout.BeginHorizontal ( ); UnityEngine.GUI.color = Color.yellow; if (blueprint == selectedBlueprint) { UnityEngine.GUI.color = Color.cyan; GUILayout.Label("Selected blueprint:"); GUILayout.BeginHorizontal(); if (blueprint.GenericResult != null && !string.IsNullOrEmpty(blueprint.GenericResult.PrefabName)) { if (GUILayout.Button(blueprint.GenericResult.PrefabName)) { rowSelection = null; rowIndex = 100; openWindow = true; } } else { if (GUILayout.Button("(Choose result)")) { rowSelection = null; rowIndex = 100; openWindow = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); blueprint.Name = GUILayout.TextField(blueprint.Name); if (string.IsNullOrEmpty(blueprint.Name)) { if (!blueprint.GenericResult.IsEmpty) { blueprint.Name = blueprint.GenericResult.PrefabName; } } GUILayout.Label("Required Skill:"); blueprint.RequiredSkill = GUILayout.TextField(blueprint.RequiredSkill); GUILayout.Label("Title:"); blueprint.Title = GUILayout.TextField(blueprint.Title); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); blueprint.Revealed = GUILayout.Toggle(blueprint.Revealed, "Revealed"); blueprint.UseGenericResult = GUILayout.Toggle(blueprint.UseGenericResult, "Generic Result"); blueprint.BaseCraftTime = UnityEditor.EditorGUILayout.FloatField(blueprint.BaseCraftTime); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Row 1:"); for (int i = 0; i < selectedBlueprint.Row1.Count; i++) { if (i == rowIndex && selectedBlueprint.Row1 == rowSelection) { UnityEngine.GUI.color = Color.yellow; } else { UnityEngine.GUI.color = Color.white; } if (selectedBlueprint.Row1[i] == null || selectedBlueprint.Row1[i].StackName == string.Empty) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n -(Empty)= \n\n")) { rowSelection = selectedBlueprint.Row1; rowIndex = i; openWindow = true; } } else { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n" + selectedBlueprint.Row1[i].StackName + "\n\n")) { rowSelection = selectedBlueprint.Row1; rowIndex = i; openWindow = true; } } } GUILayout.EndHorizontal(); UnityEngine.GUI.color = Color.cyan; GUILayout.BeginHorizontal(); GUILayout.Label("Row 2:"); for (int i = 0; i < selectedBlueprint.Row2.Count; i++) { if (i == rowIndex && selectedBlueprint.Row2 == rowSelection) { UnityEngine.GUI.color = Color.yellow; } else { UnityEngine.GUI.color = Color.white; } if (selectedBlueprint.Row2[i] == null || selectedBlueprint.Row2[i].StackName == string.Empty) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n -(Empty)= \n\n")) { rowSelection = selectedBlueprint.Row2; rowIndex = i; openWindow = true; } } else { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.white, 0.5f); if (GUILayout.Button("\n\n" + selectedBlueprint.Row2[i].StackName + "\n\n")) { rowSelection = selectedBlueprint.Row2; rowIndex = i; openWindow = true; } } } GUILayout.EndHorizontal(); UnityEngine.GUI.color = Color.cyan; GUILayout.BeginHorizontal(); GUILayout.Label("Row 3:"); for (int i = 0; i < selectedBlueprint.Row3.Count; i++) { if (i == rowIndex && selectedBlueprint.Row3 == rowSelection) { UnityEngine.GUI.color = Color.yellow; } else { UnityEngine.GUI.color = Color.white; } if (selectedBlueprint.Row3[i] == null || selectedBlueprint.Row3[i].StackName == string.Empty) { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.gray, 0.5f); if (GUILayout.Button("\n\n -(Empty)= \n\n")) { rowSelection = selectedBlueprint.Row3; rowIndex = i; openWindow = true; } } else { UnityEngine.GUI.color = Color.Lerp(UnityEngine.GUI.color, Color.white, 0.5f); if (GUILayout.Button("\n\n" + selectedBlueprint.Row3[i].StackName + "\n\n")) { rowSelection = selectedBlueprint.Row3; rowIndex = i; openWindow = true; } } } GUILayout.EndHorizontal(); } else { if (blueprint.GenericResult != null) { if (GUILayout.Button(blueprint.GenericResult.StackName)) { selectedBlueprint = blueprint; } } else { if (GUILayout.Button(" (empty blueprint) ")) { selectedBlueprint = blueprint; } } } } UnityEngine.GUI.color = Color.cyan; GUILayout.BeginHorizontal(); GUILayout.Label(" "); if (GUILayout.Button("Create blueprint")) { EditorCreateBlueprint("New blueprint", selectedCategory); } GUILayout.Label(" "); GUILayout.EndHorizontal(); if (GUILayout.Button("\nTOP\n")) { selectedCategory = null; } } else { UnityEngine.GUI.color = Color.cyan; if (GUILayout.Button("\nTOP\n")) { selectedCategory = null; } else { UnityEngine.GUI.color = Color.cyan; foreach (string category in Categories) { if (GUILayout.Button(category)) { selectedCategory = category; return; } } } } UnityEngine.GUI.color = Color.yellow; if (GUILayout.Button("\n SAVE TO DISK \n")) { SaveBlueprintsEditor(); } if (GUILayout.Button("\n LOAD FROM DISK \n")) { LoadBlueprintsEditor(); } }
public void DrawGenericWorldItemSelector(GenericWorldItem item, ref bool open, bool useStrictness) { if (WorldItems.Get == null) { Manager.WakeUp <WorldItems>("Frontiers_WorldItems"); WorldItems.Get.Initialize(); } bool drawEditor = true; UnityEditor.EditorStyles.miniButton.stretchWidth = true; UnityEditor.EditorStyles.textField.stretchWidth = true; UnityEditor.EditorStyles.popup.stretchWidth = true; GUILayout.BeginVertical(); if (string.IsNullOrEmpty(item.PackName)) { drawEditor = false; UnityEngine.GUI.color = Color.green; if (GUILayout.Button("(Add)", UnityEditor.EditorStyles.miniButton)) { item.PackName = "AncientArtifacts"; item.PrefabName = string.Empty; drawEditor = true; } UnityEngine.GUI.color = Color.yellow; if (GUILayout.Button("(Done)", UnityEditor.EditorStyles.miniButton)) { drawEditor = false; selectedItemIndex = -1; selectedRowIndex = -1; } } else { UnityEngine.GUI.color = Color.red; if (GUILayout.Button("(Clear)", UnityEditor.EditorStyles.miniButton)) { item.Clear(); drawEditor = false; } } if (drawEditor) { UnityEngine.GUI.color = Color.yellow; int packIndex = 0; List <string> packNames = new List <string>(); WorldItemPack pack = null; WorldItem worlditem = null; for (int i = 0; i < WorldItems.Get.WorldItemPacks.Count; i++) { string packName = WorldItems.Get.WorldItemPacks[i].Name; packNames.Add(packName); if (item.PackName == packName) { packIndex = i; pack = WorldItems.Get.WorldItemPacks[i]; } } if (pack == null) { pack = WorldItems.Get.WorldItemPacks[0]; } packIndex = UnityEditor.EditorGUILayout.Popup("Pack:", packIndex, packNames.ToArray(), UnityEditor.EditorStyles.popup); List <string> prefabNames = new List <string>(); int prefabIndex = 0; for (int i = 0; i < pack.Prefabs.Count; i++) { prefabNames.Add(pack.Prefabs[i].name); if (item.PrefabName == pack.Prefabs[i].name) { prefabIndex = i; worlditem = pack.Prefabs[i].GetComponent <WorldItem>(); } } prefabIndex = UnityEditor.EditorGUILayout.Popup("Prefab:", prefabIndex, prefabNames.ToArray(), UnityEditor.EditorStyles.popup); item.PackName = packNames[packIndex]; item.PrefabName = prefabNames[prefabIndex]; if (worlditem != null) { UnityEngine.GUI.color = Color.yellow; item.DisplayName = worlditem.DisplayName; if (!useStrictness || Flags.Check((uint)Blueprint.Strictness, (uint)BlueprintStrictness.StackName, Flags.CheckType.MatchAny)) { GUILayout.BeginHorizontal(); GUILayout.Label("StackName: "); if (string.IsNullOrEmpty(item.StackName) || !worlditem.StackName.Contains(item.StackName)) { item.StackName = worlditem.StackName; } item.StackName = GUILayout.TextField(item.StackName); GUILayout.EndHorizontal(); } if (!useStrictness || Flags.Check((uint)Blueprint.Strictness, (uint)BlueprintStrictness.StateName, Flags.CheckType.MatchAny)) { GUILayout.BeginHorizontal(); int stateIndex = 0; List <string> stateNames = new List <string>(); stateNames.Add("Default"); WIStates states = worlditem.GetComponent <WIStates>(); if (states != null) { for (int i = 0; i < states.States.Count; i++) { stateNames.Add(states.States[i].Name); if (item.State == states.States[i].Name) { stateIndex = i + 1; //since the first one is Default } } } stateIndex = UnityEditor.EditorGUILayout.Popup("State:", stateIndex, stateNames.ToArray(), UnityEditor.EditorStyles.popup); GUILayout.EndHorizontal(); item.State = stateNames[stateIndex]; } } UnityEngine.GUI.color = Color.white; if (!useStrictness || Flags.Check((uint)Blueprint.Strictness, (uint)BlueprintStrictness.Subcategory, Flags.CheckType.MatchAny)) { GUILayout.BeginHorizontal(); GUILayout.Label("Subcategory: "); item.Subcategory = GUILayout.TextField(item.Subcategory); GUILayout.EndHorizontal(); } UnityEngine.GUI.color = Color.yellow; if (GUILayout.Button("(Done)", UnityEditor.EditorStyles.miniButton)) { open = false; } } GUILayout.EndVertical(); UnityEditor.EditorStyles.miniButton.stretchWidth = true; UnityEditor.EditorStyles.textField.stretchWidth = true; UnityEditor.EditorStyles.popup.stretchWidth = true; }
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"); } }
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(); } } }