Overwriting Captions

Slate Forums Support Overwriting Captions

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1515
    jrush64
    Participant

    Hi,

    I was wondering if someone could please help me with overriding the GUI. I dont have any idea ho to do it. I dont want to have to keep changing the font size every time I write subtitles. I only want to change it once.

    I know I read in this site that you can subscribe to an event or something like that but I have no idea how to do that. Can you please give me an example?

    #1517
    Gavalakis
    Keymaster

    Hello,

    To override the GUI, you need to subscribe to the various events that are available in the DirectorGUI class. Each event corresponds to a different GUI functionality, thus in your case, you would want to subscribe to the OnSubtitlesGUI event.
    Once you have subscribed to that event, the default subtitles GUI implementation will completely be bypassed and instead be forwarded for you to implement through the event raised.

    Here is a rather very simple example:

    You can attach this script in the “Director Camera Root” gameobject. In runtime (and runtime only since OnEnable and OnDisable are called in runtime), your implementation will be called, while in editor time the default implementation will be called.

    But, if the only thing you want to change is the subtitles size, this might be an overkill. If that is the case, please just open up DirectorGUI.cs and change the SUBS_SIZE field from being private const, to public thus possible to change in inspector. I will keep this change in future version so that the subtitles size can be changed from inspector as well.

    Let me know.
    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    #1521
    jrush64
    Participant

    Alright thank you. While it definitely overrode the gui, I thought it would let me pick the size and color of the font easily by making values public in the script.

    How do i go about doing that?

    I still have to go into each caption and change the color individually. I know the script has color.white . How do I make that value public?

    #1525
    Gavalakis
    Keymaster

    Hello,

    By overriding the gui, you get complete control over how the specific overridden element is shown.
    If you want to use a fixed color instead of the one passed through the clips, then please use the following modified version of the previous script, which expose public variables for color (as well as size) and use those instead of passed ones from clip:

    Let me know if that works for you.
    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #1708
    jrush64
    Participant

    I tried to use this code and it didn’t work. I’d like to be able to change the color and the position of the text. Is that possible? I tried to make some changes but it didn’t work.

    Small question, is it possible to use HTML codes in the caption box. For example, say I want the characters name to be a different color than the actual text itself.

    #1709
    Gavalakis
    Keymaster

    Hello again,

    This is a refined script that I have just tested. I have also included a position variable, in the form of Y Offset from the Bottom of the Screen.
    Please create a script like this in your project:
    CustomGUIExample.cs

    Attach the above script in an empty gameobject in your scene, or attach it to some existing adequate gameobject.
    In the inspector of the script, you can change the color, size as well as the offset position from the bottom.
    CustomGUIExample

    Regarding html style formatting, yes, you can use html tags that Unity supports within the Captions or Subtitles clip text like so:
    This is a <color=#000000>black</color> text.,
    but actor name color more specifically can not be changed right now through the use of html tags as above.

    Please let me know if the above script works for you.
    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
    #1711
    jrush64
    Participant

    While it’s working, it seems that the DirectorGUI font type can’t be changed. Basically when I add a new font in DirectorGUI and press play, the font doesn’t change to the one I changed it to.

    Also, when I’m using the use instance hide original character reference audio track to display the sbutitle name of the character talking, it shows the characters and clone in brackets when the subtitle is displayed. (Character name (Clone): This is the subtitle)

    #1716
    Gavalakis
    Keymaster

    Hello,

    Just to clarify what is going on, when you override the default GUI, like we do here, nothing from the default GUI (aka DirectorGUI) is executed or used by default, since we completely override it and as such, we need to tell our GUI exactly how to display the information.

    Thus, the solution to that, is to also add a “Font” variable to our CustomGUIExample.cs script and change the script to use the supplied font:

    There will now be a “font” variable in the inspector of the above script.

    Regarding the “(Clone)” naming issue, thanks for letting me know.
    To fix this quickly, please open up PlayAudio.cs file and change line #96 to be like this:
    DirectorGUI.UpdateSubtitles(string.Format("{0}{1}", parent is ActorAudioTrack? (actor.name.Replace("(Clone)", "") + ": ") : "", subtitlesText), lerpColor);

    Let me know if the above work for you.
    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.