public static ActionListAsset AssetGUI(string label, ActionListAsset actionListAsset, string api = "", string defaultName = "") { EditorGUILayout.BeginHorizontal(); actionListAsset = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> (label, actionListAsset, false, api); if (actionListAsset == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\_]", ""); #else defaultName = ""; #endif if (defaultName != "") { actionListAsset = ActionListAssetMenu.CreateAsset(defaultName); } else { actionListAsset = ActionListAssetMenu.CreateAsset(); } } } EditorGUILayout.EndHorizontal(); return(actionListAsset); }
public static ActionListAsset AssetGUI(string label, ActionListAsset actionListAsset, string api = "") { EditorGUILayout.BeginHorizontal(); actionListAsset = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> (label, actionListAsset, false, api); if (actionListAsset == null) { if (GUILayout.Button("Create", GUILayout.MaxWidth(60f))) { actionListAsset = ActionListAssetMenu.CreateAsset(); } } EditorGUILayout.EndHorizontal(); return(actionListAsset); }
private void ButtonGUI(Button button, string suffix, InteractionSource source, bool isForInventory = false) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { EditorGUILayout.BeginHorizontal(); button.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", button.assetFile, false, "", "The ActionList asset to run"); if (button.assetFile == null) { if (GUILayout.Button("Create", autoWidth)) { string defaultName = GenerateInteractionName(suffix, true); #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\._]", ""); #else defaultName = ""; #endif button.assetFile = ActionListAssetMenu.CreateAsset(defaultName); } } else if (GUILayout.Button("", CustomStyles.IconNodes)) { ActionListEditorWindow.Init(button.assetFile); } EditorGUILayout.EndHorizontal(); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.assetFile.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", button.customScriptObject, true, "", "The GameObject with the custom script to run"); button.customScriptFunction = CustomGUILayout.TextField("Message to send:", button.customScriptFunction, "", "The name of the function to run"); if (isForInventory) { EditorGUILayout.HelpBox("If the receiving function has an integer parameter, the Inventory item's ID will be passed to it.", MessageType.Info); } } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)CustomGUILayout.ObjectField <Interaction> ("Interaction:", button.interaction, true, "", "The Interaction ActionList to run"); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = GenerateInteractionName(suffix, false); button.interaction = newInteraction; } } else { if (GUILayout.Button("", CustomStyles.IconNodes)) { ActionListEditorWindow.Init(button.interaction); } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.source == ActionListSource.InScene && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.interaction.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } else if (button.interaction != null && button.interaction.source == ActionListSource.AssetFile && button.interaction.assetFile != null && button.interaction.assetFile.useParameters && button.interaction.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.assetFile.parameters, button.parameterID, ParameterType.GameObject, -1, "The GameObject parameter to automatically assign as this Hotspot"); EditorGUILayout.EndHorizontal(); if (isForInventory) { button.invParameterID = Action.ChooseParameterGUI("Inventory item parameter:", button.interaction.assetFile.parameters, button.invParameterID, ParameterType.InventoryItem, -1, "The Inventory Item parameter to automatically assign as the used item"); } } } button.playerAction = (PlayerAction)CustomGUILayout.EnumPopup("Player action:", button.playerAction, "", "What the Player prefab does after clicking the Hotspot, but before the Interaction itself is run"); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = CustomGUILayout.Toggle("Cutscene while moving?", button.isBlocking, "", "If True, then gameplay will be blocked while the Player moves"); button.faceAfter = CustomGUILayout.Toggle("Face after moving?", button.faceAfter, "", "If True, then the Player will face the Hotspot after reaching the Marker"); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = CustomGUILayout.Toggle("Set minimum distance?", button.setProximity, "", "If True, then the Interaction will be run once the Player is within a certain distance of the Hotspot"); if (button.setProximity) { button.proximity = CustomGUILayout.FloatField("Proximity:", button.proximity, "", "The proximity the Player must be within"); } } } }
private void ButtonGUI(Button button, string suffix, InteractionSource source, bool isForInventory = false) { bool isEnabled = !button.isDisabled; isEnabled = EditorGUILayout.Toggle("Enabled:", isEnabled); button.isDisabled = !isEnabled; if (source == InteractionSource.AssetFile) { EditorGUILayout.BeginHorizontal(); button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false); if (button.assetFile == null) { if (GUILayout.Button("Create", autoWidth)) { string defaultName = GenerateInteractionName(suffix); #if !(UNITY_WP8 || UNITY_WINRT) defaultName = System.Text.RegularExpressions.Regex.Replace(defaultName, "[^\\w\\_]", ""); #else defaultName = ""; #endif button.assetFile = ActionListAssetMenu.CreateAsset(defaultName); } } else if (GUILayout.Button("", Resource.NodeSkin.customStyles[13], GUILayout.Width(20f))) { ActionListEditorWindow.Init(button.assetFile); } EditorGUILayout.EndHorizontal(); if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); if (button.parameterID >= 0 && _target.GetComponent <ConstantID>() == null) { EditorGUILayout.HelpBox("A Constant ID component must be added to the Hotspot in order for it to be passed as a parameter.", MessageType.Warning); } } } else if (source == InteractionSource.CustomScript) { button.customScriptObject = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true); button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction); if (isForInventory) { EditorGUILayout.HelpBox("If the receiving function has an integer parameter, the Inventory item's ID will be passed to it.", MessageType.Info); } } else if (source == InteractionSource.InScene) { EditorGUILayout.BeginHorizontal(); button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true); if (button.interaction == null) { if (GUILayout.Button("Create", autoWidth)) { Undo.RecordObject(_target, "Create Interaction"); Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>(); newInteraction.gameObject.name = GenerateInteractionName(suffix); button.interaction = newInteraction; } } else { if (GUILayout.Button("", Resource.NodeSkin.customStyles[13], GUILayout.Width(20f))) { ActionListEditorWindow.Init(button.interaction); } } EditorGUILayout.EndHorizontal(); if (button.interaction != null && button.interaction.useParameters && button.interaction.parameters.Count > 0) { EditorGUILayout.BeginHorizontal(); button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject); EditorGUILayout.EndHorizontal(); } } button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction); if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker) { if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null) { EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning); } button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking); button.faceAfter = EditorGUILayout.Toggle("Face after moving?", button.faceAfter); if (button.playerAction == PlayerAction.WalkTo) { button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity); if (button.setProximity) { button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity); } } } }