InControl with Dialogue Support

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
electricmonk
Posts: 2
Joined: Tue Apr 05, 2016 5:54 pm

InControl with Dialogue Support

Post by electricmonk »

Hi There,

First off, really liking this plugin so far. I've been looking at it for a while and using Love/Hate and finally bit. I'm impressed with the support and depth of functionality.

What I'm currently trying to do is integrate InControl (for using controllers) into the Dialogue system and although am having some luck, I was looking for feedback on what the best way to proceed might be.

What I've figured out so far is how to trigger a proximity selector by manually calling the "OnUse" Message in proximity trigger from a script I throw on the game object with it when the button is pressed.

eg.

Code: Select all

	dialogProximitySelector.CurrentUsable.gameObject.BroadcastMessage("OnUse", fromTransform, SendMessageOptions.DontRequireReceiver);
That seems a bit hacky but it works fine for now. The next thing I've been working on is making the UI Dialogue menu work with the controller. Since InControl will work fine with the new UI system, I could get an NPC conversation Continue button to work by setting it as the First Selected (Button) in the input manager. I know I can set the first focused with

Code: Select all

EventSystem.current.SetSelectedGameObject(yourObject); 
I'm not sure at this point whether I'm going about this the wrong way in manually overriding each feature I need. Should be extending a class or something that can handle everything I need from an input perspective (from InControl) and map it to the Dialog System? If I extend PixelCrushers.DialogueSystem.UnityUIDialogueControls will that work? Or is that just one part of the pie. I've been looking at the examples given and it seems like that is the way to go, I'm not really sure where to start however.

It seems like if I could set the Continue buttons / Player Response options to be focused then it might work out of the box (via the UI system) but I'm not sure if thats the best path forward. Can anyone give me some pointers on the best way to wrap this? It seems like a relatively common problem and since I often use InControl, its a critical problem for me. I'm willing to help build a solution if it means getting a nice extension package or wrapper or whatever to help these packages play nice together.

Basically the critical stuff is just the conversation package but I don't want to start adding calls to FirstSelected to everything if theres an easier way to handle getting the menu focused when it opens ( which then InControl works fine via unity UI ), and I'm not really sure when the best time to trigger those even is (or how to get the correct continue button).

Thanks in advance, :D

Dylan
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: InControl with Dialogue Support

Post by Tony Li »

Hi Dylan,

Thanks for using the Dialogue System!

Tick the Auto Focus checkbox at the bottom of the UnityUIDialogueUI inspector. This will auto-focus the continue button when it appears, and it will auto-focus the first button in the response menu when that appears. That should take care of dialogue UIs and InControl. (For other readers of this thread, the same applies for Rewired, etc.)

The only other part of the Dialogue System that directly uses Unity's Input Manager that you may be concerned about is the "Cancel" and "Cancel Conversation" triggers defined in the Dialogue Manager's Input Settings. If you want to use InControl for either of these, set the Button field to a blank string. Then add a script that listens for an InControl input (e.g., yourDevice.Action2.WasPressed) and use SendMessage to send "OnCancelSubtitle" or "OnCancelResponseMenu" to the Dialogue Manager. For example:

Code: Select all

string cancelMessage = null;

void OnConversationLine(Subtitle subtitle) {
    cancelMessage = "OnCancelSubtitle";
}

void OnConversationResponseMenu(Response[] responses) {
    cancelMessage = "OnCancelResponseMenu";
}

void OnConversationEnd(Transform actor) {
    cancelMessage = null;
}

void Update() {
    if (yourDevice.Action2.WasPressed && cancelMessage != null) {
        DialogueManager.Instance.SendMessage(cancelMessage);
    }
}
electricmonk
Posts: 2
Joined: Tue Apr 05, 2016 5:54 pm

Re: InControl with Dialogue Support

Post by electricmonk »

Thanks so much! I really appreciate the quick reply and I'm glad its that easy! Already built in! Thank you,

Dylan
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: InControl with Dialogue Support

Post by Tony Li »

Happy to help! If you run into any issues, just let me know.
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: InControl with Dialogue Support

Post by alfonso »

mmm i was looking the same thing :) i have two more question about dialogue System and InControl

the first is if i want to cancel the whole conversation i need to do something like this right?

Code: Select all

			if(DialogueManager.IsConversationActive && GameManager.PlayerDeviceController.CancelDialogue.WasPressed)
			{
				DialogueManager.Instance.SendMessage ("OnCancelResponseMenu");
			}
the other one is about accepting response, by default is hook to the Action1 button but what i need to do if i want to assing other?

thanks :)
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: InControl with Dialogue Support

Post by Tony Li »

Hi Alfonso,
alfonso wrote:the first is if i want to cancel the whole conversation i need to do something like this right?

Code: Select all

			if(DialogueManager.IsConversationActive && GameManager.PlayerDeviceController.CancelDialogue.WasPressed)
			{
				DialogueManager.Instance.SendMessage ("OnCancelResponseMenu");
			}
Yes, that will cancel the conversation if the response menu is active. When the response menu is active, the Dialogue System calls OnConversationResponseMenu(Response[] responses) on scripts on the Dialogue Manager. When a subtitle is active, it calls OnConversationLine(Subtitle subtitle).

If you want to cancel the whole conversation at any point, even while a character is speaking a subtitle line, you can just call DialogueManager.StopConversation() instead of sending the message. This won't send an OnConversationCancelled message, but it will stop the conversation.
alfonso wrote:the other one is about accepting response, by default is hook to the Action1 button but what i need to do if i want to assign other?
Make sure your Unity UI EventSystem has an InControlInputModule. Then assign the button to the Submit field.
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: InControl with Dialogue Support

Post by alfonso »

thanks for the response :)
Tony Li wrote: Hi Alfonso,
alfonso wrote:the first is if i want to cancel the whole conversation i need to do something like this right?

Code: Select all

			if(DialogueManager.IsConversationActive && GameManager.PlayerDeviceController.CancelDialogue.WasPressed)
			{
				DialogueManager.Instance.SendMessage ("OnCancelResponseMenu");
			}
Yes, that will cancel the conversation if the response menu is active. When the response menu is active, the Dialogue System calls OnConversationResponseMenu(Response[] responses) on scripts on the Dialogue Manager. When a subtitle is active, it calls OnConversationLine(Subtitle subtitle).
If you want to cancel the whole conversation at any point, even while a character is speaking a subtitle line, you can just call DialogueManager.StopConversation() instead of sending the message. This won't send an OnConversationCancelled message, but it will stop the conversation.
it's normal that "DialogueManager.Instance.SendMessage ("OnCancelResponseMenu");" works as the same as "DialogueManager.StopConversation()"? for me the first one cancel de conversation what ever npc or player was speaking or responseMenu was active or not
Tony Li wrote:
alfonso wrote:the other one is about accepting response, by default is hook to the Action1 button but what i need to do if i want to assign other?
Make sure your Unity UI EventSystem has an InControlInputModule. Then assign the button to the Submit field.
ok so if i want to change it only need to change on the InControlInputModule :)

Thanks for all :)
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: InControl with Dialogue Support

Post by Tony Li »

Yes, SendMessage ("OnCancelResponseMenu") works the same as StopConversation(), except StopConversation does not send the "OnConversationCancelled" message.
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

Re: InControl with Dialogue Support

Post by alfonso »

great! thanks you so much :)
Post Reply