public override void OnInspectorGUI() { if (_target == null) { OnEnable(); return; } inventoryManager = AdvGame.GetReferences().inventoryManager; ShowCategoriesUI(_target); EditorGUILayout.Space(); EditorGUILayout.LabelField("Stored Inventory items", EditorStyles.boldLabel); if (Application.isPlaying) { if (_target.InvCollection.InvInstances.Count > 0) { CustomGUILayout.BeginVertical(); foreach (InvInstance invInstance in _target.InvCollection.InvInstances) { if (!InvInstance.IsValid(invInstance)) { continue; } EditorGUILayout.BeginHorizontal(); if (invInstance.InvItem.canCarryMultiple) { EditorGUILayout.LabelField(invInstance.InvItem.label, EditorStyles.boldLabel, GUILayout.Width(235f)); EditorGUILayout.LabelField("Count: " + invInstance.Count.ToString()); } else { EditorGUILayout.LabelField(invInstance.InvItem.label, EditorStyles.boldLabel); } EditorGUILayout.EndHorizontal(); CustomGUILayout.DrawUILine(); } CustomGUILayout.EndVertical(); } else { EditorGUILayout.HelpBox("This Container has no items", MessageType.Info); } } else { if (_target.items.Count > 0) { CustomGUILayout.BeginVertical(); for (int i = 0; i < _target.items.Count; i++) { _target.items[i].ShowGUI(inventoryManager); if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { SideMenu(_target.items[i]); } EditorGUILayout.EndHorizontal(); if (_target.limitToCategory && _target.categoryIDs != null && _target.categoryIDs.Count > 0) { InvItem listedItem = inventoryManager.GetItem(_target.items[i].ItemID); if (listedItem != null && !_target.categoryIDs.Contains(listedItem.binID)) { EditorGUILayout.HelpBox("This item is not in the categories checked above and will not be displayed.", MessageType.Warning); } } CustomGUILayout.DrawUILine(); } CustomGUILayout.EndVertical(); } else { EditorGUILayout.HelpBox("This Container has no items", MessageType.Info); } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("New item to store:", GUILayout.MaxWidth(130f)); itemNumber = EditorGUILayout.Popup(itemNumber, CreateItemList()); if (GUILayout.Button("Add new item")) { _target.items.Add(new ContainerItem(CreateItemID(itemNumber), _target.items.ToArray())); } EditorGUILayout.EndHorizontal(); if (_target.maxSlots > 0 && _target.items.Count > _target.maxSlots) { EditorGUILayout.HelpBox("The Container is full! Excess slots will be discarded.", MessageType.Warning); } UnityVersionHandler.CustomSetDirty(_target); }
public void ShowGUI(string apiPrefix, List <string> binList) { Upgrade(); label = CustomGUILayout.TextField("Name:", label, apiPrefix + ".label", "The item's Editor name"); altLabel = CustomGUILayout.TextField("Label (if not name):", altLabel, apiPrefix + ".altLabel", "The item's in-game name, if not label"); bool isPronoun = !canBeLowerCase; isPronoun = CustomGUILayout.Toggle("Name is pronoun?", isPronoun, "!" + apiPrefix + ".canBeLowerCase", "If False, the name will be lower-cased when inside sentences."); canBeLowerCase = !isPronoun; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Category:", "The category that the item belongs to"), GUILayout.Width(146f)); if (KickStarter.inventoryManager.bins.Count > 0) { int binNumber = KickStarter.inventoryManager.GetBinSlot(binID); binNumber = CustomGUILayout.Popup(binNumber, binList.ToArray(), apiPrefix + ".binID"); binID = KickStarter.inventoryManager.bins[binNumber].id; } else { binID = -1; EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f)); } EditorGUILayout.EndHorizontal(); carryOnStart = CustomGUILayout.Toggle("Carry on start?", carryOnStart, apiPrefix + ".carryOnStart", "If True, the Player carries the item when the game begins"); if (carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory) { carryOnStartNotDefault = CustomGUILayout.Toggle("Non-default Player(s)?", carryOnStartNotDefault, apiPrefix + ".carryOnStartNotDefault", "If True, then a Player prefab that is not the default carries the item when the game begins"); if (carryOnStartNotDefault) { carryOnStartIDs = ChoosePlayerGUI(carryOnStartIDs, apiPrefix + ".carryOnStartID"); } } canCarryMultiple = CustomGUILayout.Toggle("Can carry multiple?", canCarryMultiple, apiPrefix + ".canCarryMultiple", "If True, then multiple instances of the item can be carried at once"); if (carryOnStart && canCarryMultiple) { count = CustomGUILayout.IntField("Quantity on start:", count, apiPrefix + ".count", "The number of instances that the player is carrying when the game begins"); } else { count = 1; } if (canCarryMultiple) { if (maxCount == 0) { maxCount = 999; } maxCount = CustomGUILayout.IntField("Slot capacity:", maxCount, apiPrefix + ".maxCount", "The number of instances of the item that can occupy a single inventory slot"); if (maxCount < 1) { maxCount = 1; } if (maxCount > 1) { itemStackingMode = (ItemStackingMode)CustomGUILayout.EnumPopup("Selection mode:", itemStackingMode, apiPrefix + ".itemStackingMode", "How to select items when multiple are in a given slot"); } } overrideUseSyntax = CustomGUILayout.Toggle("Override 'Use' syntax?", overrideUseSyntax, apiPrefix + ".overrideUseSyntax", "If True, then the item has its own 'Use X on Y' syntax when selected"); if (overrideUseSyntax) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f)); hotspotPrefix1.label = EditorGUILayout.TextField(hotspotPrefix1.label, GUILayout.MaxWidth(80f)); EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f)); hotspotPrefix2.label = EditorGUILayout.TextField(hotspotPrefix2.label, GUILayout.MaxWidth(80f)); EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f)); EditorGUILayout.EndHorizontal(); } linkedPrefab = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Linked prefab:", linkedPrefab, false, apiPrefix + ".linkedPrefab", "A GameObject that can be associated with the item, for the creation of e.g. 3D inventory items (through scripting only)"); if (linkedPrefab != null) { EditorGUILayout.HelpBox("This reference is accessible through scripting, or via Inventory parameter in the 'Object: Add or remove' Action.", MessageType.Info); } CustomGUILayout.DrawUILine(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Main graphic:", "The item's main graphic"), GUILayout.Width(145)); tex = (Texture)CustomGUILayout.ObjectField <Texture> (tex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".tex"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Active graphic:", "The item's 'highlighted' graphic"), GUILayout.Width(145)); activeTex = (Texture)CustomGUILayout.ObjectField <Texture> (activeTex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".activeTex"); EditorGUILayout.EndHorizontal(); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.selectInventoryDisplay == SelectInventoryDisplay.ShowSelectedGraphic) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Selected graphic:", "The item's 'selected' graphic"), GUILayout.Width(145)); selectedTex = (Texture)CustomGUILayout.ObjectField <Texture> (selectedTex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".selectedTex"); EditorGUILayout.EndHorizontal(); } if (AdvGame.GetReferences().cursorManager != null) { CursorManager cursorManager = AdvGame.GetReferences().cursorManager; if (cursorManager.inventoryHandling == InventoryHandling.ChangeCursor || cursorManager.inventoryHandling == InventoryHandling.ChangeCursorAndHotspotLabel) { cursorIcon.ShowGUI(true, true, "Cursor (optional):", cursorManager.cursorRendering, apiPrefix + ".cursorIcon", "A Cursor that, if assigned, will be used in place of the 'tex' Texture when the item is selected on the cursor"); CustomGUILayout.DrawUILine(); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Standard interactions", CustomStyles.subHeader); if (KickStarter.settingsManager && KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple && KickStarter.cursorManager) { List <string> iconList = new List <string> (); foreach (CursorIcon icon in KickStarter.cursorManager.cursorIcons) { iconList.Add(icon.id.ToString() + ": " + icon.label); } if (KickStarter.cursorManager.cursorIcons.Count > 0) { foreach (InvInteraction interaction in interactions) { EditorGUILayout.BeginHorizontal(); int invNumber = GetIconSlot(interaction.icon.id); invNumber = EditorGUILayout.Popup(invNumber, iconList.ToArray()); interaction.icon = KickStarter.cursorManager.cursorIcons[invNumber]; int i = interactions.IndexOf(interaction); string autoName = label + "_" + interaction.icon.label; interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList, autoName, apiPrefix + ".interactions[" + i + "].actionList", "The ActionList to run when the interaction is triggered"); if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { SideInteractionMenu(interactions.IndexOf(interaction)); } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("No interaction icons defined - please use the Cursor Manager", MessageType.Warning); } if (GUILayout.Button("Add interaction")) { Undo.RecordObject(KickStarter.inventoryManager, "Add new interaction"); interactions.Add(new InvInteraction(KickStarter.cursorManager.cursorIcons[0])); } } else { string autoName = label + "_Use"; useActionList = ActionListAssetMenu.AssetGUI("Use:", useActionList, autoName, apiPrefix + ".useActionList", "The ActionList asset to run when using the item is used"); if (KickStarter.cursorManager && KickStarter.cursorManager.allowInteractionCursorForInventory && KickStarter.cursorManager.cursorIcons.Count > 0) { int useCursor_int = KickStarter.cursorManager.GetIntFromID(useIconID) + 1; if (useIconID == -1) { useCursor_int = 0; } useCursor_int = CustomGUILayout.Popup("Use cursor icon:", useCursor_int, KickStarter.cursorManager.GetLabelsArray(true), apiPrefix + ".useIconID", "The Cursor to show when hovering over the item"); if (useCursor_int == 0) { useIconID = -1; } else if (KickStarter.cursorManager.cursorIcons.Count > (useCursor_int - 1)) { useIconID = KickStarter.cursorManager.cursorIcons[useCursor_int - 1].id; } } else { useIconID = 0; } autoName = label + "_Examine"; lookActionList = ActionListAssetMenu.AssetGUI("Examine:", lookActionList, autoName, apiPrefix + ".lookActionList", "The ActionListAsset to run when the item is examined"); } if (KickStarter.settingsManager && KickStarter.settingsManager.CanSelectItems(false)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Unhandled interactions", CustomStyles.subHeader); string autoName = label + "_Unhandled_Hotspot"; unhandledActionList = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", unhandledActionList, autoName, apiPrefix + ".unhandledActionList", "The ActionList asset to run when using the item on a Hotspot is unhandled"); autoName = label + "_Unhandled_Combine"; unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", unhandledCombineActionList, autoName, apiPrefix + ".unhandledCombineActionList", "The ActionListAsset to run when using the item on another InvItem is unhandled"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Combine interactions", CustomStyles.subHeader); for (int i = 0; i < combineActionList.Count; i++) { EditorGUILayout.BeginHorizontal(); int invNumber = KickStarter.inventoryManager.GetArraySlot(combineID[i]); invNumber = EditorGUILayout.Popup(invNumber, KickStarter.inventoryManager.GetLabelList()); combineID[i] = KickStarter.inventoryManager.items[invNumber].id; string autoName = label + "_Combine_" + KickStarter.inventoryManager.GetLabelList()[invNumber]; combineActionList[i] = ActionListAssetMenu.AssetGUI(string.Empty, combineActionList[i], autoName, apiPrefix + ".combineActionList[" + i + "]", "A List of all 'Combine' InvInteraction objects associated with the item"); if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth)) { Undo.RecordObject(KickStarter.inventoryManager, "Delete combine event"); combineActionList.RemoveAt(i); combineID.RemoveAt(i); break; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add combine event")) { Undo.RecordObject(KickStarter.inventoryManager, "Add new combine event"); combineActionList.Add(null); combineID.Add(0); } // List all "reverse" inventory combinations string reverseCombinations = string.Empty; foreach (InvItem otherItem in KickStarter.inventoryManager.items) { if (otherItem != this) { if (otherItem.combineID.Contains(id)) { reverseCombinations += "- " + otherItem.label + "\n"; continue; } } } if (reverseCombinations.Length > 0) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("The following inventory items have combine interactions that reference this item:\n" + reverseCombinations, MessageType.Info); } if (KickStarter.inventoryManager.invVars.Count > 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Properties", CustomStyles.subHeader); RebuildProperties(); // UI for setting property values if (vars.Count > 0) { foreach (InvVar invVar in vars) { invVar.ShowGUI(apiPrefix + ".GetProperty (" + invVar.id + ")"); } } else { EditorGUILayout.HelpBox("No properties have been defined that this inventory item can use.", MessageType.Info); } } }
private void IconsGUI() { // Make sure unhandledCursorInteractions is the same length as cursorIcons while (unhandledCursorInteractions.Count < cursorIcons.Count) { unhandledCursorInteractions.Add(null); } while (unhandledCursorInteractions.Count > cursorIcons.Count) { unhandledCursorInteractions.RemoveAt(unhandledCursorInteractions.Count + 1); } // List icons foreach (CursorIcon _cursorIcon in cursorIcons) { int i = cursorIcons.IndexOf(_cursorIcon); CustomGUILayout.DrawUILine(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Icon ID:", GUILayout.MaxWidth(145)); EditorGUILayout.LabelField(_cursorIcon.id.ToString(), GUILayout.MaxWidth(120)); GUILayout.FlexibleSpace(); if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { SideMenu(i); } EditorGUILayout.EndHorizontal(); _cursorIcon.label = CustomGUILayout.TextField("Label:", _cursorIcon.label, "AC.KickStarter.cursorManager.GetCursorIconFromID (" + i + ").label", "The display name of the icon"); if (KickStarter.settingsManager != null && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && allowIconInput) { EditorGUILayout.LabelField("Input button:", _cursorIcon.GetButtonName()); } _cursorIcon.ShowGUI(true, true, "Texture:", cursorRendering, "AC.KickStarter.cursorManager.GetCursorIconFromID (" + i + ")", "The icon's texture"); if (AllowUnhandledIcons()) { string autoName = _cursorIcon.label + "_Unhandled_Interaction"; unhandledCursorInteractions[i] = ActionListAssetMenu.AssetGUI("Unhandled interaction:", unhandledCursorInteractions[i], autoName, "AC.KickStarter.cursorManager.unhandledCursorInteractions[" + i + "]", "An ActionList asset that gets run when an unhandled Interaction is triggered"); } if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot) { _cursorIcon.dontCycle = CustomGUILayout.Toggle("Leave out of Cursor cycle?", _cursorIcon.dontCycle, "AC.KickStarter.cursorManager.GetCursorIconFromID (" + i + ").dontCycle", "If True, then the cursor will be left out of the cycle when right-clicking"); } } EditorGUILayout.Space(); if (GUILayout.Button("Create new icon")) { Undo.RecordObject(this, "Add icon"); cursorIcons.Add(new CursorIcon(GetIDArray())); } if (AllowUnhandledIcons()) { EditorGUILayout.Space(); passUnhandledHotspotAsParameter = CustomGUILayout.ToggleLeft("Pass Hotspot as GameObject parameter?", passUnhandledHotspotAsParameter, "AC.KickStarter.cursorManager.passUnhandledHotspotAsParameter", "If True, the Hotspot clicked on to initiate unhandled Interactions will be sent as a parameter to the ActionList asset"); if (passUnhandledHotspotAsParameter) { EditorGUILayout.HelpBox("The Hotspot will be set as the Unhandled interaction's first parameter, which must be set to type 'GameObject'.", MessageType.Info); } } }
private void InvInteractionGUI() { CustomGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Inventory interactions", EditorStyles.boldLabel); if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth)) { Undo.RecordObject(_target, "Create inventory interaction"); _target.invButtons.Add(new Button()); _target.provideInvInteraction = true; } EditorGUILayout.EndHorizontal(); if (_target.provideInvInteraction) { if (inventoryManager) { // Create a string List of the field's names (for the PopUp box) List <string> labelList = new List <string>(); int invNumber; if (inventoryManager.items.Count > 0) { foreach (InvItem _item in inventoryManager.items) { labelList.Add(_item.label); } foreach (Button invButton in _target.invButtons) { invNumber = -1; int j = 0; string invName = string.Empty; foreach (InvItem _item in inventoryManager.items) { // If an item has been removed, make sure selected variable is still valid if (_item.id == invButton.invID) { invNumber = j; invName = _item.label; break; } j++; } if (invNumber == -1) { // Wasn't found (item was deleted?), so revert to zero if (invButton.invID > 0) { ACDebug.Log("Previously chosen item no longer exists!"); } invNumber = 0; invButton.invID = 0; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); invNumber = CustomGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray(), "", "The inventory item associated with the interaction"); // Re-assign variableID based on PopUp selection invButton.invID = inventoryManager.items[invNumber].id; if (settingsManager != null && settingsManager.CanGiveItems()) { if (_target.GetComponent <Char>() != null || _target.GetComponentInParent <Char>()) { invButton.selectItemMode = (SelectItemMode)EditorGUILayout.EnumPopup(invButton.selectItemMode, GUILayout.Width(70f)); } } if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { SideMenu("Inv", _target.invButtons.Count, _target.invButtons.IndexOf(invButton)); } EditorGUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(invName)) { string label = invName; if (_target.GetComponent <Char>() && settingsManager != null && settingsManager.CanGiveItems()) { label = invButton.selectItemMode.ToString() + " " + label; } ButtonGUI(invButton, label, _target.interactionSource, true); } else { ButtonGUI(invButton, "Inventory", _target.interactionSource, true); } CustomGUILayout.DrawUILine(); } } else { EditorGUILayout.LabelField("No inventory items exist!"); for (int i = 0; i < _target.invButtons.Count; i++) { _target.invButtons[i].invID = -1; } } } else { ACDebug.LogWarning("An InventoryManager is required to run the game properly - please open the Adventure Creator wizard and set one."); } } CustomGUILayout.EndVertical(); }
private void UseInteractionGUI() { if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive) { if (_target.UpgradeSelf()) { UnityVersionHandler.CustomSetDirty(_target); } } CustomGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Use interactions", EditorStyles.boldLabel); if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth)) { Undo.RecordObject(_target, "Create use interaction"); _target.useButtons.Add(new Button()); _target.provideUseInteraction = true; } EditorGUILayout.EndHorizontal(); if (_target.provideUseInteraction) { if (cursorManager) { // Create a string List of the field's names (for the PopUp box) List <string> labelList = new List <string>(); int iconNumber; if (cursorManager.cursorIcons.Count > 0) { foreach (CursorIcon _icon in cursorManager.cursorIcons) { labelList.Add(_icon.id.ToString() + ": " + _icon.label); } foreach (Button useButton in _target.useButtons) { iconNumber = -1; int j = 0; foreach (CursorIcon _icon in cursorManager.cursorIcons) { // If an item has been removed, make sure selected variable is still valid if (_icon.id == useButton.iconID) { iconNumber = j; break; } j++; } if (iconNumber == -1) { // Wasn't found (item was deleted?), so revert to zero iconNumber = 0; useButton.iconID = 0; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); iconNumber = CustomGUILayout.Popup("Cursor / icon:", iconNumber, labelList.ToArray(), "", "The cursor/icon associated with the interaction"); // Re-assign variableID based on PopUp selection useButton.iconID = cursorManager.cursorIcons[iconNumber].id; string iconLabel = cursorManager.cursorIcons[iconNumber].label; if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { SideMenu("Use", _target.useButtons.Count, _target.useButtons.IndexOf(useButton)); } EditorGUILayout.EndHorizontal(); ButtonGUI(useButton, iconLabel, _target.interactionSource); CustomGUILayout.DrawUILine(); } } else { EditorGUILayout.LabelField("No cursor icons exist!"); iconNumber = -1; for (int i = 0; i < _target.useButtons.Count; i++) { _target.useButtons[i].iconID = -1; } } } else { ACDebug.LogWarning("A CursorManager is required to run the game properly - please open the Adventure Creator wizard and set one."); } } CustomGUILayout.EndVertical(); }
private void SaveFileGUI() { iSaveFileHandler saveFileHandler = SaveSystem.SaveFileHandler; iOptionsFileHandler optionsFileHandler = Options.OptionsFileHandler; iFileFormatHandler fileFormatHandler = SaveSystem.FileFormatHandler; iFileFormatHandler optionsFileFormatHandler = SaveSystem.OptionsFileFormatHandler; if (optionsFileHandler == null) { EditorGUILayout.HelpBox("No Options File Handler assigned - one must be set in order to locate Profile Data.", MessageType.Warning); return; } if (saveFileHandler == null) { EditorGUILayout.HelpBox("No Save File Handler assigned - one must be set in order to locate Save Data.", MessageType.Warning); return; } EditorGUILayout.BeginVertical(CustomStyles.thinBox); showHandlers = CustomGUILayout.ToggleHeader(showHandlers, "File and format handlers"); if (showHandlers) { if (saveFileHandler != null) { EditorGUILayout.LabelField("Save file location:", saveFileHandler.GetType().Name); } if (optionsFileHandler != null) { EditorGUILayout.LabelField("Options location:", optionsFileHandler.GetType().Name); } if (fileFormatHandler != null) { EditorGUILayout.LabelField("File format:", fileFormatHandler.GetType().Name); } if (optionsFileFormatHandler != null && fileFormatHandler == null || (optionsFileFormatHandler.GetType().Name != fileFormatHandler.GetType().Name)) { EditorGUILayout.LabelField("Options format:", optionsFileFormatHandler.GetType().Name); } EditorGUILayout.HelpBox("Save format and location handlers can be modified through script - see the Manual's 'Custom save formats and handling' chapter.", MessageType.Info); } CustomGUILayout.EndVertical(); if (settingsManager.useProfiles) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showProfiles = CustomGUILayout.ToggleHeader(showProfiles, "Profiles"); if (showProfiles) { bool foundSome = false; for (int profileID = 0; profileID < Options.maxProfiles; profileID++) { if (optionsFileHandler.DoesProfileExist(profileID)) { foundSome = true; OptionsData tempOptionsData = Options.LoadPrefsFromID(profileID, false, false); string label = profileID.ToString() + ": " + tempOptionsData.label; if (profileID == Options.GetActiveProfileID()) { label += " (ACTIVE)"; } if (GUILayout.Toggle(selectedProfileID == profileID, label, "Button")) { if (selectedProfileID != profileID) { selectedProfileID = profileID; selectedSaveIndex = -1; foundSaveFiles.Clear(); } } } } if (!foundSome) { selectedProfileID = -1; EditorGUILayout.HelpBox("No save profiles found.", MessageType.Warning); } } CustomGUILayout.EndVertical(); } else { selectedProfileID = 0; } if (selectedProfileID < 0 || !optionsFileHandler.DoesProfileExist(selectedProfileID)) { EditorGUILayout.HelpBox("No save profiles found! Run the game to create a new save profile", MessageType.Warning); return; } EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showProfile = CustomGUILayout.ToggleHeader(showProfile, "Profile " + selectedProfileID + ": Properties"); if (showProfile) { OptionsData prefsData = GetPrefsData(selectedProfileID); if (prefsData != null) { EditorGUILayout.LabelField("Label:", prefsData.label); EditorGUILayout.LabelField("ID:", prefsData.ID.ToString()); EditorGUILayout.LabelField("Language:", prefsData.language.ToString()); if (prefsData.language != prefsData.voiceLanguage) { EditorGUILayout.LabelField("Voice language:", prefsData.voiceLanguage.ToString()); } EditorGUILayout.LabelField("Show subtitles:", prefsData.showSubtitles.ToString()); EditorGUILayout.LabelField("SFX volume:", prefsData.sfxVolume.ToString()); EditorGUILayout.LabelField("Music volume:", prefsData.musicVolume.ToString()); EditorGUILayout.LabelField("Speech volume:", prefsData.speechVolume.ToString()); if (KickStarter.variablesManager != null) { List <GVar> linkedVariables = SaveSystem.UnloadVariablesData(prefsData.linkedVariables, KickStarter.variablesManager.vars, true); foreach (GVar linkedVariable in linkedVariables) { if (linkedVariable.link == VarLink.OptionsData) { EditorGUILayout.LabelField(linkedVariable.label + ":", linkedVariable.GetValue()); } } } else { EditorGUILayout.LabelField("Linked Variables:", prefsData.linkedVariables); } EditorGUILayout.BeginHorizontal(); if (settingsManager.useProfiles) { GUI.enabled = (selectedProfileID != Options.GetActiveProfileID()); if (GUILayout.Button("Make active")) { SwitchActiveProfile(selectedProfileID); } GUI.enabled = true; } if (GUILayout.Button("Delete profile")) { bool canDelete = EditorUtility.DisplayDialog("Delete profile?", "Are you sure you want to delete profile #" + selectedProfileID + "? This operation cannot be undone.", "Yes", "No"); if (canDelete) { Options.DeleteProfilePrefs(selectedProfileID); } } EditorGUILayout.EndHorizontal(); } } CustomGUILayout.EndVertical(); EditorGUILayout.Space(); foundSaveFiles = saveFileHandler.GatherSaveFiles(selectedProfileID); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showSaves = CustomGUILayout.ToggleHeader(showSaves, "Save game files"); if (showSaves) { if (foundSaveFiles != null) { for (int saveIndex = 0; saveIndex < foundSaveFiles.Count; saveIndex++) { SaveFile saveFile = foundSaveFiles[saveIndex]; string label = saveFile.saveID.ToString() + ": " + saveFile.label; if (GUILayout.Toggle(selectedSaveIndex == saveIndex, label, "Button")) { selectedSaveIndex = saveIndex; } } } if (foundSaveFiles == null || foundSaveFiles.Count == 0) { selectedSaveIndex = -1; EditorGUILayout.HelpBox("No save game files found.", MessageType.Warning); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUI.enabled = Application.isPlaying; if (GUILayout.Button("Autosave")) { if (!PlayerMenus.IsSavingLocked(null, true)) { SwitchActiveProfile(selectedProfileID); SaveSystem.SaveAutoSave(); } } if (GUILayout.Button("Save new")) { if (!PlayerMenus.IsSavingLocked(null, true)) { SwitchActiveProfile(selectedProfileID); SaveSystem.SaveNewGame(); } } GUI.enabled = (foundSaveFiles != null && foundSaveFiles.Count > 0); if (GUILayout.Button("Delete all saves")) { bool canDelete = EditorUtility.DisplayDialog("Delete all save files?", "Are you sure you want to delete all save files? This operation cannot be undone.", "Yes", "No"); if (canDelete) { saveFileHandler.DeleteAll(selectedProfileID); } } CustomGUILayout.EndVertical(); } CustomGUILayout.EndVertical(); if (selectedSaveIndex < 0 || foundSaveFiles == null || selectedSaveIndex >= foundSaveFiles.Count) { return; } EditorGUILayout.Space(); SaveFile selectedSaveFile = foundSaveFiles[selectedSaveIndex]; EditorGUILayout.BeginVertical(CustomStyles.thinBox); showSave = CustomGUILayout.ToggleHeader(showSave, "Save game " + selectedSaveIndex + ": Properties"); if (showSave) { EditorGUILayout.LabelField("Label:", selectedSaveFile.label); EditorGUILayout.LabelField("ID:", selectedSaveFile.saveID.ToString()); CustomGUILayout.MultiLineLabelGUI("Filename:", selectedSaveFile.fileName); EditorGUILayout.LabelField("Timestamp:", selectedSaveFile.updatedTime.ToString()); if (!string.IsNullOrEmpty(selectedSaveFile.screenshotFilename)) { CustomGUILayout.MultiLineLabelGUI("Filename:", selectedSaveFile.screenshotFilename); } EditorGUILayout.LabelField("Is auto-save?", selectedSaveFile.isAutoSave.ToString()); GUILayout.BeginHorizontal(); GUI.enabled = Application.isPlaying; if (GUILayout.Button("Load")) { SwitchActiveProfile(selectedProfileID); SaveSystem.LoadGame(0, selectedSaveFile.saveID, true); } if (GUILayout.Button("Save over")) { if (!PlayerMenus.IsSavingLocked(null, true)) { SwitchActiveProfile(selectedProfileID); SaveSystem.SaveGame(0, selectedSaveFile.saveID, true); } } GUI.enabled = true; if (GUILayout.Button("Delete")) { bool canDelete = EditorUtility.DisplayDialog("Delete save file?", "Are you sure you want to delete the save file " + selectedSaveFile.label + "? This operation cannot be undone.", "Yes", "No"); if (canDelete) { saveFileHandler.Delete(selectedSaveFile); } } GUILayout.EndHorizontal(); } CustomGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showSaveData = CustomGUILayout.ToggleHeader(showSaveData, "Save game " + selectedSaveIndex + ": Data"); if (showSaveData) { if (GUI.changed || !runCache) { CacheSaveData(saveFileHandler, selectedSaveFile); } if (cachedSaveData != null) { cachedSaveData.ShowGUI(); } if (cachedLevelData != null) { for (int i = 0; i < cachedLevelData.Count; i++) { CustomGUILayout.DrawUILine(); EditorGUILayout.LabelField("Scene data " + i.ToString() + ":", CustomStyles.subHeader); cachedLevelData[i].ShowGUI(); } } } CustomGUILayout.EndVertical(); }
public override void OnInspectorGUI() { SortingMap _target = (SortingMap)target; CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Properties", EditorStyles.boldLabel); _target.mapType = (SortingMapType)CustomGUILayout.EnumPopup("Affect sprite's:", _target.mapType); _target.affectScale = CustomGUILayout.Toggle("Affect Character size?", _target.affectScale, "", "If True, characters that follow this map should have their scale affected"); _target.affectSpeed = CustomGUILayout.Toggle("Affect Character speed?", _target.affectSpeed, "", "If True, characters that follow this map should have their movement speed affected by the scale factor"); if (_target.affectScale || _target.affectSpeed) { _target.sortingMapScaleType = (SortingMapScaleType)CustomGUILayout.EnumPopup("Scaling mode:", _target.sortingMapScaleType, "", "How scaling values are defined"); if (_target.sortingMapScaleType == SortingMapScaleType.Linear || _target.sortingAreas.Count == 0) { _target.originScale = CustomGUILayout.IntField("Start scale (%):", _target.originScale, "", "The scale (as a percentage) that characters will have at the very top of the map"); if (_target.sortingMapScaleType == SortingMapScaleType.AnimationCurve) { EditorGUILayout.HelpBox("The Sorting Map must have at least one area defined to make use of an animation curve.", MessageType.Warning); } } else { if (_target.scalingAnimationCurve == null) { _target.scalingAnimationCurve = AnimationCurve.Linear(0f, 0.1f, 1f, 1f); } _target.scalingAnimationCurve = CustomGUILayout.CurveField("Scaling curve:", _target.scalingAnimationCurve, "", "The AnimationCurve used to define character scaling, where 0s is the smallest scale, and 1s is the largest"); EditorGUILayout.HelpBox("The curve's values will be read from 0s to 1s only.", MessageType.Info); } if (_target.sortingMapScaleType == SortingMapScaleType.Linear && _target.sortingAreas.Count > 1) { if (GUILayout.Button("Interpolate in-between scales")) { Undo.RecordObject(_target, "Interpolate scales"); _target.SetInBetweenScales(); EditorUtility.SetDirty(_target); } } } CustomGUILayout.EndVertical(); EditorGUILayout.Space(); CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Sorting areas", EditorStyles.boldLabel); foreach (SortingArea area in _target.sortingAreas) { int i = _target.sortingAreas.IndexOf(area); CustomGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); area.color = EditorGUILayout.ColorField(area.color); EditorGUILayout.LabelField("Position:", GUILayout.Width(50f)); area.z = EditorGUILayout.FloatField(area.z, GUILayout.Width(80f)); if (_target.mapType == SortingMapType.OrderInLayer) { EditorGUILayout.LabelField("Order:", labelWidth); area.order = EditorGUILayout.IntField(area.order); } else if (_target.mapType == SortingMapType.SortingLayer) { EditorGUILayout.LabelField("Layer:", labelWidth); area.layer = EditorGUILayout.TextField(area.layer); } if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth)) { Undo.RecordObject(_target, "Add area"); if (i < _target.sortingAreas.Count - 1) { _target.sortingAreas.Insert(i + 1, new SortingArea(area, _target.sortingAreas[i + 1])); } else { _target.sortingAreas.Insert(i + 1, new SortingArea(area)); } break; } if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth)) { Undo.RecordObject(_target, "Delete area"); _target.sortingAreas.Remove(area); break; } EditorGUILayout.EndHorizontal(); if ((_target.affectScale || _target.affectSpeed) && _target.sortingMapScaleType == SortingMapScaleType.Linear) { area.scale = CustomGUILayout.IntField("End scale (%):", area.scale, "", "The factor by which characters that use FollowSortingMap will be scaled by when positioned at the bottom boundary of this region"); } CustomGUILayout.EndVertical(); CustomGUILayout.DrawUILine(); } if (GUILayout.Button("Add area")) { Undo.RecordObject(_target, "Add area"); if (_target.sortingAreas.Count > 0) { SortingArea lastArea = _target.sortingAreas [_target.sortingAreas.Count - 1]; _target.sortingAreas.Add(new SortingArea(lastArea)); } else { _target.sortingAreas.Add(new SortingArea(_target.transform.position.z + 1f, 1)); } } CustomGUILayout.EndVertical(); EditorGUILayout.Space(); if (SceneSettings.IsTopDown()) { } else if (SceneSettings.IsUnity2D()) { } else { if (GUILayout.Button("Face active camera")) { Undo.RecordObject(_target, "Face active camera"); Vector3 forwardVector = KickStarter.CameraMainTransform.forward; _target.transform.forward = -forwardVector; EditorUtility.SetDirty(_target); } } UnityVersionHandler.CustomSetDirty(_target); }