Hi,
I've Unity UI menu for Subtitles , in order to change it's position in certain cases
I'm wrote custom action list and set the menu's appear type to Manual
It works pretty good, except that I need also the Duplicate for each Line feature
which works only when appear type is When Speech Plays
How can I implement such feature in code?
I don't see any way to override 'AssignSpeechToMenu'
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
What's the reason you need to set it to Manual?
To duplicate a Menu through code, you have to create a new Menu instance manually, and add it to AC's list of custom menus:
Passing "true" in that last function parameter will have it be removed from the list automatically when the Menu is turned off.
Duplicating Menus manually can be tricky. It may instead be worth manually changing the regular speech Menu's Appear type to Manual once it's been duplicated by AC. Once created and displayed, the duplicate menu's settings will be independent from the original.
Got it.
I set it to Manual to control position manually
in case where sprites has too much space above head
or when text is close to screen boundary and I want to control the text
position.
What's the best place to call CreateDuplicate?
I tried in OnStartSpeech but I'm not getting same result as:
Appear type: When Speech Plays
For speech of time: Characters only
For Speech of type: All
Duplicate for each Line: checked
It's for the case when mutilple character speak at once
and each should create subtitle menu.
Instead, I get only one character text shown at a time.
even that all of their menus created and
display text set to play in background in the actionlist
I will also need to turn it off OnStopSpeech, but then
I'll need a reference to that specific menu.
I'm not clear on your need for this - the "Appear type" is separate from the "Position type". You can still reposition a duplicated speech menu without having to manually duplicate it.
If you hook into the OnMenuTurnOn event, you can read its speech variable to determine which speech line / character it's associated with.
If you did need to duplicate it, doing so from OnStartSpeech should do it - but you'll need to make sure the Menu you're duplicating isn't itself set to duplicate in the Menu Manager.
To turn it off from OnStopSpeech, you can call GetMenusAssignedToSpeech to find all Menus associated with the line.
Oh my, I didn't know there is such speech variable in AC.Menu
that's why I used OnStartSpeech from the first place.
So, I hooked the OnMenuTurnOn as you suggested and took
everything I did OnStartSpeech and put there.
Then, I set back Subtitles 'Appear type' to When Speech Plays with duplicate line.
and now it works exactly as I wanted, thanks Chris!