Forum rules - please read before posting.

Feature Request - Character Count

It might sound silly, yet it's a simple request...
Is it possible to add a character count for the "Line Text" of a Dialogue: Play Speech action?

I'm working on a 2D Game with old school Subtitles that appear above the characters and I'd like to keep max 2 rows.
I know that it means approx 80 characters so would be great to have a counter somewhere while I write the dialogues.
Some simple number on a corner of the action element.

I guess it should be easy to program? And yet so useful...


  • Easy or not, I don't feel that would be beneficial to many - and combined with the line ID also appearing would likely be confusing to some.

    However, you can create a subclass of ActionSpeech to add this in yourself (see the custom Actions tutorial).

    Alternatively, you can avoid scripting by gathering up your text in the Speech Manager and exporting it so that you can display character limits in a spreadsheet file. By creating a new language and checking Don't use at runtime? under your original language, you can also use any text you enter in AC's Speech action boxes as placeholder text, and rely only on a translation for your game's display text.

  • I honestly think that lot will benefits, not just me (Forum users, am I crazy?). A character count is a must for every dialogue writing software (ok, this is not one of those, but at the same time I thought it wasn't a big deal to include it).

    Also, I was thinking a design LIKE THIS (made in Photoshop) that, in my opinion, is not confusing at all...

    I'll see if I can script it myself somehow at this point.
    But I'd prefer to avoid exporting/importing the text... Mine was a request to have a quick way to check how many characters I'm writing directly in Unity.

  • edited April 2019

    This can be achieved by inserting the following into ActionSpeech.cs after the "EditorGUILayout.EndHorizontal ();" line:

    EditorGUILayout.LabelField ("Character count: " + messageText.Length);

    I'll consider adding something officially.

  • edited April 2019

    I thought it was working fine, until I created a new Dialogue.Speech action, then I get the error:

    NullReferenceException: Object reference not set to an instance of an object
    AC.ActionSpeech.ShowGUI (System.Collections.Generic.List`1[T] parameters) (at Assets/AdventureCreator/Scripts/Actions/ActionSpeech.cs:351)
    AC.ActionListEditorWindow.NodeWindow (System.Int32 i) (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:702)
    UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at C:/buildslave/unity/build/Modules/IMGUI/GUILayout.cs:442)
    UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at C:/buildslave/unity/build/Modules/IMGUI/GUI.cs:1635)
    AC.ActionListEditorWindow:NodesGUI(Boolean) (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:1126)
    AC.ActionListEditorWindow:OnGUI() (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:389)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

    I thought it was working because on existing Actions it's shown correctly without error. If I copy-paste the existing Action it works good (I see the line of character count where it should be, everything great!). But when I create a blank new Dialogue one, it gives me that error and crashes everything...

  • if (!string.IsNullOrEmpty (messageText)) EditorGUILayout.LabelField ("Character count: " + messageText.Length);
  • edited April 2019

    For completeness, as I mentioned it's possible to rely on an ActionSpeech subclass, here is a custom Action that does just this:

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEditor;
    namespace AC
        public class ActionSpeechCount : ActionSpeech
            public ActionSpeechCount ()
                this.isDisplayed = true;
                category = ActionCategory.Dialogue;
                title = "Play speech cc";
                lineID = -1;
            #if UNITY_EDITOR
            override public void ShowGUI (List<ActionParameter> parameters)
                if (!string.IsNullOrEmpty (messageText))
                    EditorGUILayout.BeginHorizontal ();
                    GUILayout.FlexibleSpace ();
                    EditorGUILayout.LabelField ("Character count: " + messageText.Length, EditorStyles.miniLabel, GUILayout.Width (100f));
                    EditorGUILayout.EndHorizontal ();
                base.ShowGUI (parameters);

    This Action can be loaded into the AC Actions Manager, and the default Dialogue: Play speech Action can then be disabled (once existing speech Actions are replaced with this new type).

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.
Do NOT follow this link or you will be banned from the site!