public void ShowGUI(int itemIndex, string[] labelList, string apiPrefix, Recipe recipe) { itemIndex = CustomGUILayout.Popup("Item:", itemIndex, labelList, apiPrefix + ".ingredients [" + recipe.ingredients.IndexOf(this) + "].itemID"); itemID = KickStarter.inventoryManager.items[itemIndex].id; if (InvItem.canCarryMultiple) { if (recipe.useSpecificSlots && InvItem.maxCount == 1) { // Don't show amount in this case: make other ingredients of same item amount = 1; } else { amount = EditorGUILayout.IntField("Amount:", amount); if (amount < 1) { amount = 1; } } } if (recipe.useSpecificSlots) { slotNumber = EditorGUILayout.IntField("Crafting slot:", slotNumber); } }
private ShapeKey KeyGUI(ShapeKey shapeKey, string[] blendShapeNames) { EditorGUILayout.LabelField("Shape key " + shapeKey.label, EditorStyles.boldLabel); shapeKey.label = CustomGUILayout.TextField("Key label:", shapeKey.label, "", "An editor-friendly name of the blendshape"); if (blendShapeNames != null && blendShapeNames.Length > 0) { shapeKey.index = CustomGUILayout.Popup("Blendshape:", shapeKey.index, blendShapeNames, "", "The Blendshape that this relates to"); } else { shapeKey.index = CustomGUILayout.IntField("BlendShape index:", shapeKey.index, "", "The Blendshape that this relates to"); } return(shapeKey); }
private int CreateInventoryGUI(int invID) { if (AdvGame.GetReferences().inventoryManager == null || AdvGame.GetReferences().inventoryManager.items == null || AdvGame.GetReferences().inventoryManager.items.Count == 0) { EditorGUILayout.HelpBox("Cannot find any inventory items!", MessageType.Warning); return(invID); } // Create a string List of the field's names (for the PopUp box) List <string> labelList = new List <string>(); int invNumber = -1; int i = 0; if (AdvGame.GetReferences().inventoryManager.items.Count > 0) { foreach (InvItem _item in AdvGame.GetReferences().inventoryManager.items) { labelList.Add(_item.label); // If a item has been removed, make sure selected variable is still valid if (_item.id == invID) { invNumber = i; } i++; } if (invNumber == -1) { if (invID > 0) { ACDebug.Log("Previously chosen item no longer exists!"); } invNumber = 0; invID = 0; } else { invNumber = CustomGUILayout.Popup("Linked inventory item:", invNumber, labelList.ToArray(), "", "The inventory item that the player must be carrying for the option to be active"); invID = AdvGame.GetReferences().inventoryManager.items[invNumber].id; } } return(invID); }
private int ChoosePlayerGUI(int playerID, string api) { List <string> labelList = new List <string>(); int i = 0; int playerNumber = -1; if (AdvGame.GetReferences().settingsManager.players.Count > 0) { foreach (PlayerPrefab playerPrefab in settingsManager.players) { if (playerPrefab.playerOb != null) { labelList.Add(playerPrefab.playerOb.name); } else { labelList.Add("(Undefined prefab)"); } // If a player has been removed, make sure selected player is still valid if (playerPrefab.ID == playerID) { playerNumber = i; } i++; } if (playerNumber == -1) { // Wasn't found (item was possibly deleted), so revert to zero ACDebug.LogWarning("Previously chosen Player no longer exists!"); playerNumber = 0; playerID = 0; } playerNumber = CustomGUILayout.Popup("Item is carried by:", playerNumber, labelList.ToArray(), api); playerID = settingsManager.players[playerNumber].ID; } return(playerID); }
private void LookIconGUI() { if (cursorIcons.Count > 0) { int lookCursor_int = GetIntFromID(lookCursor_ID); lookCursor_int = CustomGUILayout.Popup("Examine icon:", lookCursor_int, GetLabelsArray(), "AC.KickStarter.cursorManager.lookCursor_ID"); lookCursor_ID = cursorIcons[lookCursor_int].id; if (cursorRendering == CursorRendering.Software) { EditorGUILayout.LabelField("When Use and Examine interactions are both available:"); lookUseCursorAction = (LookUseCursorAction)CustomGUILayout.EnumPopup(" ", lookUseCursorAction, "AC.KickStarter.cursorManager.lookUseCursorAction"); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Left-click to examine when no use interaction exists?", GUILayout.Width(300f)); leftClickExamine = CustomGUILayout.Toggle(leftClickExamine, "AC.KickStarter.cursorManager.leftClickExamine"); EditorGUILayout.EndHorizontal(); } }
protected void ChangeCursorGUI(Menu menu) { string apiPrefix = "AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\")"; changeCursor = CustomGUILayout.Toggle("Change cursor when over?", changeCursor, apiPrefix + ".changeCursor", "If True, then the mouse cursor will change when it hovers over the element"); if (changeCursor) { CursorManager cursorManager = AdvGame.GetReferences().cursorManager; if (cursorManager != null) { int cursorIndex = cursorManager.GetIntFromID(cursorID); cursorIndex = CustomGUILayout.Popup("Cursor ID:", cursorIndex, cursorManager.GetLabelsArray(), apiPrefix + ".cursorID", "The Cursor to display when the mouse hovers of the element"); cursorID = cursorManager.cursorIcons[cursorIndex].id; } else { EditorGUILayout.HelpBox("No Cursor Manager found!", MessageType.Warning); } } }
private void LookIconGUI() { if (cursorIcons.Count > 0) { int lookCursor_int = GetIntFromID(lookCursor_ID); lookCursor_int = CustomGUILayout.Popup("Examine icon:", lookCursor_int, GetLabelsArray(), "AC.KickStarter.cursorManager.lookCursor_ID", "The Cursor that represents the 'Examine' Interaction"); lookCursor_ID = cursorIcons[lookCursor_int].id; EditorGUILayout.LabelField(new GUIContent("When Use and Examine interactions are both available:", "What happens when hovering over a Hotspot that has both a Use and Examine Interaction")); lookUseCursorAction = (LookUseCursorAction)CustomGUILayout.EnumPopup(" ", lookUseCursorAction, "AC.KickStarter.cursorManager.lookUseCursorAction"); if (cursorRendering == CursorRendering.Hardware && lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide) { EditorGUILayout.HelpBox("This mode is not available with Hardward cursor rendering.", MessageType.Warning); } if (lookUseCursorAction != LookUseCursorAction.RightClickCyclesModes) { leftClickExamine = CustomGUILayout.ToggleLeft("Left-click to examine when no use interaction exists?", leftClickExamine, "AC.KickStarter.cursorManager.leftClickExamine", "If True, then left-clicking a Hotspot will examine it if no 'Use' Interaction exists"); } } }
public static int ShowDocumentSelectorGUI(string label, List <Document> documents, int ID, string tooltip = "") { int docNumber = -1; List <string> labelList = new List <string>(); labelList.Add(" (None)"); foreach (Document document in documents) { labelList.Add(document.Title); } docNumber = GetDocNumber(documents, ID) + 1; docNumber = CustomGUILayout.Popup(label, docNumber, labelList.ToArray(), string.Empty, tooltip) - 1; if (docNumber >= 0) { return(documents[docNumber].ID); } return(-1); }
public static int ShowInvItemSelectorGUI(string label, List <InvItem> items, int ID, string tooltip = "") { int invNumber = -1; List <string> labelList = new List <string>(); labelList.Add(" (None)"); foreach (InvItem _item in items) { labelList.Add(_item.label); } invNumber = GetInvNumber(items, ID) + 1; invNumber = CustomGUILayout.Popup(label, invNumber, labelList.ToArray(), string.Empty, tooltip) - 1; if (invNumber >= 0) { return(items[invNumber].id); } return(-1); }
public void ShowGUI(string apiPrefix) { string _label = label + ":"; if (string.IsNullOrEmpty(label)) { _label = "Property " + id.ToString() + ":"; } switch (type) { case VariableType.Boolean: if (val != 1) { val = 0; } val = CustomGUILayout.Popup(_label, val, boolType, apiPrefix + ".BooleanValue", "The property's value for this item"); break; case VariableType.Integer: val = CustomGUILayout.IntField(_label, val, apiPrefix + ".IntegerValue", "The property's value for this item"); break; case VariableType.PopUp: val = CustomGUILayout.Popup(_label, val, GenerateEditorPopUpLabels(), apiPrefix + ".IntegerValue", "The property's value for this item"); break; case VariableType.String: textVal = CustomGUILayout.TextField(_label, textVal, apiPrefix + ".TextValue", "The property's value for this item"); break; case VariableType.Float: floatVal = CustomGUILayout.FloatField(_label, floatVal, apiPrefix + ".FloatValue", "The property's value for this item"); break; case VariableType.Vector3: vector3Val = CustomGUILayout.Vector3Field(_label, vector3Val, apiPrefix + ".Vector3Value", "The property's value for this item"); break; } }
protected void SharedGUI(DragBase _target, bool isOnHinge) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Collision settings:", EditorStyles.boldLabel); _target.ignorePlayerCollider = CustomGUILayout.ToggleLeft("Ignore Player's collider?", _target.ignorePlayerCollider, "", "If True, then the Physics system will ignore collisions between this object and the player"); _target.ignoreMoveableRigidbodies = CustomGUILayout.ToggleLeft("Ignore Moveable Rigidbodies?", _target.ignoreMoveableRigidbodies, "", " If True, then the Physics system will ignore collisions between this object and the bounday colliders of any DragTrack that this is not locked to"); _target.childrenShareLayer = CustomGUILayout.ToggleLeft("Place children on same layer?", _target.childrenShareLayer, "", "If True, then this object's children will be placed on the same layer"); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Icon settings:", EditorStyles.boldLabel); _target.showIcon = CustomGUILayout.Toggle("Icon at contact point?", _target.showIcon, "", "If True, then an icon will be displayed at the 'grab point' when the object is held"); if (_target.showIcon) { if (cursorManager && cursorManager.cursorIcons.Count > 0) { int cursorInt = cursorManager.GetIntFromID(_target.iconID); cursorInt = CustomGUILayout.Popup("Cursor icon:", cursorInt, cursorManager.GetLabelsArray(), "", "The cursor that gets shown when held"); _target.iconID = cursorManager.cursorIcons [cursorInt].id; } else { _target.iconID = -1; } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Sound settings:", EditorStyles.boldLabel); _target.moveSoundClip = (AudioClip)CustomGUILayout.ObjectField <AudioClip> ("Move sound:", _target.moveSoundClip, false, "", "The sound to play when the object is moved"); _target.slideSoundThreshold = CustomGUILayout.FloatField("Min. move speed:", _target.slideSoundThreshold, "", "The minimum speed that the object must be moving by for sound to play"); _target.slidePitchFactor = CustomGUILayout.FloatField("Pitch factor:", _target.slidePitchFactor, "", "The factor by which the movement sound's pitch is adjusted in relation to speed"); _target.collideSoundClip = (AudioClip)CustomGUILayout.ObjectField <AudioClip> ("Collide sound:", _target.collideSoundClip, false, "", "The sound to play when the object has a collision"); if (isOnHinge) { _target.onlyPlayLowerCollisionSound = CustomGUILayout.Toggle("Only on lower boundary?", _target.onlyPlayLowerCollisionSound, "", "If True, then the collision sound will only play when the object collides with its lower boundary collider"); } EditorGUILayout.EndVertical(); }
public static int ShowVarSelectorGUI(string label, List <GVar> vars, int ID, string tooltip = "") { int variableNumber = -1; List <string> labelList = new List <string>(); labelList.Add(" (None)"); foreach (GVar _var in vars) { labelList.Add(_var.label); } variableNumber = GetVarNumber(vars, ID) + 1; variableNumber = CustomGUILayout.Popup(label, variableNumber, labelList.ToArray(), string.Empty, tooltip) - 1; if (variableNumber >= 0) { return(vars[variableNumber].id); } return(-1); }
private void LookIconGUI() { if (cursorIcons.Count > 0) { int lookCursor_int = GetIntFromID(lookCursor_ID); lookCursor_int = CustomGUILayout.Popup("Examine icon:", lookCursor_int, GetLabelsArray(), "AC.KickStarter.cursorManager.lookCursor_ID"); lookCursor_ID = cursorIcons[lookCursor_int].id; EditorGUILayout.LabelField("When Use and Examine interactions are both available:"); lookUseCursorAction = (LookUseCursorAction)CustomGUILayout.EnumPopup(" ", lookUseCursorAction, "AC.KickStarter.cursorManager.lookUseCursorAction"); if (cursorRendering == CursorRendering.Hardware && lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide) { EditorGUILayout.HelpBox("This mode is not available with Hardward cursor rendering.", MessageType.Warning); } if (lookUseCursorAction != LookUseCursorAction.RightClickCyclesModes) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Left-click to examine when no use interaction exists?", GUILayout.Width(300f)); leftClickExamine = CustomGUILayout.Toggle(leftClickExamine, "AC.KickStarter.cursorManager.leftClickExamine"); EditorGUILayout.EndHorizontal(); } } }
private void CraftingGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Crafting", CustomStyles.subHeader); EditorGUILayout.Space(); if (items.Count == 0) { EditorGUILayout.HelpBox("No inventory items defined!", MessageType.Info); return; } foreach (Recipe recipe in recipes) { EditorGUILayout.BeginHorizontal(); string buttonLabel = recipe.label; if (buttonLabel == "") { buttonLabel = "(Untitled)"; } if (GUILayout.Toggle(recipe.isEditing, recipe.id + ": " + buttonLabel, "Button")) { if (selectedRecipe != recipe) { DeactivateAllRecipes(); ActivateRecipe(recipe); } } if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(15f))) { Undo.RecordObject(this, "Delete recipe"); DeactivateAllRecipes(); recipes.Remove(recipe); AssetDatabase.SaveAssets(); break; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Create new recipe")) { Undo.RecordObject(this, "Create inventory recipe"); Recipe newRecipe = new Recipe(GetIDArrayRecipe()); recipes.Add(newRecipe); DeactivateAllRecipes(); ActivateRecipe(newRecipe); } EditorGUILayout.EndVertical(); if (selectedRecipe != null && recipes.Contains(selectedRecipe)) { string apiPrefix = "AC.KickStarter.inventoryManager.GetRecipe (" + selectedRecipe.id + ")"; EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Recipe '" + selectedRecipe.label + "' properties", CustomStyles.subHeader); EditorGUILayout.Space(); selectedRecipe.label = CustomGUILayout.TextField("Name:", selectedRecipe.label, apiPrefix + ".label"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Resulting item:", GUILayout.Width(146f)); int i = GetArraySlot(selectedRecipe.resultID); i = CustomGUILayout.Popup(i, GetLabelList(), apiPrefix + ".resultID"); selectedRecipe.resultID = items[i].id; EditorGUILayout.EndHorizontal(); selectedRecipe.autoCreate = CustomGUILayout.Toggle("Result is automatic?", selectedRecipe.autoCreate, apiPrefix + ".autoCreate"); selectedRecipe.useSpecificSlots = CustomGUILayout.Toggle("Requires specific pattern?", selectedRecipe.useSpecificSlots, apiPrefix + ".useSpecificSlots"); selectedRecipe.actionListOnCreate = ActionListAssetMenu.AssetGUI("ActionList when create:", selectedRecipe.actionListOnCreate, apiPrefix + ".actionListOnCreate"); selectedRecipe.onCreateRecipe = (OnCreateRecipe)CustomGUILayout.EnumPopup("When click on result:", selectedRecipe.onCreateRecipe, apiPrefix + ".onCreateRecipe"); if (selectedRecipe.onCreateRecipe == OnCreateRecipe.RunActionList) { selectedRecipe.invActionList = ActionListAssetMenu.AssetGUI("ActionList when click:", selectedRecipe.invActionList, apiPrefix + ".invActionList"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Ingredients", CustomStyles.subHeader); foreach (Ingredient ingredient in selectedRecipe.ingredients) { int j = selectedRecipe.ingredients.IndexOf(ingredient); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Ingredient:", GUILayout.Width(70f)); i = GetArraySlot(ingredient.itemID); i = CustomGUILayout.Popup(i, GetLabelList(), apiPrefix + ".ingredients [" + j + "].itemID"); ingredient.itemID = items[i].id; if (items[i].canCarryMultiple) { EditorGUILayout.LabelField("Amount:", GUILayout.Width(50f)); ingredient.amount = EditorGUILayout.IntField(ingredient.amount, GUILayout.Width(30f)); } if (selectedRecipe.useSpecificSlots) { EditorGUILayout.LabelField("Slot:", GUILayout.Width(30f)); ingredient.slotNumber = EditorGUILayout.IntField(ingredient.slotNumber, GUILayout.Width(30f)); } if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(15f))) { Undo.RecordObject(this, "Delete ingredient"); selectedRecipe.ingredients.Remove(ingredient); AssetDatabase.SaveAssets(); break; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add new ingredient")) { Undo.RecordObject(this, "Add recipe ingredient"); Ingredient newIngredient = new Ingredient(); selectedRecipe.ingredients.Add(newIngredient); } EditorGUILayout.EndVertical(); } }
private void ItemsGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Unhandled events", CustomStyles.subHeader); EditorGUILayout.Space(); unhandledCombine = ActionListAssetMenu.AssetGUI("Combine:", unhandledCombine, "AC.KickStarter.runtimeInventory.unhandledCombine"); unhandledHotspot = ActionListAssetMenu.AssetGUI("Use on hotspot:", unhandledHotspot, "AC.KickStarter.runtimeInventory.unhandledHotspot"); if (settingsManager != null && settingsManager.CanGiveItems()) { unhandledGive = ActionListAssetMenu.AssetGUI("Give to NPC:", unhandledGive, "AC.KickStarter.runtimeInventory.unhandledGive"); } passUnhandledHotspotAsParameter = CustomGUILayout.ToggleLeft("Pass Hotspot as GameObject parameter?", passUnhandledHotspotAsParameter, "AC.KickStarter.inventoryManager.passUnhandledHotspotAsParameter"); if (passUnhandledHotspotAsParameter && unhandledHotspot != null) { EditorGUILayout.HelpBox("The Hotspot will be set as " + unhandledHotspot.name + "'s first parameter, which must be set to type 'GameObject'.", MessageType.Info); } List <string> binList = new List <string>(); foreach (InvBin bin in bins) { binList.Add(bin.label); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); CreateItemsGUI(binList.ToArray()); EditorGUILayout.Space(); if (selectedItem != null && items.Contains(selectedItem)) { string apiPrefix = "AC.KickStarter.runtimeInventory.GetItem (" + selectedItem.id + ")"; EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Inventory item '" + selectedItem.label + "' settings", CustomStyles.subHeader); EditorGUILayout.Space(); selectedItem.label = CustomGUILayout.TextField("Name:", selectedItem.label, apiPrefix + ".label"); selectedItem.altLabel = CustomGUILayout.TextField("Label (if not name):", selectedItem.altLabel, apiPrefix + ".altLabel"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Category:", GUILayout.Width(146f)); if (bins.Count > 0) { binNumber = GetBinSlot(selectedItem.binID); binNumber = CustomGUILayout.Popup(binNumber, binList.ToArray(), apiPrefix + ".binID"); selectedItem.binID = bins[binNumber].id; } else { selectedItem.binID = -1; EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f)); } EditorGUILayout.EndHorizontal(); selectedItem.carryOnStart = CustomGUILayout.Toggle("Carry on start?", selectedItem.carryOnStart, apiPrefix + ".carryOnStart"); if (selectedItem.carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory) { selectedItem.carryOnStartNotDefault = CustomGUILayout.Toggle("Give to non-default player?", selectedItem.carryOnStartNotDefault, apiPrefix + ".carryOnStartNotDefault"); if (selectedItem.carryOnStartNotDefault) { selectedItem.carryOnStartID = ChoosePlayerGUI(selectedItem.carryOnStartID, apiPrefix + ".carryOnStartID"); } } selectedItem.canCarryMultiple = CustomGUILayout.Toggle("Can carry multiple?", selectedItem.canCarryMultiple, apiPrefix + ".canCarryMultiple"); if (selectedItem.canCarryMultiple) { selectedItem.useSeparateSlots = CustomGUILayout.Toggle("Place in separate slots?", selectedItem.useSeparateSlots, apiPrefix + ".useSeparateSlots"); } if (selectedItem.carryOnStart && selectedItem.canCarryMultiple) { selectedItem.count = CustomGUILayout.IntField("Quantity on start:", selectedItem.count, apiPrefix + ".count"); } else { selectedItem.count = 1; } selectedItem.overrideUseSyntax = CustomGUILayout.Toggle("Override 'Use' syntax?", selectedItem.overrideUseSyntax, apiPrefix + ".overrideUseSyntax"); if (selectedItem.overrideUseSyntax) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f)); selectedItem.hotspotPrefix1.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix1.label, GUILayout.MaxWidth(80f)); EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f)); selectedItem.hotspotPrefix2.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix2.label, GUILayout.MaxWidth(80f)); EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f)); EditorGUILayout.EndHorizontal(); } selectedItem.linkedPrefab = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Linked prefab:", selectedItem.linkedPrefab, false, apiPrefix + ".linkedPrefab"); if (selectedItem.linkedPrefab != null) { EditorGUILayout.HelpBox("This reference is only accessibly through scripting.", MessageType.Info); } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Main graphic:", GUILayout.Width(145)); selectedItem.tex = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (selectedItem.tex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".tex"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Active graphic:", GUILayout.Width(145)); selectedItem.activeTex = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (selectedItem.activeTex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".activeTex"); EditorGUILayout.EndHorizontal(); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.selectInventoryDisplay == SelectInventoryDisplay.ShowSelectedGraphic) { selectedItem.selectedTex = (Texture2D)CustomGUILayout.ObjectField <Texture2D> ("Selected graphic:", selectedItem.selectedTex, false, apiPrefix + ".selectedTex"); } if (AdvGame.GetReferences().cursorManager != null) { CursorManager cursorManager = AdvGame.GetReferences().cursorManager; if (cursorManager.inventoryHandling == InventoryHandling.ChangeCursor || cursorManager.inventoryHandling == InventoryHandling.ChangeCursorAndHotspotLabel) { GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); selectedItem.cursorIcon.ShowGUI(true, "Cursor (optional):", cursorManager.cursorRendering, apiPrefix + ".cursorIcon"); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Standard interactions", CustomStyles.subHeader); if (settingsManager && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Multiple && AdvGame.GetReferences().cursorManager) { CursorManager cursorManager = AdvGame.GetReferences().cursorManager; List <string> iconList = new List <string>(); foreach (CursorIcon icon in cursorManager.cursorIcons) { iconList.Add(icon.label); } if (cursorManager.cursorIcons.Count > 0) { foreach (InvInteraction interaction in selectedItem.interactions) { EditorGUILayout.BeginHorizontal(); invNumber = GetIconSlot(interaction.icon.id); invNumber = EditorGUILayout.Popup(invNumber, iconList.ToArray()); interaction.icon = cursorManager.cursorIcons[invNumber]; int i = selectedItem.interactions.IndexOf(interaction); string autoName = selectedItem.label + "_" + interaction.icon.label; interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList, apiPrefix + ".interactions[" + i + "].actionList", autoName); if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth)) { Undo.RecordObject(this, "Delete interaction"); selectedItem.interactions.Remove(interaction); break; } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("No interaction icons defined - please use the Cursor Manager", MessageType.Warning); } if (GUILayout.Button("Add interaction")) { Undo.RecordObject(this, "Add new interaction"); selectedItem.interactions.Add(new InvInteraction(cursorManager.cursorIcons[0])); } } else { string autoName = selectedItem.label + "_Use"; selectedItem.useActionList = ActionListAssetMenu.AssetGUI("Use:", selectedItem.useActionList, apiPrefix + ".useActionList", autoName); if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0) { int useCursor_int = cursorManager.GetIntFromID(selectedItem.useIconID) + 1; if (selectedItem.useIconID == -1) { useCursor_int = 0; } useCursor_int = CustomGUILayout.Popup("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray(true), apiPrefix + ".useIconID"); if (useCursor_int == 0) { selectedItem.useIconID = -1; } else if (cursorManager.cursorIcons.Count > (useCursor_int - 1)) { selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int - 1].id; } } else { selectedItem.useIconID = 0; } autoName = selectedItem.label + "_Examine"; selectedItem.lookActionList = ActionListAssetMenu.AssetGUI("Examine:", selectedItem.lookActionList, apiPrefix + ".lookActionList", autoName); } if (settingsManager.CanSelectItems(false)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Unhandled interactions", CustomStyles.subHeader); string autoName = selectedItem.label + "_Unhandled_Hotspot"; selectedItem.unhandledActionList = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", selectedItem.unhandledActionList, apiPrefix + ".unhandledActionList", autoName); autoName = selectedItem.label + "_Unhandled_Combine"; selectedItem.unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", selectedItem.unhandledCombineActionList, apiPrefix + ".unhandledCombineActionList", autoName); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Combine interactions", CustomStyles.subHeader); for (int i = 0; i < selectedItem.combineActionList.Count; i++) { EditorGUILayout.BeginHorizontal(); invNumber = GetArraySlot(selectedItem.combineID[i]); invNumber = EditorGUILayout.Popup(invNumber, GetLabelList()); selectedItem.combineID[i] = items[invNumber].id; string autoName = selectedItem.label + "_Combine_" + GetLabelList() [invNumber]; selectedItem.combineActionList[i] = ActionListAssetMenu.AssetGUI("", selectedItem.combineActionList[i], apiPrefix + ".combineActionList[" + i + "]", autoName); if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth)) { Undo.RecordObject(this, "Delete combine event"); selectedItem.combineActionList.RemoveAt(i); selectedItem.combineID.RemoveAt(i); break; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add combine event")) { Undo.RecordObject(this, "Add new combine event"); selectedItem.combineActionList.Add(null); selectedItem.combineID.Add(0); } // List all "reverse" inventory combinations string reverseCombinations = ""; foreach (InvItem otherItem in items) { if (otherItem != selectedItem) { if (otherItem.combineID.Contains(selectedItem.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 (invVars.Count > 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Properties", CustomStyles.subHeader); RebuildProperties(selectedItem); // UI for setting property values if (selectedItem.vars.Count > 0) { foreach (InvVar invVar in selectedItem.vars) { string label = invVar.label + ":"; if (invVar.label.Length == 0) { label = "Property " + invVar.id.ToString() + ":"; } if (invVar.type == VariableType.Boolean) { if (invVar.val != 1) { invVar.val = 0; } invVar.val = CustomGUILayout.Popup(label, invVar.val, boolType, apiPrefix + ".GetProperty (" + invVar.id + ").val"); } else if (invVar.type == VariableType.Integer) { invVar.val = CustomGUILayout.IntField(label, invVar.val, apiPrefix + ".GetProperty (" + invVar.id + ").val"); } else if (invVar.type == VariableType.PopUp) { invVar.val = CustomGUILayout.Popup(label, invVar.val, invVar.popUps, apiPrefix + ".GetProperty (" + invVar.id + ").val"); } else if (invVar.type == VariableType.String) { invVar.textVal = CustomGUILayout.TextField(label, invVar.textVal, apiPrefix + ".GetProperty (" + invVar.id + ").textVal"); } else if (invVar.type == VariableType.Float) { invVar.floatVal = CustomGUILayout.FloatField(label, invVar.floatVal, apiPrefix + ".GetProperty (" + invVar.id + ").floatVal"); } } } else { EditorGUILayout.HelpBox("No properties have been defined that this inventory item can use.", MessageType.Info); } } EditorGUILayout.EndVertical(); } }
private void UseInteractionGUI() { if (settingsManager && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive) { if (_target.UpgradeSelf()) { UnityVersionHandler.CustomSetDirty(_target); } } EditorGUILayout.BeginVertical("Button"); 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("", CustomStyles.IconCog)) { SideMenu("Use", _target.useButtons.Count, _target.useButtons.IndexOf(useButton)); } EditorGUILayout.EndHorizontal(); ButtonGUI(useButton, iconLabel, _target.interactionSource); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } } 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."); } } EditorGUILayout.EndVertical(); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuLabel)"; MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); if (source != MenuSource.AdventureCreator) { uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); } labelType = (AC_LabelType)CustomGUILayout.EnumPopup("Label type:", labelType, apiPrefix + ".labelType"); if (labelType == AC_LabelType.Normal) { label = CustomGUILayout.TextField("Label text:", label, apiPrefix + ".label"); } else if (source == MenuSource.AdventureCreator) { label = CustomGUILayout.TextField("Placeholder text:", label, apiPrefix + ".label"); } if (labelType == AC_LabelType.GlobalVariable) { variableID = AdvGame.GlobalVariableGUI("Global Variable:", variableID); } else if (labelType == AC_LabelType.DialogueLine) { useCharacterColour = CustomGUILayout.Toggle("Use Character text colour?", useCharacterColour, apiPrefix + ".useCharacterColour"); if (sizeType == AC_SizeType.Manual) { autoAdjustHeight = CustomGUILayout.Toggle("Auto-adjust height to fit?", autoAdjustHeight, apiPrefix + ".autoAdjustHeight"); } } if (labelType == AC_LabelType.Hotspot || labelType == AC_LabelType.DialogueLine || labelType == AC_LabelType.DialogueSpeaker) { updateIfEmpty = CustomGUILayout.Toggle("Update if string is empty?", updateIfEmpty, apiPrefix + ".updateIfEmpty"); if (labelType == AC_LabelType.Hotspot) { showPendingWhileMovingToHotspot = CustomGUILayout.ToggleLeft("Show pending Interaction while moving to Hotspot?", showPendingWhileMovingToHotspot, apiPrefix + ".showPendingWhileMovingToHotspot"); } } else if (labelType == AC_LabelType.InventoryProperty) { if (AdvGame.GetReferences().inventoryManager) { if (AdvGame.GetReferences().inventoryManager.invVars != null && AdvGame.GetReferences().inventoryManager.invVars.Count > 0) { InvVar[] invVars = AdvGame.GetReferences().inventoryManager.invVars.ToArray(); List <string> invVarNames = new List <string>(); int itemPropertyNumber = 0; for (int i = 0; i < invVars.Length; i++) { if (invVars[i].id == itemPropertyID) { itemPropertyNumber = i; } invVarNames.Add(invVars[i].id + ": " + invVars[i].label); } itemPropertyNumber = CustomGUILayout.Popup("Inventory property:", itemPropertyNumber, invVarNames.ToArray(), apiPrefix + ".itemPropertyNumber"); itemPropertyID = invVars[itemPropertyNumber].id; inventoryPropertyType = (InventoryPropertyType)CustomGUILayout.EnumPopup("Inventory item source:", inventoryPropertyType, apiPrefix + ".inventoryPropertyType"); } else { EditorGUILayout.HelpBox("No Inventory properties defined!", MessageType.Warning); } } else { EditorGUILayout.HelpBox("No Inventory Manager assigned!", MessageType.Warning); } } EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuLabel)"; MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); if (source != MenuSource.AdventureCreator) { #if TextMeshProIsPresent uiText = LinkedUiGUI <TMPro.TextMeshProUGUI> (uiText, "Linked Text:", source); #else uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); #endif EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); } labelType = (AC_LabelType)CustomGUILayout.EnumPopup("Label type:", labelType, apiPrefix + ".labelType", "What kind of text the label displays"); if (labelType == AC_LabelType.Normal) { label = CustomGUILayout.TextField("Label text:", label, apiPrefix + ".label", "The display text"); } else if (source == MenuSource.AdventureCreator) { label = CustomGUILayout.TextField("Placeholder text:", label, apiPrefix + ".label"); } if (labelType == AC_LabelType.GlobalVariable) { variableID = AdvGame.GlobalVariableGUI("Global Variable:", variableID, "The Global Variable whose value will be displayed"); } else if (labelType == AC_LabelType.DialogueLine) { useCharacterColour = CustomGUILayout.Toggle("Use Character text colour?", useCharacterColour, apiPrefix + ".useCharacterColour", "If True, then the displayed subtitle text will use the speaking character's subtitle text colour"); if (sizeType == AC_SizeType.Manual) { autoAdjustHeight = CustomGUILayout.Toggle("Auto-adjust height to fit?", autoAdjustHeight, apiPrefix + ".autoAdjustHeight", "If True, then the label's height will adjust itself to fit the text within it"); } } if (labelType == AC_LabelType.Hotspot || labelType == AC_LabelType.DialogueLine || labelType == AC_LabelType.DialogueSpeaker) { updateIfEmpty = CustomGUILayout.Toggle("Update if string is empty?", updateIfEmpty, apiPrefix + ".updateIfEmpty", "If True, then the display text buffer can be empty "); if (labelType == AC_LabelType.Hotspot) { showPendingWhileMovingToHotspot = CustomGUILayout.ToggleLeft("Show pending Interaction while moving to Hotspot?", showPendingWhileMovingToHotspot, apiPrefix + ".showPendingWhileMovingToHotspot", "If True, then the label will not change while the player is moving towards a Hotspot in order to run an interaction"); } } else if (labelType == AC_LabelType.InventoryProperty) { if (AdvGame.GetReferences().inventoryManager) { if (AdvGame.GetReferences().inventoryManager.invVars != null && AdvGame.GetReferences().inventoryManager.invVars.Count > 0) { InvVar[] invVars = AdvGame.GetReferences().inventoryManager.invVars.ToArray(); List <string> invVarNames = new List <string>(); int itemPropertyNumber = 0; for (int i = 0; i < invVars.Length; i++) { if (invVars[i].id == itemPropertyID) { itemPropertyNumber = i; } invVarNames.Add(invVars[i].id + ": " + invVars[i].label); } itemPropertyNumber = CustomGUILayout.Popup("Inventory property:", itemPropertyNumber, invVarNames.ToArray(), apiPrefix + ".itemPropertyNumber", "The inventory property to show"); itemPropertyID = invVars[itemPropertyNumber].id; inventoryPropertyType = (InventoryPropertyType)CustomGUILayout.EnumPopup("Inventory item source:", inventoryPropertyType, apiPrefix + ".inventoryPropertyType", "What kind of item to display properties for"); } else { EditorGUILayout.HelpBox("No Inventory properties defined!", MessageType.Warning); } } else { EditorGUILayout.HelpBox("No Inventory Manager assigned!", MessageType.Warning); } } EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
public void ShowGUI(VariableLocation location, bool canEdit, List <VarPreset> _varPresets = null, string apiPrefix = "", Variables _variables = null) { string labelPrefix = (canEdit) ? "Initial value:" : "Current value:"; string helpText = (canEdit) ? "Its initial value" : "Its current value"; if (!canEdit && HasTranslations() && Options.GetLanguage() > 0) { labelPrefix = "Original language value:"; } if (canEdit) { label = CustomGUILayout.TextField("Label:", label, apiPrefix + ".label", "Its editor name"); type = (VariableType)CustomGUILayout.EnumPopup("Type:", type, apiPrefix + ".type", "Its variable type"); } else { EditorGUILayout.LabelField("Label: " + label); EditorGUILayout.LabelField("Type: " + type.ToString()); } switch (type) { case VariableType.Boolean: if (val != 1) { val = 0; } val = CustomGUILayout.Popup(labelPrefix, val, boolType, apiPrefix + ".BooleanValue", helpText); break; case VariableType.Float: floatVal = CustomGUILayout.FloatField(labelPrefix, floatVal, apiPrefix + ".FloatValue", helpText); break; case VariableType.Integer: val = CustomGUILayout.IntField(labelPrefix, val, apiPrefix + ".IntegerValue", helpText); break; case VariableType.PopUp: Object objectToRecord = null; if (location == VariableLocation.Global) { objectToRecord = KickStarter.variablesManager; } if (location == VariableLocation.Local) { objectToRecord = KickStarter.localVariables; } if (location == VariableLocation.Component) { objectToRecord = _variables; } VariablesManager.ShowPopUpLabelsGUI(this, canEdit, objectToRecord); if (GetNumPopUpValues() > 0) { string[] popUpLabels = GenerateEditorPopUpLabels(); val = CustomGUILayout.Popup(labelPrefix, val, popUpLabels, apiPrefix + ".IntegerValue", helpText); } else { val = 0; } if (popUpID > 0) { if (Application.isPlaying && canTranslate) { EditorGUILayout.LabelField("Values can be translated"); } } else { if (canEdit) { canTranslate = CustomGUILayout.Toggle("Values can be translated?", canTranslate, apiPrefix + ".canTranslate", "If True, the variable's value can be translated"); } else if (canTranslate) { EditorGUILayout.LabelField("Values can be translated"); } } break; case VariableType.String: EditorGUILayout.BeginHorizontal(); CustomGUILayout.LabelField(labelPrefix, GUILayout.Width(140f), apiPrefix + ".TextValue"); EditorStyles.textField.wordWrap = true; textVal = CustomGUILayout.TextArea(textVal, GUILayout.MaxWidth(800f), apiPrefix + ".TextValue"); EditorGUILayout.EndHorizontal(); if (canEdit) { canTranslate = CustomGUILayout.Toggle("Values can be translated?", canTranslate, apiPrefix + ".canTranslate", "If True, the variable's value can be translated"); } else if (canTranslate) { EditorGUILayout.LabelField("Values can be translated"); } break; case VariableType.Vector3: vector3Val = CustomGUILayout.Vector3Field(labelPrefix, vector3Val, apiPrefix + ".Vector3Value", helpText); break; } switch (location) { case VariableLocation.Global: CustomGUILayout.TokenLabel("[var:" + id.ToString() + "]"); break; case VariableLocation.Local: CustomGUILayout.TokenLabel("[localvar:" + id.ToString() + "]"); break; case VariableLocation.Component: if (_variables != null) { ConstantID _constantID = _variables.GetComponent <ConstantID> (); if (_constantID != null && _constantID.constantID != 0) { CustomGUILayout.TokenLabel("[compvar:" + _constantID.constantID.ToString() + ":" + id.ToString() + "]"); } } break; } if (_varPresets != null) { EditorGUILayout.Space(); foreach (VarPreset _varPreset in _varPresets) { // Local string apiPrefix2 = (location == VariableLocation.Local) ? "AC.KickStarter.localVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + id + ")" : "AC.KickStarter.runtimeVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + id + ")"; _varPreset.UpdateCollection(this); string label = "'" + (!string.IsNullOrEmpty(_varPreset.label) ? _varPreset.label : ("Preset #" + _varPreset.ID.ToString())) + "' value:"; PresetValue presetValue = _varPreset.GetPresetValue(this); switch (type) { case VariableType.Boolean: presetValue.val = CustomGUILayout.Popup(label, presetValue.val, boolType, apiPrefix2 + ".BooleanValue"); break; case VariableType.Float: presetValue.floatVal = CustomGUILayout.FloatField(label, presetValue.floatVal, apiPrefix2 + ".FloatValue"); break; case VariableType.Integer: presetValue.val = CustomGUILayout.IntField(label, presetValue.val, apiPrefix2 + ".IntegerValue"); break; case VariableType.PopUp: presetValue.val = CustomGUILayout.Popup(label, presetValue.val, popUps, apiPrefix2 + ".IntegerValue"); break; case VariableType.String: presetValue.textVal = CustomGUILayout.TextField(label, presetValue.textVal, apiPrefix2 + ".TextValue"); break; case VariableType.Vector3: presetValue.vector3Val = CustomGUILayout.Vector3Field(label, presetValue.vector3Val, apiPrefix2 + ".Vector3Value"); break; } } } EditorGUILayout.Space(); if (canEdit) { switch (location) { case VariableLocation.Local: link = VarLink.None; break; case VariableLocation.Global: case VariableLocation.Component: link = (VarLink)CustomGUILayout.EnumPopup("Link to:", link, apiPrefix + ".link", "What it links to"); if (link == VarLink.PlaymakerVariable) { if (PlayMakerIntegration.IsDefinePresent()) { if (location == VariableLocation.Global) { pmVar = CustomGUILayout.TextField("Playmaker Global Variable:", pmVar, apiPrefix + ".pmVar", "The name of the Playmaker variable to link to."); } else if (location == VariableLocation.Component) { if (_variables != null && PlayMakerIntegration.HasFSM(_variables.gameObject)) { pmVar = CustomGUILayout.TextField("Playmaker Local Variable:", pmVar, apiPrefix + ".pmVar", "The name of the Playmaker variable to link to. It is assumed to be placed on the same GameObject as this Variables component."); } else { EditorGUILayout.HelpBox("A Playmaker FSM component must be present on the Variables GameObject.", MessageType.Info); } } if (!string.IsNullOrEmpty(pmVar)) { updateLinkOnStart = CustomGUILayout.Toggle("Use PM for initial value?", updateLinkOnStart, apiPrefix + ".updateLinkOnStart", "If True, then Playmaker will be referred to for the initial value"); } } else { EditorGUILayout.HelpBox("The 'PlayMakerIsPresent' Scripting Define Symbol must be listed in the\nPlayer Settings. Please set it from Edit -> Project Settings -> Player", MessageType.Warning); } } else if (link == VarLink.OptionsData) { if (location == VariableLocation.Global) { EditorGUILayout.HelpBox("This Variable will be stored in PlayerPrefs, and not in saved game files.", MessageType.Info); } else { EditorGUILayout.HelpBox("Component variables cannot be linked to Options Data - use Global variables instead.", MessageType.Warning); } } else if (link == VarLink.CustomScript) { updateLinkOnStart = CustomGUILayout.Toggle("Script sets initial value?", updateLinkOnStart, apiPrefix + ".updateLinkOnStart", "If True, then a custom script will be referred to for the initial value"); EditorGUILayout.HelpBox("See the Manual's 'Global variable linking' chapter for details on how to synchronise values.", MessageType.Info); } break; } } else { if (link != VarLink.None) { EditorGUILayout.LabelField("Links to: " + link.ToString()); if (link == VarLink.PlaymakerVariable && !string.IsNullOrEmpty(pmVar)) { EditorGUILayout.LabelField("Linked PM variable: " + pmVar); } if (link == VarLink.PlaymakerVariable || link == VarLink.CustomScript) { if (updateLinkOnStart) { EditorGUILayout.LabelField("Script sets initial value"); } } } } if (canEdit) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Internal description:", "An Editor-only description to aid designers"), GUILayout.MaxWidth(146f)); description = EditorGUILayout.TextArea(description); EditorGUILayout.EndHorizontal(); } else { if (!string.IsNullOrEmpty(description)) { EditorGUILayout.LabelField("Internal description: " + description); } } }
private void ShowVarGUI(VariableLocation location, List <VarPreset> _varPresets = null, string apiPrefix = "") { EditorGUILayout.BeginVertical(CustomStyles.thinBox); showVariablesProperties = CustomGUILayout.ToggleHeader(showVariablesProperties, location + " variable '" + selectedVar.label + "' properties"); if (showVariablesProperties) { selectedVar.label = CustomGUILayout.TextField("Label:", selectedVar.label, apiPrefix + ".label"); selectedVar.type = (VariableType)CustomGUILayout.EnumPopup("Type:", selectedVar.type, apiPrefix + ".type"); if (location == VariableLocation.Local) { //EditorGUILayout.LabelField ("Replacement token:", "[localvar:" + selectedVar.id.ToString () + "]"); CustomGUILayout.TokenLabel("[localvar:" + selectedVar.id.ToString() + "]"); } else { //EditorGUILayout.LabelField ("Replacement token:", "[var:" + selectedVar.id.ToString () + "]"); CustomGUILayout.TokenLabel("[var:" + selectedVar.id.ToString() + "]"); } if (selectedVar.type == VariableType.Boolean) { if (selectedVar.val != 1) { selectedVar.val = 0; } selectedVar.val = CustomGUILayout.Popup("Initial value:", selectedVar.val, boolType, apiPrefix + ".val"); } else if (selectedVar.type == VariableType.Integer) { selectedVar.val = CustomGUILayout.IntField("Initial value:", selectedVar.val, apiPrefix + ".val"); } else if (selectedVar.type == VariableType.PopUp) { selectedVar.popUps = PopupsGUI(selectedVar.popUps); selectedVar.val = CustomGUILayout.Popup("Initial value:", selectedVar.val, selectedVar.popUps, apiPrefix + ".val"); selectedVar.canTranslate = CustomGUILayout.Toggle("Values can be translated?", selectedVar.canTranslate, apiPrefix + ".canTranslate"); } else if (selectedVar.type == VariableType.String) { selectedVar.textVal = CustomGUILayout.TextField("Initial value:", selectedVar.textVal, apiPrefix + ".textVal"); selectedVar.canTranslate = CustomGUILayout.Toggle("Values can be translated?", selectedVar.canTranslate, apiPrefix + ".canTranslate"); } else if (selectedVar.type == VariableType.Float) { selectedVar.floatVal = CustomGUILayout.FloatField("Initial value:", selectedVar.floatVal, apiPrefix + ".floatVal"); } else if (selectedVar.type == VariableType.Vector3) { selectedVar.vector3Val = CustomGUILayout.Vector3Field("Initial value:", selectedVar.vector3Val, apiPrefix + ".vector3Val"); } if (_varPresets != null) { foreach (VarPreset _varPreset in _varPresets) { // Local string apiPrefix2 = (location == VariableLocation.Local) ? "AC.KickStarter.localVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + selectedVar.id + ")" : "AC.KickStarter.runtimeVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + selectedVar.id + ")"; _varPreset.UpdateCollection(selectedVar); string label = "'" + _varPreset.label + "' value:"; PresetValue presetValue = _varPreset.GetPresetValue(selectedVar); if (selectedVar.type == VariableType.Boolean) { presetValue.val = CustomGUILayout.Popup(label, presetValue.val, boolType, apiPrefix2 + ".val"); } else if (selectedVar.type == VariableType.Integer) { presetValue.val = CustomGUILayout.IntField(label, presetValue.val, apiPrefix2 + ".val"); } else if (selectedVar.type == VariableType.PopUp) { presetValue.val = CustomGUILayout.Popup(label, presetValue.val, selectedVar.popUps, apiPrefix2 + ".val"); } else if (selectedVar.type == VariableType.String) { presetValue.textVal = CustomGUILayout.TextField(label, presetValue.textVal, apiPrefix2 + ".textVal"); } else if (selectedVar.type == VariableType.Float) { presetValue.floatVal = CustomGUILayout.FloatField(label, presetValue.floatVal, apiPrefix2 + ".floatVal"); } else if (selectedVar.type == VariableType.Vector3) { presetValue.vector3Val = CustomGUILayout.Vector3Field(label, presetValue.vector3Val, apiPrefix2 + ".vector3Val"); } } } if (location == VariableLocation.Local) { selectedVar.link = VarLink.None; } else { EditorGUILayout.Space(); selectedVar.link = (VarLink)CustomGUILayout.EnumPopup("Link to:", selectedVar.link, apiPrefix + ".link"); if (selectedVar.link == VarLink.PlaymakerGlobalVariable) { if (PlayMakerIntegration.IsDefinePresent()) { selectedVar.pmVar = CustomGUILayout.TextField("Playmaker Global Variable:", selectedVar.pmVar, apiPrefix + ".pmVar"); selectedVar.updateLinkOnStart = CustomGUILayout.Toggle("Use PM for initial value?", selectedVar.updateLinkOnStart, apiPrefix + ".updateLinkOnStart"); } else { EditorGUILayout.HelpBox("The 'PlayMakerIsPresent' Scripting Define Symbol must be listed in the\nPlayer Settings. Please set it from Edit -> Project Settings -> Player", MessageType.Warning); } } else if (selectedVar.link == VarLink.OptionsData) { EditorGUILayout.HelpBox("This Variable will be stored in PlayerPrefs, and not in saved game files.", MessageType.Info); } } } EditorGUILayout.EndVertical(); }
public void ShowGUI(string apiPrefix, List <InvBin> bins) { title = CustomGUILayout.TextField("Title:", title, apiPrefix + ".title"); if (titleLineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", titleLineID.ToString()); } texture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> ("Texture:", texture, false, apiPrefix + ".texture", "A Texture2D associated with the Document"); carryOnStart = CustomGUILayout.Toggle("Carry on start?", carryOnStart, apiPrefix + ".carryOnStart", "If True, the Document will be in the Player's collection when the game begins"); rememberLastOpenPage = CustomGUILayout.Toggle("Remember last-open page?", rememberLastOpenPage, ".rememberLastOpenPage", "If True, the Document will be re-opened at the same page that it was closed at"); // if (bins.Count > 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Category:", "The category that the document belongs to"), GUILayout.Width(146f)); int binNumber = GetBinSlot(bins, binID); List <string> binList = new List <string>(); foreach (InvBin bin in bins) { binList.Add(bin.EditorLabel); } binNumber = CustomGUILayout.Popup(binNumber, binList.ToArray(), apiPrefix + ".binID"); binID = bins[binNumber].id; EditorGUILayout.EndHorizontal(); } // EditorGUILayout.Space(); EditorGUILayout.LabelField("Document pages:"); if (pages == null || pages.Count == 0) { pages.Clear(); pages.Add(new JournalPage()); } scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(pages.Count * 21, 185f) + 5)); for (int i = 0; i < pages.Count; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Toggle(selectedPage == i, "Page #" + i.ToString(), "Button")) { if (selectedPage != i) { selectedPage = i; EditorGUIUtility.editingTextField = false; } } if (GUILayout.Button("", CustomStyles.IconCog)) { sidePage = i; EditorGUIUtility.editingTextField = false; SidePageMenu(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Create new page")) { Undo.RecordObject(KickStarter.inventoryManager, "Add Document page"); pages.Add(new JournalPage()); if (pages.Count == 1) { selectedPage = 0; EditorGUIUtility.editingTextField = false; } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); if (selectedPage >= 0 && pages.Count > selectedPage) { EditorGUILayout.BeginVertical("Button"); showPageGUI = CustomGUILayout.ToggleHeader(showPageGUI, "Document page #" + selectedPage); if (showPageGUI) { CustomGUILayout.LabelField("Page text:", apiPrefix + ".pages[" + selectedPage + "].text"); EditorStyles.textField.wordWrap = true; pages[selectedPage].text = EditorGUILayout.TextArea(pages[selectedPage].text, GUILayout.MaxWidth(400f)); } EditorGUILayout.EndVertical(); } }
protected void SharedGUI (DragBase _target, bool isOnHinge) { CustomGUILayout.BeginVertical (); EditorGUILayout.LabelField ("Collision settings:", EditorStyles.boldLabel); _target.ignorePlayerCollider = CustomGUILayout.ToggleLeft ("Ignore Player's collider?", _target.ignorePlayerCollider, "", "If True, then the Physics system will ignore collisions between this object and the player"); _target.ignoreMoveableRigidbodies = CustomGUILayout.ToggleLeft ("Ignore Moveable Rigidbodies?", _target.ignoreMoveableRigidbodies, "", " If True, then the Physics system will ignore collisions between this object and the bounday colliders of any DragTrack that this is not locked to"); _target.childrenShareLayer = CustomGUILayout.ToggleLeft ("Place children on same layer?", _target.childrenShareLayer, "", "If True, then this object's children will be placed on the same layer"); EditorGUILayout.BeginHorizontal (); _target.interactiveBoundary = (InteractiveBoundary) CustomGUILayout.ObjectField <InteractiveBoundary> ("Interactive boundary:", _target.interactiveBoundary, true, "", "If assigned, then the draggable will only be interactive when the player is within this Trigger Collider's boundary"); if (_target.interactiveBoundary == null) { if (GUILayout.Button ("Create", GUILayout.MaxWidth (90f))) { string prefabName = "InteractiveBoundary"; if (SceneSettings.IsUnity2D ()) { prefabName += "2D"; } InteractiveBoundary newInteractiveBoundary = SceneManager.AddPrefab ("Logic", prefabName, true, false, true).GetComponent <InteractiveBoundary>(); newInteractiveBoundary.gameObject.name += (": " + _target.gameObject.name); newInteractiveBoundary.transform.position = _target.transform.position; _target.interactiveBoundary = newInteractiveBoundary; UnityVersionHandler.PutInFolder (newInteractiveBoundary.gameObject, "_Hotspots"); } } EditorGUILayout.EndHorizontal (); _target.limitToCamera = (_Camera) CustomGUILayout.ObjectField <_Camera> ("Limit to camera:", _target.limitToCamera, true, "", "If assigned, then the draggable will only be interactive when the assigned _Camera is active"); CustomGUILayout.EndVertical (); CustomGUILayout.BeginVertical (); EditorGUILayout.LabelField ("Icon settings:", EditorStyles.boldLabel); _target.showIcon = CustomGUILayout.Toggle ("Icon at contact point?", _target.showIcon, "", "If True, then an icon will be displayed at the 'grab point' when the object is held"); if (_target.showIcon) { if (cursorManager && cursorManager.cursorIcons.Count > 0) { int cursorInt = cursorManager.GetIntFromID (_target.iconID); cursorInt = CustomGUILayout.Popup ("Cursor icon:", cursorInt, cursorManager.GetLabelsArray (), "", "The cursor that gets shown when held"); _target.iconID = cursorManager.cursorIcons [cursorInt].id; } else { _target.iconID = -1; } } CustomGUILayout.EndVertical (); CustomGUILayout.BeginVertical (); EditorGUILayout.LabelField ("Sound settings:", EditorStyles.boldLabel); _target.moveSoundClip = (AudioClip) CustomGUILayout.ObjectField <AudioClip> ("Move sound:", _target.moveSoundClip, false, "", "The sound to play when the object is moved"); _target.slideSoundThreshold = CustomGUILayout.FloatField ("Min. move speed:", _target.slideSoundThreshold, "", "The minimum speed that the object must be moving by for sound to play"); _target.slidePitchFactor = CustomGUILayout.FloatField ("Pitch factor:", _target.slidePitchFactor, "", "The factor by which the movement sound's pitch is adjusted in relation to speed"); _target.collideSoundClip = (AudioClip) CustomGUILayout.ObjectField <AudioClip> ("Collide sound:", _target.collideSoundClip, false, "", "The sound to play when the object has a collision"); if (isOnHinge) { _target.onlyPlayLowerCollisionSound = CustomGUILayout.Toggle ("Only on lower boundary?", _target.onlyPlayLowerCollisionSound, "", "If True, then the collision sound will only play when the object collides with its lower boundary collider"); } CustomGUILayout.EndVertical (); }
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); } } }
public static void PropertiesGUI(AC_Trigger _target) { string[] Options = { "On enter", "Continuous", "On exit" }; if (Application.isPlaying) { if (!_target.IsOn()) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.source, string.Empty, "Where the Actions are stored"); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList asset:", _target.assetFile, false, string.Empty, "The ActionList asset that stores the Actions"); _target.syncParamValues = CustomGUILayout.Toggle("Sync parameter values?", _target.syncParamValues, string.Empty, "If True, the ActionList asset's parameter values will be shared amongst all linked ActionLists"); } _target.actionListType = (ActionListType)CustomGUILayout.EnumPopup("When running:", _target.actionListType, string.Empty, "The effect that running the Actions has on the rest of the game"); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = CustomGUILayout.Toggle("Is skippable?", _target.isSkippable, string.Empty, "If True, the Actions will be skipped when the user presses the 'EndCutscene' Input button"); } _target.triggerType = CustomGUILayout.Popup("Trigger type:", _target.triggerType, Options, string.Empty, "What kind of contact the Trigger reacts to"); _target.triggerReacts = (TriggerReacts)CustomGUILayout.EnumPopup("Reacts:", _target.triggerReacts, string.Empty, "The state of the game under which the trigger reacts"); _target.cancelInteractions = CustomGUILayout.Toggle("Cancels interactions?", _target.cancelInteractions, string.Empty, "If True, and the Player sets off the Trigger while walking towards a Hotspot Interaction, then the Player will stop and the Interaction will be cancelled"); _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID); if (_target.source == ActionListSource.InScene) { _target.useParameters = CustomGUILayout.Toggle("Set collider as parameter?", _target.useParameters, string.Empty, "If True, the colliding object will be provided as a GameObject parameter"); if (_target.useParameters) { EditorGUILayout.HelpBox("A GameObject parameter will be automatically defined by the Trigger.", MessageType.Info); } } else if (_target.source == ActionListSource.AssetFile && _target.assetFile != null && _target.assetFile.NumParameters > 0) { _target.gameObjectParameterID = Action.ChooseParameterGUI("Collider parameter:", _target.assetFile.DefaultParameters, _target.gameObjectParameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically set as the colliding object when run."); } _target.detectionMethod = (TriggerDetectionMethod)CustomGUILayout.EnumPopup("Detection method:", _target.detectionMethod, string.Empty, "How this Trigger detects objects. If 'Rigidbody Collider', then it requires that incoming objects have a Rigidbody and a Collider - and it will rely on collisions. If 'Point Based', it will check an incoming object's root position for whether it is within the Trigger's collider boundary."); EditorGUILayout.Space(); if (_target.detectionMethod == TriggerDetectionMethod.RigidbodyCollision) { _target.detects = (TriggerDetects)CustomGUILayout.EnumPopup("Trigger detects:", _target.detects, string.Empty, "What the Trigger will react to"); switch (_target.detects) { case TriggerDetects.AnyObjectWithComponent: _target.detectComponent = CustomGUILayout.TextField("Component name:", _target.detectComponent, string.Empty, "The component that must be attached to an object for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple component names should be separated by a colon ';'", MessageType.Info); break; case TriggerDetects.AnyObjectWithTag: _target.detectComponent = CustomGUILayout.TextField("Tag name:", _target.detectComponent, string.Empty, "The tag that an object must have for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple tags should be separated by a colon ';'", MessageType.Info); break; case TriggerDetects.SetObject: _target.obToDetect = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object to detect:", _target.obToDetect, true, string.Empty, "The GameObject that the Trigger reacts to"); break; case TriggerDetects.Player: if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow) { EditorGUILayout.HelpBox("Only the active Player will be detected. To detect all Players, set the 'Detection method' to 'Component name'", MessageType.Info); } break; default: break; } } else if (_target.detectionMethod == TriggerDetectionMethod.TransformPosition) { if (KickStarter.settingsManager == null || KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow) { _target.detectsPlayer = CustomGUILayout.Toggle("Detect Player?", _target.detectsPlayer); } else { _target.detectsPlayer = CustomGUILayout.Toggle("Detect active Player?", _target.detectsPlayer); if (_target.detectsPlayer) { _target.detectsAllPlayers = CustomGUILayout.Toggle("Detect inactive Players?", _target.detectsAllPlayers); } } if (_target.obsToDetect == null) { _target.obsToDetect = new List <GameObject>(); } int numObs = _target.obsToDetect.Count; int newNumObs = EditorGUILayout.DelayedIntField("# " + ((_target.detectsPlayer) ? "other " : string.Empty) + "objects to detect:", numObs); if (newNumObs < 0) { newNumObs = 0; } if (newNumObs != numObs) { _target.obsToDetect = ResizeList(_target.obsToDetect, newNumObs); } for (int i = 0; i < _target.obsToDetect.Count; i++) { _target.obsToDetect[i] = (GameObject)EditorGUILayout.ObjectField("Object #" + i + ":", _target.obsToDetect[i], typeof(GameObject), true); } } CustomGUILayout.EndVertical(); if (_target.source == ActionListSource.InScene && _target.useParameters) { if (_target.parameters.Count < 1) { ActionParameter newParameter = new ActionParameter(0); newParameter.parameterType = ParameterType.GameObject; newParameter.label = "Collision object"; _target.parameters.Clear(); _target.parameters.Add(newParameter); } } }
private void InvInteractionGUI() { EditorGUILayout.BeginVertical("Button"); 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 = ""; 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 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>() != null) { invButton.selectItemMode = (SelectItemMode)EditorGUILayout.EnumPopup(invButton.selectItemMode, GUILayout.Width(70f)); } } if (GUILayout.Button("", CustomStyles.IconCog)) { SideMenu("Inv", _target.invButtons.Count, _target.invButtons.IndexOf(invButton)); } EditorGUILayout.EndHorizontal(); if (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); } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } } 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."); } } EditorGUILayout.EndVertical(); }
public static void PropertiesGUI(AC_Trigger _target) { string[] Options = { "On enter", "Continuous", "On exit" }; if (Application.isPlaying) { if (!_target.IsOn()) { EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info); } } EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Trigger properties", EditorStyles.boldLabel); _target.source = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.source, "", "Where the Actions are stored"); if (_target.source == ActionListSource.AssetFile) { _target.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList asset:", _target.assetFile, false, "", "The ActionList asset that stores the Actions"); _target.syncParamValues = CustomGUILayout.Toggle("Sync parameter values?", _target.syncParamValues, "", "If True, the ActionList asset's parameter values will be shared amongst all linked ActionLists"); } _target.actionListType = (ActionListType)CustomGUILayout.EnumPopup("When running:", _target.actionListType, "", "The effect that running the Actions has on the rest of the game"); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = CustomGUILayout.Toggle("Is skippable?", _target.isSkippable, "", "If True, the Actions will be skipped when the user presses the 'EndCutscene' Input button"); } _target.triggerType = CustomGUILayout.Popup("Trigger type:", _target.triggerType, Options, "", "What kind of contact the Trigger reacts to"); _target.triggerReacts = (TriggerReacts)CustomGUILayout.EnumPopup("Reacts:", _target.triggerReacts, "", "The state of the game under which the trigger reacts"); _target.cancelInteractions = CustomGUILayout.Toggle("Cancels interactions?", _target.cancelInteractions, "", "If True, and the Player sets off the Trigger while walking towards a Hotspot Interaction, then the Player will stop and the Interaction will be cancelled"); _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID); _target.useParameters = CustomGUILayout.Toggle("Set collider as parameter?", _target.useParameters, "", "If True, the colliding object will be provided as a GameObject parameter"); EditorGUILayout.Space(); _target.detects = (TriggerDetects)CustomGUILayout.EnumPopup("Trigger detects:", _target.detects, "", "What the Trigger will react to"); if (_target.detects == TriggerDetects.AnyObjectWithComponent) { _target.detectComponent = CustomGUILayout.TextField("Component name:", _target.detectComponent, "", "The component that must be attached to an object for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple component names should be separated by a colon ';'", MessageType.Info); } else if (_target.detects == TriggerDetects.AnyObjectWithTag) { _target.detectComponent = CustomGUILayout.TextField("Tag name:", _target.detectComponent, "", "The tag that an object must have for the Trigger to react to"); EditorGUILayout.HelpBox("Multiple tags should be separated by a colon ';'", MessageType.Info); } else if (_target.detects == TriggerDetects.SetObject) { _target.obToDetect = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object to detect:", _target.obToDetect, true, "", "The GameObject that the Trigger reacts to"); } EditorGUILayout.EndVertical(); if (_target.useParameters) { if (_target.parameters.Count != 1) { ActionParameter newParameter = new ActionParameter(0); newParameter.parameterType = ParameterType.GameObject; newParameter.label = "Collision object"; _target.parameters.Clear(); _target.parameters.Add(newParameter); } } }