Page 1 of 2
Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 12:42 pm
by HawkX
Hi again!
I'm trying to create a button/function that will completely hide the current playing cutscene, but that can also be brough back to keep going exactly where it left off... I havent added other "add-ons" to my project... but this is something that could very well be in the visual novel pack... since that is something that is often done (usually mapped to the right mouse button to hide and show the UI at anytime during a cutscene)
Any suggestion on how to best create that so i dont end up destroying my project?
And while im writing... Completely unrelated... I have been searching for a way to have the same image file have 2 different name in my project... so that it can be loaded using Ressources.load using 2 different names (similar to shortcuts in windows that can have a different name than the file they are pointing to)... is this something that is possible? if not, i think i might just end up duplicating the jpg file and renaming the copy instead
its not memory efficient, but if I only have a dozen of those in the whole game its not gonna make that huge of a difference...
As always, thanks so much for your help!
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 2:18 pm
by Tony Li
Hi!
HawkX wrote:I'm trying to create a button/function that will completely hide the current playing cutscene, but that can also be brought back to keep going exactly where it left off... I havent added other "add-ons" to my project... but this is something that could very well be in the visual novel pack... since that is something that is often done (usually mapped to the right mouse button to hide and show the UI at anytime during a cutscene)
The visual novel pack and the separate (and smaller)
GameSaver Example have a RememberCurrentDialogueEntry script.
HawkX wrote:And while im writing... Completely unrelated... I have been searching for a way to have the same image file have 2 different name in my project... so that it can be loaded using Ressources.load using 2 different names (similar to shortcuts in windows that can have a different name than the file they are pointing to)... is this something that is possible? if not, i think i might just end up duplicating the jpg file and renaming the copy instead
its not memory efficient, but if I only have a dozen of those in the whole game its not gonna make that huge of a difference...
I'm not aware of any way to create a shortcut to an asset. If they're not big, it might be easiest to do what you said and just duplicate them.
Otherwise, if you're using some kind of a script, you could make that script be a middle-man so it will load the same image given two different names.
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 2:53 pm
by HawkX
I am getting the following error after importing the unitypackage you linked...
Code: Select all
Assets/Dialogue System/Visual Novel Framework/Scripts/SequencerCommandVNLoadLevel.cs(17,67): error CS0234: The type or namespace name `RememberCurrentDialogueEntry' does not exist in the namespace `PixelCrushers.DialogueSystem.VisualNovelFramework'. Are you missing an assembly reference?
Not sure if that is what i needed though... i only want a "toggle visibility" of the dialoguemanager... im not changing scene or loading anything... its just for people who want to see the picture in fullscreen without the text/UI for a few seconds before continuing...
EDIT : and i just learned that you cannot uninstall a unitypackage... that is really troublesome... now i cant even run my project until i fix that compile error... there were only 2 files but im not 100% sure which one to remove
lol...
EDIT2 : Removed the NVLoadLevel and test.scene and all works again
--- But honestly, I wont be instaling unitypackage into an existing project again unless i have no other choice... way too dangerous especially since there is no undo or uninstall... i cant imagine if it was a super complexe package with tons of stuff...
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 3:14 pm
by Tony Li
Hi,
I try to keep everything for unitypackages in a single folder, so you can typically delete that folder to uninstall everything. That's only for Pixel Crushers packages, though. I can't promise the same for others' folders. But to find out what files are in a unitypackage, you can create a new project and select the unitypackage to import. This will show the import window with checkboxes for each file. You don't have to click the Import button; just make a note of which files are listed in the import window.
The Game Saver Example (linked above) might be a simpler way to get the functionality you're looking for. Open the import window for that unitypackage and UNtick everything else the RememberDialogueEntry.cs script.
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 3:25 pm
by HawkX
I actually tried importing it again (just to see the window with the file name) and noticed i did not delete the right file
Now i'm wondering if the file i deleted was important
SequencerCommandVNLoadLevel.cs...
that RememberDialogueEntry.cs file was causing SequencerCommandVNLoadLevel.cs to not compile... (see the error above i copy pasted)
I think i'll just give up on the idea... way too much work to get it working properly... its not something that is absolutely necessary... just that in our latest cutscene, there is one character that gets partly hidden by the subtitle window, so i wanted to create a super quick "hide" button to toggle on/off the ui... but seeing as i dont use any of the "extra" features (save/load/datamanagement) of the dialogue manager (since i had already started my project before adding the manager and already had my own saveload BinaryFormatter)
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 3:32 pm
by Tony Li
I kind of agree from a design standpoint. It might be more consistent to adjust the cutscene so the character isn't obscured by the subtitle window. This way your game doesn't have to introduce a new operation (show/hide UI).
However, if you want to hide the UI during a subtitle, you can use the SetActive() sequencer command. No extra scripts needed. For example, something like:
Code: Select all
SetActive(Dialogue Panel,false);
Camera(Special Camera Position,,2);
required SetActive(Dialogue Panel,true)@1.8
This hides the GameObject named "Dialogue Panel". Then it moves the camera to the position of an (empty) GameObject named "Special Camera Position" over 2 seconds. At the 1.8-second mark, it shows "Dialogue Panel" again.
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 3:46 pm
by HawkX
Thanks again for taking the time to reply so fast! Always extremely appreciated
I tried reimporting DialogueManager 1.6.9 to get back the file "SequencerCommandVNLoadLevel.cs" but it says i already have all the files...
I then went into one of my backup and copied back the file manually and i still get the same namespace error even though the RememberDialogueEntry.cs is not in the project anymore... is SequencerCommandVNLoadLevel.cs important or can i just not have it and it wont matter?
THIS line "SetActive(Dialogue Panel,false);" seems to be exactly what i needed...
Can I put that in a button stand alone?
And then make another button to do "SetActive(Dialogue Panel,true);"
or do those need to be added to the sequencer like the camera cuts?
EDIT : I did that in an update ()
Code: Select all
if (Input.GetKeyDown (KeyCode.H))
{
DialogueManager.PlaySequence("SetActive(Dialogue Panel,false);");
}
if (Input.GetKeyDown (KeyCode.S))
{
DialogueManager.PlaySequence("required SetActive(Dialogue Panel,true)@0.1");
}
the "H" for hide works... but not the "S" for show it back on... im 50% there
why is the "S" not working?
Note that I tried without the @0.1 and without the "required" and it didnt work either...
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 4:03 pm
by Tony Li
Sorry, I totally forgot to answer about "SequencerCommandVNLoadLevel.cs"! It was added by the Visual Novel Framework package. (That's where the "VN" in the name comes from.) You can leave it deleted, since you're not using the Visual Novel Framework.
If you use UI buttons, you don't need sequencer commands at all for this. You can add an entry to your "Hide Dialogue UI" button's OnClick() event and directly assign the Dialogue Panel. From the dropdown, select GameObject.SetActive. Leave the checkbox unticked to deactivate the GameObject.
Note that if your UI button is located inside Dialogue Panel this will also hide your UI button. You could add another UI button outside of your Dialogue Panel labeled "Show Dialogue UI". You could even position it in the same place as the Hide Dialogue UI button so it looks like they're the same button. Configure this button similarly, but tick the checkbox to reactivate the Dialogue Panel. Then deactivate the Show Dialogue UI Button.
Finally, add a few more entries to the buttons' OnClick() events so in total they look like this:
Hide Dialogue UI Button:
- Dialogue Panel -> GameObject.SetActive (UNticked)
- Show Dialogue UI Button -> GameObject.SetActive (ticked)
Show Dialogue UI Button:
- Dialogue Panel -> GameObject.SetActive (ticked)
- Show Dialogue UI Button -> GameObject.SetActive (UNticked)
To summarize:
- The Hide Dialogue UI Button will hide the Dialogue Panel and show the Show Dialogue UI Button.
- The Show Dialogue UI Button will show the Dialogue Panel and hide the Show Dialogue UI Button.
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 4:06 pm
by Tony Li
Regarding your edited post with code:
Try setting the Dialogue Manager's Debug Level to Info. When the "S" sequence runs, it should report which GameObject it found for "Dialogue Panel". Make sure it's the right GameObject.
Or use the UI button idea in my previous post. You can add UI Button Key Trigger components to the UI buttons if you want to add keyboard shortcuts for them.
Re: Creating a Show/Hide Dialogues Button
Posted: Thu May 04, 2017 4:25 pm
by HawkX
wow... always incredibly complete answer!
I already tested with the "S" key and the DialoguePanel is indeed "re-activated"... but the conversation does not re-appear...
I just tried it the way you suggested as well with 2 default UI buttons (one next to my skip/auto buttons) and the other outside that gets enabled when the first one is clicked... and it seems getting "ticked off" cancel the ongoing conversation...
I also tried toggling off and on the Canvas, the DialogueUI, the DialoguePanel and the TextPanel
And all of them did not reappear when i toggled them back on...
Only one that actually worked and reappeared was the Subtitle Line (but its not useful as the rest of the UI is still visible)
EDIT : I'm guessing I might need to tweak that "remember" file you sent me to save and restart the conversation after all...