private int GetIconID(string label, int iconID, CursorManager cursorManager) { int iconInt = cursorManager.GetIntFromID(iconID); iconInt = EditorGUILayout.Popup(label, iconInt, cursorManager.GetLabelsArray(iconInt)); iconID = cursorManager.cursorIcons[iconInt].id; return(iconID); }
protected void ChangeCursorGUI(MenuSource source) { changeCursor = EditorGUILayout.Toggle("Change cursor when over?", changeCursor); if (changeCursor) { CursorManager cursorManager = AdvGame.GetReferences().cursorManager; if (cursorManager != null) { int cursorIndex = cursorManager.GetIntFromID(cursorID); cursorIndex = EditorGUILayout.Popup("Cursor ID:", cursorIndex, cursorManager.GetLabelsArray()); cursorID = cursorManager.cursorIcons[cursorIndex].id; } else { EditorGUILayout.HelpBox("No Cursor Manager found!", MessageType.Warning); } } }
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); } } }
protected void SharedGUI(DragBase _target, bool isOnHinge) { EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Collision settings:", EditorStyles.boldLabel); _target.ignorePlayerCollider = EditorGUILayout.ToggleLeft("Ignore Player's collider?", _target.ignorePlayerCollider); _target.ignoreMoveableRigidbodies = EditorGUILayout.ToggleLeft("Ignore Moveable Rigidbodies?", _target.ignoreMoveableRigidbodies); _target.childrenShareLayer = EditorGUILayout.ToggleLeft("Place children on same layer?", _target.childrenShareLayer); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Icon settings:", EditorStyles.boldLabel); _target.showIcon = EditorGUILayout.Toggle("Icon at contact point?", _target.showIcon); if (_target.showIcon) { if (cursorManager && cursorManager.cursorIcons.Count > 0) { int cursorInt = cursorManager.GetIntFromID(_target.iconID); cursorInt = EditorGUILayout.Popup("Cursor icon:", cursorInt, cursorManager.GetLabelsArray()); _target.iconID = cursorManager.cursorIcons [cursorInt].id; } else { _target.iconID = -1; } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); EditorGUILayout.LabelField("Sound settings:", EditorStyles.boldLabel); _target.moveSoundClip = (AudioClip)EditorGUILayout.ObjectField("Move sound:", _target.moveSoundClip, typeof(AudioClip), false); _target.slideSoundThreshold = EditorGUILayout.FloatField("Min. move speed:", _target.slideSoundThreshold); _target.slidePitchFactor = EditorGUILayout.FloatField("Pitch factor:", _target.slidePitchFactor); _target.collideSoundClip = (AudioClip)EditorGUILayout.ObjectField("Collide sound:", _target.collideSoundClip, typeof(AudioClip), false); if (isOnHinge) { _target.onlyPlayLowerCollisionSound = EditorGUILayout.Toggle("Only on lower boundary?", _target.onlyPlayLowerCollisionSound); } 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 GetCursorGUI () { if (AdvGame.GetReferences ().cursorManager) { cursorManager = AdvGame.GetReferences ().cursorManager; if (cursorManager.cursorIcons.Count > 0) { int iconInt = cursorManager.GetIntFromID (iconID); iconInt = EditorGUILayout.Popup ("Cursor:", iconInt, cursorManager.GetLabelsArray (iconInt)); iconID = cursorManager.cursorIcons [iconInt].id; } else { iconID = -1; } } }
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 (); }
private int GetIconID(string label, int iconID, CursorManager cursorManager) { int iconInt = cursorManager.GetIntFromID (iconID); iconInt = EditorGUILayout.Popup (label, iconInt, cursorManager.GetLabelsArray (iconInt)); iconID = cursorManager.cursorIcons[iconInt].id; return iconID; }
private void ItemsGUI() { EditorGUILayout.LabelField("Unhandled events", EditorStyles.boldLabel); unhandledCombine = ActionListAssetMenu.AssetGUI("Combine:", unhandledCombine); unhandledHotspot = ActionListAssetMenu.AssetGUI("Use on hotspot:", unhandledHotspot); if (settingsManager != null && settingsManager.CanGiveItems()) { unhandledGive = ActionListAssetMenu.AssetGUI("Give to NPC:", unhandledGive); } List <string> binList = new List <string>(); foreach (InvBin bin in bins) { binList.Add(bin.label); } EditorGUILayout.Space(); CreateItemsGUI(binList.ToArray()); EditorGUILayout.Space(); if (selectedItem != null && items.Contains(selectedItem)) { EditorGUILayout.LabelField("Inventory item '" + selectedItem.label + "' properties", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("Button"); selectedItem.label = EditorGUILayout.TextField("Name:", selectedItem.label); selectedItem.altLabel = EditorGUILayout.TextField("Label (if not name):", selectedItem.altLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Category:", GUILayout.Width(146f)); if (bins.Count > 0) { binNumber = GetBinSlot(selectedItem.binID); binNumber = EditorGUILayout.Popup(binNumber, binList.ToArray()); selectedItem.binID = bins[binNumber].id; } else { selectedItem.binID = -1; EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f)); } EditorGUILayout.EndHorizontal(); selectedItem.tex = (Texture2D)EditorGUILayout.ObjectField("Texture:", selectedItem.tex, typeof(Texture2D), false); if (settingsManager && (settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot || (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && settingsManager.inventoryInteractions == InventoryInteractions.Single))) { selectedItem.activeTex = (Texture2D)EditorGUILayout.ObjectField("Active texture:", selectedItem.activeTex, typeof(Texture2D), false); } selectedItem.carryOnStart = EditorGUILayout.Toggle("Carry on start?", selectedItem.carryOnStart); if (selectedItem.carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory) { selectedItem.carryOnStartNotDefault = EditorGUILayout.Toggle("Give to non-default player?", selectedItem.carryOnStartNotDefault); if (selectedItem.carryOnStartNotDefault) { selectedItem.carryOnStartID = ChoosePlayerGUI(selectedItem.carryOnStartID); } } selectedItem.canCarryMultiple = EditorGUILayout.Toggle("Can carry multiple?", selectedItem.canCarryMultiple); if (selectedItem.canCarryMultiple) { selectedItem.useSeparateSlots = EditorGUILayout.Toggle("Place in separate slots?", selectedItem.useSeparateSlots); } if (selectedItem.carryOnStart && selectedItem.canCarryMultiple) { selectedItem.count = EditorGUILayout.IntField("Quantity on start:", selectedItem.count); } else { selectedItem.count = 1; } selectedItem.overrideUseSyntax = EditorGUILayout.Toggle("Override 'Use' syntax?", selectedItem.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(); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Standard interactions", EditorStyles.boldLabel); 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]; interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList); 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 { selectedItem.useActionList = ActionListAssetMenu.AssetGUI("Use:", selectedItem.useActionList); if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0) { int useCursor_int = cursorManager.GetIntFromID(selectedItem.useIconID); useCursor_int = EditorGUILayout.Popup("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray(useCursor_int)); selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int].id; } else { selectedItem.useIconID = 0; } selectedItem.lookActionList = ActionListAssetMenu.AssetGUI("Examine:", selectedItem.lookActionList); } if (settingsManager.CanSelectItems(false)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Unhandled interactions", EditorStyles.boldLabel); selectedItem.unhandledActionList = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", selectedItem.unhandledActionList); selectedItem.unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", selectedItem.unhandledCombineActionList); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Combine interactions", EditorStyles.boldLabel); 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; selectedItem.combineActionList[i] = ActionListAssetMenu.AssetGUI("", selectedItem.combineActionList[i]); 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); } EditorGUILayout.EndVertical(); } }
private void ItemsGUI() { EditorGUILayout.LabelField("Unhandled events", EditorStyles.boldLabel); unhandledCombine = ActionListAssetMenu.AssetGUI("Combine:", unhandledCombine); unhandledHotspot = ActionListAssetMenu.AssetGUI("Use on hotspot:", unhandledHotspot); if (settingsManager != null && settingsManager.CanGiveItems()) { unhandledGive = ActionListAssetMenu.AssetGUI("Give to NPC:", unhandledGive); } List <string> binList = new List <string>(); foreach (InvBin bin in bins) { binList.Add(bin.label); } EditorGUILayout.Space(); CreateItemsGUI(binList.ToArray()); EditorGUILayout.Space(); if (selectedItem != null && items.Contains(selectedItem)) { EditorGUILayout.LabelField("Inventory item '" + selectedItem.label + "' settings", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("Button"); selectedItem.label = EditorGUILayout.TextField("Name:", selectedItem.label); selectedItem.altLabel = EditorGUILayout.TextField("Label (if not name):", selectedItem.altLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Category:", GUILayout.Width(146f)); if (bins.Count > 0) { binNumber = GetBinSlot(selectedItem.binID); binNumber = EditorGUILayout.Popup(binNumber, binList.ToArray()); selectedItem.binID = bins[binNumber].id; } else { selectedItem.binID = -1; EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Main graphic:", GUILayout.Width(145)); selectedItem.tex = (Texture2D)EditorGUILayout.ObjectField(selectedItem.tex, typeof(Texture2D), false, GUILayout.Width(70), GUILayout.Height(70)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Active graphic:", GUILayout.Width(145)); selectedItem.activeTex = (Texture2D)EditorGUILayout.ObjectField(selectedItem.activeTex, typeof(Texture2D), false, GUILayout.Width(70), GUILayout.Height(70)); EditorGUILayout.EndHorizontal(); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.selectInventoryDisplay == SelectInventoryDisplay.ShowSelectedGraphic) { selectedItem.selectedTex = (Texture2D)EditorGUILayout.ObjectField("Selected graphic:", selectedItem.selectedTex, typeof(Texture2D), false); } 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, cursorManager.cursorRendering, "Cursor (optional):"); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } } selectedItem.carryOnStart = EditorGUILayout.Toggle("Carry on start?", selectedItem.carryOnStart); if (selectedItem.carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory) { selectedItem.carryOnStartNotDefault = EditorGUILayout.Toggle("Give to non-default player?", selectedItem.carryOnStartNotDefault); if (selectedItem.carryOnStartNotDefault) { selectedItem.carryOnStartID = ChoosePlayerGUI(selectedItem.carryOnStartID); } } selectedItem.canCarryMultiple = EditorGUILayout.Toggle("Can carry multiple?", selectedItem.canCarryMultiple); if (selectedItem.canCarryMultiple) { selectedItem.useSeparateSlots = EditorGUILayout.Toggle("Place in separate slots?", selectedItem.useSeparateSlots); } if (selectedItem.carryOnStart && selectedItem.canCarryMultiple) { selectedItem.count = EditorGUILayout.IntField("Quantity on start:", selectedItem.count); } else { selectedItem.count = 1; } selectedItem.overrideUseSyntax = EditorGUILayout.Toggle("Override 'Use' syntax?", selectedItem.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(); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Standard interactions", EditorStyles.boldLabel); 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]; interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList); 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 { selectedItem.useActionList = ActionListAssetMenu.AssetGUI("Use:", selectedItem.useActionList); if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0) { int useCursor_int = cursorManager.GetIntFromID(selectedItem.useIconID); useCursor_int = EditorGUILayout.Popup("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray()); selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int].id; } else { selectedItem.useIconID = 0; } selectedItem.lookActionList = ActionListAssetMenu.AssetGUI("Examine:", selectedItem.lookActionList); } if (settingsManager.CanSelectItems(false)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Unhandled interactions", EditorStyles.boldLabel); selectedItem.unhandledActionList = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", selectedItem.unhandledActionList); selectedItem.unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", selectedItem.unhandledCombineActionList); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Combine interactions", EditorStyles.boldLabel); 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; selectedItem.combineActionList[i] = ActionListAssetMenu.AssetGUI("", selectedItem.combineActionList[i]); 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", EditorStyles.boldLabel); 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 = EditorGUILayout.Popup(label, invVar.val, boolType); } else if (invVar.type == VariableType.Integer) { invVar.val = EditorGUILayout.IntField(label, invVar.val); } else if (invVar.type == VariableType.PopUp) { invVar.val = EditorGUILayout.Popup(label, invVar.val, invVar.popUps); } else if (invVar.type == VariableType.String) { invVar.textVal = EditorGUILayout.TextField(label, invVar.textVal); } else if (invVar.type == VariableType.Float) { invVar.floatVal = EditorGUILayout.FloatField(label, invVar.floatVal); } } } else { EditorGUILayout.HelpBox("No properties have been defined that this inventory item can use.", MessageType.Info); } } EditorGUILayout.EndVertical(); } }
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(); }