Beispiel #1
0
        private void EditOptionGUI(ButtonDialog option, InteractionSource source)
        {
            EditorGUILayout.BeginVertical("Button");

            if (option.lineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString());
            }

            option.label = EditorGUILayout.TextField("Label:", option.label);

            if (source == InteractionSource.AssetFile)
            {
                option.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", option.assetFile, typeof(ActionListAsset), false);
            }
            else if (source == InteractionSource.CustomScript)
            {
                option.customScriptObject   = (GameObject)EditorGUILayout.ObjectField("Object with script:", option.customScriptObject, typeof(GameObject), true);
                option.customScriptFunction = EditorGUILayout.TextField("Message to send:", option.customScriptFunction);
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                option.dialogueOption = (DialogueOption)EditorGUILayout.ObjectField("Interaction:", option.dialogueOption, typeof(DialogueOption), true);
                if (option.dialogueOption == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        Undo.RecordObject(_target, "Auto-create dialogue option");
                        DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                        newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option");
                        newDialogueOption.Initialise();
                        EditorUtility.SetDirty(newDialogueOption);
                        option.dialogueOption = newDialogueOption;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            option.cursorIcon.ShowGUI(false, true, "Icon texture:");

            option.isOn = EditorGUILayout.Toggle("Is enabled?", option.isOn);
            if (source == InteractionSource.CustomScript)
            {
                EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
            }
            else
            {
                option.conversationAction = (ConversationAction)EditorGUILayout.EnumPopup("When finished:", option.conversationAction);
                if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    option.newConversation = (Conversation)EditorGUILayout.ObjectField("Conversation to run:", option.newConversation, typeof(Conversation), true);
                }
            }

            option.linkToInventory = EditorGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory);
            if (option.linkToInventory)
            {
                option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID);
            }

            EditorGUILayout.EndVertical();
        }
