Forum rules - please read before posting.

Problem with Super Text Mesh and Scene Changes

Hi Chris,

Wonder if you could please help. I'm using Super Text Mesh in my SubtitlesUI and it's been working well, but breaks when switching scenes. After a scene switch, all Subtitles UI in the new scene incorrectly display the last used dialogue from the previous scene, regardless of which character spoke it.

I'm using the script from the AC Wiki:
https://adventure-creator.fandom.com/wiki/Super_Text_Mesh_subtitle_integration

I've placed the script on the SubtitlesUI Prefab, specifically on the txtSubtitles object.
That subtitles object has a Constant ID component, as well as a hidden TextMeshPro component on it (having TMP, even though hidden, is the only way I've been able to link the Super Text Mesh subtitles object to the AC menu in the past)

However, when I look now, I see in the AC Subtitles menu that the 'Linked Text' is showing 'None (Text)' but the Recorded ConstantID of the txtSubtitles object is correctly showing. I can't seem to reconnect it, even if I enable the Text Mesh Pro component.

I wonder if you could please advise? I'm stumped. The Super Text Mesh setup works ok in a single scene, but seems to get stuck on the last used dialogue when changing scenes, whenever dialogue is spoken in the new scene.

Demo vid:

Comments

  • edited October 1

    Huh - turns out turning on the 'Duplicate for each line' setting in the AC Menu seems to have solved it.
    Nice.

  • edited October 6

    Hi Chris, I'm encountering a new problem, that was maybe always there but I've only started noticing it now: I'm using UnityUI for Subtitles, and am noticing that the subtitles appear very quickly in the middle of the screen before correctly appearing above the player's heads. Any idea how to fix this please?

    I'm using Super Text Mesh along with the script on the Wiki. Even if I turn off 'Canvas Fade' it doesn't help the issue.

  • I can remedy the problem by deselecting 'Duplicate for each line?' option in the menu, but then I run into the problem mentioned in the first post in this thread.

    Hmm...

  • After plenty testing it seems like it's related possibly to the way the ACWiki script integrates 'Super Text Mesh' because when I disable Super Text Mesh on the Subtitles Canvas element and just use Text Mesh Pro, the temporary placement issue is solved.

    I think the ACWiki script is positioning the text in the right place a little too late, so the text is appearing at the Prefab origin and only being moved above the character's head a moment later.

    Wonder if any way to solve this.

  • Can you share the script? I seem to have a bit of an issue accessing the wiki page right now.

  • edited October 7

    Hi Chris - sure, thanks, it’s this one:
    https://adventure-creator.fandom.com/wiki/Super_Text_Mesh_subtitle_integration
    I asked the creator about it but he says he wouldn’t know or even remember the script from 9 years ago. I can’t seem to comment it as code from my phone :/ [edit: [pasted from comp, and included the supertext.color = speech.GetColour (); line that the script on the wiki doesn't have.

    > using UnityEngine;
    using System.Collections;
    
    public class SuperTextFromACSpeech : MonoBehaviour {
        /*
        This script is to make Super Text Mesh work with Adventure Creator.
        Essentially, it lets AC handle all non-text elements (sound effects, user input),
        while letting STM handle all text-related issues (scrolling speed, animations, colors, etc.)
    
        Simply put this script on a Super Text ui item in your subtitlesUI adventure creator menu,
        then hide the text item that AC thinks it's referencing (put it offscreen, make it invisible, whatever!).
    
        AC will play dialogue sounds and handle input as normal,
        but the player will only see the Super Text.
    
        Script by @johndaguerra.  No credit needed, but I'm cool and it'd make me happy if you followed me on twitter!
        */
        SuperTextMesh supertext;
        AC.Speech speech;
        AC.Dialog dialog;
    
        void Start () {
            supertext = GetComponent<SuperTextMesh>();
            dialog = FindObjectOfType<AC.Dialog>();
        }
    
        void Update () {
            //If there is dialogue currently being spoken...
            if (dialog.GetLatestSpeech() != null)
            {
                //And you haven't already sampled it...
                if (speech != dialog.GetLatestSpeech())
                {
                    //Then set the supertext text to print the dialogue
                    speech = dialog.GetLatestSpeech();
                    supertext.color = speech.GetColour ();
                    supertext.Text = speech.log.fullText;
                    //This tells the text to read at regular speeds, in case it was told to speed read
                    supertext.RegularRead();
                }
            }
    
            if (supertext.reading == true)
            {
                if (Input.GetMouseButtonDown(0) || Input.GetKeyDown("space"))
                {
                    //If the player clicks or presses space while reading, then speed read
                    supertext.SpeedRead();
                }
            }
    
        }
    }
    
  • In case useful or in case it might affect things, this is my SubtitlesUI setup. Was a fairly convoluted setup to get the background colour box of the text to conform to the text amount, and for setting the min and max horizontal size the text box could be (took me a couple days of fiddling and watching and rewatching various tutorials, perhaps second nature to some but defs not for me).

  • Try this:

    using UnityEngine;
    using AC;
    
    public class SuperTextFromACSpeech : MonoBehaviour
    {
    
        SuperTextMesh supertext;
        AC.Speech speech;
        AC.Dialog dialog;
    
        void Start () {
            supertext = GetComponent<SuperTextMesh>();
            dialog = FindObjectOfType<AC.Dialog>();
        }
    
        void OnEnable()
        {
            EventManager.OnStartSpeech_Alt += OnStartSpeech;
        }
    
        void OnDisable()
        {
            EventManager.OnStartSpeech_Alt -= OnStartSpeech;
        }
    
        void OnStartSpeech(Speech speech)
        {
            this.speech = speech;
            supertext.color = speech.GetColour ();
            supertext.Text = speech.log.fullText;
            //This tells the text to read at regular speeds, in case it was told to speed read
            supertext.RegularRead();
        }
    
        void Update ()
        {
            if (supertext.reading)
            {
                if (KickStarter.playerInput.InputGetMouseButtonDown(0) || Input.GetKeyDown("space"))
                {
                    //If the player clicks or presses space while reading, then speed read
                    supertext.SpeedRead();
                }
            }
    
        }
    }
    
  • Hi Chris, thanks - I get this compilation error:

    Assets/bbsugar/Scripts/SuperTextFromACSpeech.cs(39,41): error CS0122: 'PlayerInput.InputGetMouseButtonDown(int)' is inaccessible due to its protection level

  • Ah - I asked KaiClavier (the author of Super Text Mesh) about this and he gave some suggestions, the first of which (replacing "supertext.Text" with "supertext._text") seemed to do the trick:

    https://itch.io/t/5397155/issue-with-adventure-creator-and-super-text-mesh#post-14425498

    I tried to make a contribution to the ACWiki's integration script (and also added the line:
    supertext.color = speech.GetColour ();
    So that the script uses the character's subtitles colour, but struggled to get the script formatting to appear correctly with the web editor.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.