Page 1 of 1

Keeping Methods from an Instance and returning to previous text

Posted: Fri May 19, 2023 5:12 am
by Dyonos
So I'm working to integrate the Dialogue System into my project, and it's working well so far, however, I have two questions that I could find by googling.

First:
I some instanced game objects in my game that run/keep track of background logic. At one point, I'd like to increment a variable through a function on one of these instances. However, when changing scenes, it disconnects the link to the function (under scene event, the event says "game object missing"). I've gotten around this by registering the functions into LUA, and calling it from the LUA script, but is there a way to use the event drag and drop list even when using instances that persist through scene changes?

Second:
I would like the player to be able to go back to previous dialogue entries if they missed something or if they want to re-read it. Is this possible with the Dialogue System? Is there a similar function already built in? Or, failing that, is there a way to make a text log/text history that players could look at mid-conversation?

Thank you in advance for the help ^^

Re: Keeping Methods from an Instance and returning to previous text

Posted: Fri May 19, 2023 6:35 am
by Tony Li
Hi,
Dyonos wrote: Fri May 19, 2023 5:12 amFirst:
I some instanced game objects in my game that run/keep track of background logic. At one point, I'd like to increment a variable through a function on one of these instances. However, when changing scenes, it disconnects the link to the function (under scene event, the event says "game object missing"). I've gotten around this by registering the functions into LUA, and calling it from the LUA script, but is there a way to use the event drag and drop list even when using instances that persist through scene changes?
This is a similar topic to: How To: Manage Player Controls and Scene Changes. You can't use event drag and drop for the same reason. That's one of the reasons why Lua functions and sequencer commands exist.
Dyonos wrote: Fri May 19, 2023 5:12 amSecond:
I would like the player to be able to go back to previous dialogue entries if they missed something or if they want to re-read it. Is this possible with the Dialogue System? Is there a similar function already built in? Or, failing that, is there a way to make a text log/text history that players could look at mid-conversation?
You can do both. The Dialogue System Extras page has a Backtracking Example to go backwards in the conversation.

Alternatively, you can tick the subtitle panel's Accumulate Text checkbox to accumulate all dialogue text so the player can scroll back. The WRPG, Runic, and Scrolling dialogue UI prefabs are already set up this way if you'd like see examples.

You can also log the conversation in your own script using the Dialogue System's special script methods. See ConversationLogger.cs for an example.

Re: Keeping Methods from an Instance and returning to previous text

Posted: Fri May 19, 2023 7:06 am
by Dyonos
Tony Li wrote: Fri May 19, 2023 6:35 am This is a similar topic to: How To: Manage Player Controls and Scene Changes. You can't use event drag and drop for the same reason. That's one of the reasons why Lua functions and sequencer commands exist.
I figured that might be the case. I think I prefer setting them in LUA anyways. ^^
On that topic, one other question I had:
Sometimes after I put the LUA script into the script box and click "apply" the text will sometimes disappear when I test the scene. Is this a bug, or am I doing something wrong? It's happened more than a few times in the past 2 days.
Tony Li wrote: Fri May 19, 2023 6:35 am You can do both. The Dialogue System Extras page has a Backtracking Example to go backwards in the conversation.

Alternatively, you can tick the subtitle panel's Accumulate Text checkbox to accumulate all dialogue text so the player can scroll back. The WRPG, Runic, and Scrolling dialogue UI prefabs are already set up this way if you'd like see examples.

You can also log the conversation in your own script using the Dialogue System's special script methods. See ConversationLogger.cs for an example.
These are great, thank you!

Re: Keeping Methods from an Instance and returning to previous text

Posted: Fri May 19, 2023 10:33 am
by Tony Li
> Sometimes after I put the LUA script into the script box and click "apply" the text will sometimes disappear when I test the scene. Is this a bug, or am I doing something wrong? It's happened more than a few times in the past 2 days.

Which field goes blank -- the Script field, or the Dialogue Text field, or something else?

Are there any errors or warnings in the Console window when this happens?

Re: Keeping Methods from an Instance and returning to previous text

Posted: Fri May 19, 2023 11:52 am
by Dyonos
The script field. It can be inconsistent, sometimes the scripts will save on the first try, sometimes I'll need to retype the scripts twice, as it will vanish each time I hit the play button. I don't get any errors when it happens, the console window stays empty.

I'm using editor version 2022.2.18f1 if that is relevant.

Re: Keeping Methods from an Instance and returning to previous text

Posted: Fri May 19, 2023 1:38 pm
by Tony Li
Hi,

Thanks; I'll investigate this. It might be a Unity 2022 bug.