Forums › 💬 Slate Sequencer › ⚙️ Support › Overwriting Captions › Reply To: Overwriting Captions
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
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
using UnityEngine; using Slate; [ExecuteInEditMode] public class CustomGUIExample : MonoBehaviour { public Color subsColor = Color.white; public int size = 14; public int yOffsetFromBottom = 5; private string subsText; private float colorAlpha; void OnEnable(){ DirectorGUI.OnSubtitlesGUI += OnSubtitlesGUI; } void OnDisable(){ DirectorGUI.OnSubtitlesGUI -= OnSubtitlesGUI; } void OnSubtitlesGUI(string text, Color color){ colorAlpha = color.a; if (colorAlpha < 0.1f){ subsText = null; return; } subsText = string.Format("<size={0}>{1}</size>", size, text); } void OnGUI(){ if (!string.IsNullOrEmpty(subsText)){ var style = new GUIStyle("label"); var size = style.CalcSize(new GUIContent(subsText)); var rect = new Rect(0, 0, size.x, size.y); rect.center = new Vector2( Screen.width/2, Screen.height - size.y - yOffsetFromBottom ); var clr = subsColor; clr.a = colorAlpha; GUI.color = clr; GUI.Label(rect, subsText); GUI.color = Color.white; } } } |
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.
[attachment file=”CustomGUIExample.png”]
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.