Beispiel #2
0
		private void NodeWindow (int ID)
		{
			if (ID == -2)
			{
				GUILayout.Label (lastConversation.gameObject.name);
			}
			else if (ID == -1)
			{
				GUILayout.Label (conversation.gameObject.name);
			}
			else if (ID < conversation.options.Count)
			{
				GUILayout.BeginHorizontal ();
				conversation.options[ID].label = GUILayout.TextField (conversation.options[ID].label);
				if (GUILayout.Button ("-", GUILayout.Width (20f)))
				{
					Undo.RecordObject (this, "Delete dialogue option");
					
					foreach (ButtonDialog option in conversation.options)
					{
						option.isEditing = false;
					}
					conversation.selectedOption = null;
					conversation.options.RemoveAt (ID);
				}
				GUILayout.EndHorizontal ();
			}
			else if (ID < conversation.options.Count * 2)
			{
				int i = ID - conversation.options.Count;
				if (conversation.interactionSource == InteractionSource.AssetFile)
				{
					conversation.options[i].assetFile = (ActionListAsset) EditorGUILayout.ObjectField (conversation.options[i].assetFile, typeof (ActionListAsset), false);
				}
				else if (conversation.interactionSource == InteractionSource.CustomScript)
				{
					GUILayout.Label ("(Set in Inspector)");
				}
				else if (conversation.interactionSource == InteractionSource.InScene)
				{
					if (conversation.options[i].dialogueOption != null)
					{
						GUILayout.BeginHorizontal ();

						string label = conversation.options[i].dialogueOption.gameObject.name;
						if (label.Length > 22)
						{
							label = label.Substring (0,22);
						}

						if (GUILayout.Button (label))
						{
							if (conversation.interactionSource == InteractionSource.InScene)
							{
								Selection.activeGameObject = conversation.options[i].dialogueOption.gameObject;
							}
						}

						if (GUILayout.Button ("", Resource.NodeSkin.customStyles[13]))
						{
							if (conversation.interactionSource == InteractionSource.InScene)
							{
								ActionListEditorWindow.Init (conversation.options[i].dialogueOption);
							}
							else
							{
								ActionListEditorWindow.Init (conversation.options[i].dialogueOption.assetFile);
							}
						}
						GUILayout.EndHorizontal ();
					}
					else
					{
						GUILayout.BeginHorizontal ();
						GUILayout.Label ("(Not set)");
						if (GUILayout.Button ("Create"))
						{
							Undo.RecordObject (conversation, "Auto-create dialogue option");
							DialogueOption newDialogueOption = SceneManager.AddPrefab ("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();
							
							newDialogueOption.gameObject.name = AdvGame.UniqueName (conversation.gameObject.name + "_Option");
							newDialogueOption.Initialise ();
							EditorUtility.SetDirty (newDialogueOption);
							conversation.options[i].dialogueOption = newDialogueOption;
						}
						GUILayout.EndHorizontal ();
					}
				}
			}
			else if (ID < conversation.options.Count * 3)
			{
				int i = ID - (conversation.options.Count*2);
				conversation.options[i].conversationAction = (ConversationAction) EditorGUILayout.EnumPopup (conversation.options[i].conversationAction);
			}
			else
			{
				int i = ID - (conversation.options.Count*3);
				if (conversation.options[i].newConversation != null)
				{
					conversation.options[i].newConversation = (Conversation) EditorGUILayout.ObjectField (conversation.options[i].newConversation, typeof (Conversation), true);
				}
				else
				{
					GUILayout.BeginHorizontal ();
					conversation.options[i].newConversation = (Conversation) EditorGUILayout.ObjectField (conversation.options[i].newConversation, typeof (Conversation), true);

					if (GUILayout.Button ("Create"))
					{
						Undo.RecordObject (conversation, "Auto-create conversation");
						Conversation newConversation = SceneManager.AddPrefab ("Logic", "Conversation", true, false, true).GetComponent <Conversation>();
						conversation.options[i].newConversation = newConversation;
					}
					GUILayout.EndHorizontal ();
				}
			}
		}
        private void EditOptionGUI(ButtonDialog option, InteractionSource source)
        {
            CustomGUILayout.BeginVertical();

            if (option.lineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString());
            }

            option.label = CustomGUILayout.TextField("Label:", option.label, "", "The option's display label");

            if (source == InteractionSource.AssetFile)
            {
                option.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", option.assetFile, false, "", "The ActionListAsset to run");
            }
            else if (source == InteractionSource.CustomScript)
            {
                option.customScriptObject   = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", option.customScriptObject, true, "", "The GameObject with the custom script to run");
                option.customScriptFunction = CustomGUILayout.TextField("Message to send:", option.customScriptFunction, "", "The name of the function to run");
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                option.dialogueOption = (DialogueOption)CustomGUILayout.ObjectField <DialogueOption> ("DialogOption:", option.dialogueOption, true, "", "The DialogOption to run");
                if (option.dialogueOption == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        Undo.RecordObject(_target, "Auto-create dialogue option");
                        DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                        newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option");
                        newDialogueOption.Initialise();
                        EditorUtility.SetDirty(newDialogueOption);
                        option.dialogueOption = newDialogueOption;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            option.cursorIcon.ShowGUI(false, true, "Icon texture:", CursorRendering.Software, "", "The icon to display in DialogList menu elements");

            option.isOn = CustomGUILayout.Toggle("Is enabled?", option.isOn, "", "If True, the option is enabled, and will be displayed in a MenuDialogList element");
            if (source == InteractionSource.CustomScript)
            {
                EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
            }
            else
            {
                option.conversationAction = (ConversationAction)CustomGUILayout.EnumPopup("When finished:", option.conversationAction, "", "What happens when the DialogueOption ActionList has finished");
                if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    option.newConversation = (Conversation)CustomGUILayout.ObjectField <Conversation> ("Conversation to run:", option.newConversation, true, "", "The new Conversation to run");
                }
            }

            option.linkToInventory = CustomGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory, "", " If True, then the option will only be visible if a given inventory item is being carried");
            if (option.linkToInventory)
            {
                option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID);
            }

            CustomGUILayout.EndVertical();
        }