Hi there,
Since its implementation, I've been using shortcuts extensively. Would be weird otherwise, being the guy that asked for them.
And as I'm no real coder, I've been adding them using several Sequencer Shortcuts components in the Dialogue Manager. Now, I have so many of them that managing the list is becoming more and more of a hassle.
I'd like to move all of them to an attached C# script, but I can't find relevant info on how exactly I should do it. Could you help me with that, please?
Thanks!
Shortcuts registration via C# script ?
Shortcuts registration via C# script ?
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Shortcuts registration via C# script ?
Hi,
Use Sequencer.RegisterShortcut() and Sequencer.UnregisterShortcut().
In version 1.8.6+, shortcuts stack. So if you were to use this code:
Then "talk" would be mapped to "AudioWait(entrytag)" because it's on the top of the stack.
If you then use this code:
Then "talk" would be mapped to "AnimatorPlayWait(MoveMouth)", which is next on the stack after removing "AudioWait(entrytag)".
Use Sequencer.RegisterShortcut() and Sequencer.UnregisterShortcut().
Code: Select all
using PixelCrushers.DialogueSystem;
...
Sequencer.RegisterShortcut("talk", "AnimatorPlayWait(MoveMouth)");
...
Sequencer.UnregisterShortcut("talk");
In version 1.8.6+, shortcuts stack. So if you were to use this code:
Code: Select all
Sequencer.RegisterShortcut("talk", "AnimatorPlayWait(MoveMouth)");
Sequencer.RegisterShortcut("talk", "AudioWait(entrytag)");
If you then use this code:
Code: Select all
Sequencer.UnregisterShortcut("talk");
Re: Shortcuts registration via C# script ?
Thanks Tony,
Just one doubt I have... Can I include line break code \n\r inside the sequencer shortcut value?
Just one doubt I have... Can I include line break code \n\r inside the sequencer shortcut value?
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Shortcuts registration via C# script ?
Yes, that's fine, and you can shorten it to "\n" if you prefer. The "\r" isn't required.
Re: Shortcuts registration via C# script ?
Thank you.
Oh, and another question... lol, I'm remembering them as I go. I suck.
Which one runs first? Sequencer Shortcut components? Custom scripts? Only the RNG gods know?
Oh, and another question... lol, I'm remembering them as I go. I suck.
Which one runs first? Sequencer Shortcut components? Custom scripts? Only the RNG gods know?
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Shortcuts registration via C# script ?
The Sequencer Shortcuts component registers shortcuts in the OnEnable phase.
If your script registers shortcuts in Awake, it's guaranteed to register them before Sequencer Shortcuts.
If you scroll down halfway on Unity's Execution Order of Event Functions page, a handy flowchart explains when each phase runs.
If your script registers in OnEnable or Start, only the RNG gods know. (That's not entirely true. You can manually set Script Execution Order, but it might be more hassle than it's worth.)
If your script registers shortcuts in Awake, it's guaranteed to register them before Sequencer Shortcuts.
If you scroll down halfway on Unity's Execution Order of Event Functions page, a handy flowchart explains when each phase runs.
If your script registers in OnEnable or Start, only the RNG gods know. (That's not entirely true. You can manually set Script Execution Order, but it might be more hassle than it's worth.)
Re: Shortcuts registration via C# script ?
Thank you Tony.
That's all I need...
...for now. <insert Dr. Evil cackle here>
That's all I need...
...for now. <insert Dr. Evil cackle here>
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15