Creating a Show/Hide Dialogues Button

Announcements, support questions, and discussion for the Dialogue System.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Creating a Show/Hide Dialogues Button

Post by HawkX »

I FIXED IT!!! :)

Here is what I put inside my script :

Code: Select all

if (Input.GetKeyDown (KeyCode.H))
		{
			DialogueManager.PlaySequence ("SetActive(Dialogue Panel,false);");
			FindObjectOfType<GameSettingsOptions>().DisableEnergyNMenu();
		}

		if (Input.GetKeyDown (KeyCode.S))
		{
			DialogueManager.PlaySequence ("SetActive(Dialogue Panel,true)");
			FindObjectOfType<GameSettingsOptions>().EnableEnergyNMenu();
			var conversationID = DialogueLua.GetVariable ("CurrentConversationID").AsInt;
			var entryID = DialogueLua.GetVariable ("CurrentEntryID").AsInt;
			if (conversationID >= 0 && entryID > 0)
			{
				var conversation = DialogueManager.MasterDatabase.GetConversation (conversationID);
				var actorName = DialogueLua.GetVariable ("CurrentConversationActor").AsString;
				var conversantName = DialogueLua.GetVariable ("CurrentConversationConversant").AsString;
				var actor = GameObject.Find (actorName);
				var conversant = GameObject.Find (conversantName);
				var actorTransform = (actor != null) ? actor.transform : null;
				var conversantTransform = (conversant != null) ? conversant.transform : null;
				GV.boolHideDialogueInterface = true;
				DialogueManager.StopConversation ();
				DialogueManager.StartConversation (conversation.Title, actorTransform, conversantTransform, entryID);
				GV.boolHideDialogueInterface = false;
			}
		}
the "GV.boolHideDialogueInterface" is a bool I toggle so that all of my "on conversations end" and "on conversations start" are not called when i stop and start the conversation...

I added a

Code: Select all

		if (!GV.boolHideDialogueInterface)
		{
		....
		}
Inside all of my public void OnConversationStart (Transform gm) that I have all over the game :)

So it all work now!! which is amazing! :)

It wasnt an important feature... but its so nice when you spend hours trying to fix something and it eventually work out! :)

There is however a warning that pops from one of your file :
UIShowHideController.cs : the line "currentHashID"

Code: Select all

 while ((currentHashID != goalHashID) && (currentHashID == oldHashId) && (Time.realtimeSinceStartup < timeout))
                    {
                        yield return null;
                        currentHashID = UITools.GetAnimatorNameHash(animator.GetCurrentAnimatorStateInfo(0));
                    }
returns the following error message :
Animator is not playing an AnimatorController
UnityEngine.Animator:GetCurrentAnimatorStateInfo(Int32)
PixelCrushers.DialogueSystem.<WaitForAnimation>c__Iterator0:MoveNext() (at Assets/Dialogue System/Scripts/Supplemental/UI/Tools/UIShowHideController.cs:63)
I dont really like "leaving" warnings when possible i like to fix them... any tips on what that one mean? :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Creating a Show/Hide Dialogues Button

Post by Tony Li »

Awesome! I'm glad you got it working. It's yet another little bit of polish that players will appreciate even if they don't realize it consciously.

The next release of the Dialogue System should get rid of the "Animator is not playing" message.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Creating a Show/Hide Dialogues Button

Post by HawkX »

Hey Tony!! :)

I'm getting better and better i dont bug you as often anymore! :P

Today I decided to tweak the function to hide and restart the dialogues and to add features to hide and show EVERY single UI elements in the game...

After a few hours, everything is working perfectly... but I found a small bug in the function you gave me...

When calling back the Dialogues, you told me to use :
DialogueManager.PlaySequence ("SetActive(Dialogue Panel,true)");

However, if there is no dialogues currently playing when I re-enable the interface, the portrait panel in my dialoguemanager gets turned on with alpha = 0 (invisible) and that mess up any buttons that would appear below it... (see attached jpg)

BOTH the dialogue panel AND Portrait panel gets toggled back on by that line... when there is no dialogues playing...

IF there is a dialogue playing, the bug will not appear at all, the end of the dialogues, will also fix the problem...

I am unsure if my Portrait Panel SHOULD have an image component or not... there never seems to be anything that goes in there... (probably because I dont use a frame for the portraits)...

Any suggestion on how to fix this? :) -- or should I just remove the image component of the panel since that seemed to fix it (I tried it while in play mode and the bug did not occur that way)
Attachments
portrait panel.jpg
portrait panel.jpg (79.06 KiB) Viewed 1131 times
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Creating a Show/Hide Dialogues Button

Post by Tony Li »

I think you can just remove the image from the Portrait Panel. You still need some kind of UI element on any of the other panels that are assigned to fields in the Unity UI Dialogue UI component (e.g., NPC Subtitle > Panel). But you can make their alphas = 0 if you don't want them to be visible.

If that doesn't work, let me know so we can come up with a different solution than using SetActive().
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Creating a Show/Hide Dialogues Button

Post by HawkX »

The problem is that this line :
DialogueManager.PlaySequence ("SetActive(Dialogue Panel,true)");
will put the dialogue panel and portrait panel to active EVEN if there was no cutscene playing...

and if their alpha = 0, they interfere with buttons all over the game... they really need to be not-active...

I think in this case deleting the image component of the portrait panel would fix it... but there is still an underlying bug or something missing...

Before I hide everything, both the Dialogue Panel and Portrait Panel are "not active"... but after toggling hide and not-hide, those 2 are set to active even when no cutscenes are playing...
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Creating a Show/Hide Dialogues Button

Post by Tony Li »

What if you make Dialogue Panel a child of another panel, and then use SetActive() on the parent? Like:
  • Unity UI Dialogue UI
    • Master Dialogue Panel
      • Dialogue Panel
        • Subtitle Panel, etc.
and use SetActive on Master Dialogue Panel.

If that doesn't work for you, you could add a Canvas Group to Master Dialogue Panel. In your script, instead of running SetActive(), do something like this:

Code: Select all

public CanvasGroup masterDialoguePanel; // ASSIGN IN INSPECTOR, OR USE GAMEOBJECT.FIND.
...
void SetDialogueVisibility(bool show) {
    masterDialoguePanel.alpha = show ? 1 : 0;
} 
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Creating a Show/Hide Dialogues Button

Post by HawkX »

well disabling the component image of both the dialogue panel and portrait panel worked... so i think im gonna leave it at that...

I tested starting new conversations, skipping some, toggling off and on the ui over and over... seems pretty robust and bug free...

if those 2 are not used and not important... i'm gonna leave them there but the image component itself disabled.. :)

to be honest, im actually afraid to change stuff in the manager... hehe... afraid that something would break or stop working :P hehe...

But really thanks for your help as always! :)
Post Reply