Forum rules - please read before posting.

All dialogue lines are considered to be narration

edited March 6 in Technical Q&A

I gathered all my game text for translating and I have the problem, that every character is added as "Narrator" as the speaker in the speech list (in Speech Manager).

I know why this happend: In every Action List I made where characters say something I defined the characters as Action List parameters of type GameObject and use the parameter as the speakers in the "Dialogue: Play Speech". This way when gathering the text AC doesn't know, which GameObject is there at runtime and counts it to be a narration. That is a really big problem currently.

Would a feature be technically possible to take eg. the Action List Parameter name to be the speaker name that is saved to the Speech Manager entry if the speaker is a ActionList parameter? Or should AC recognise the connected GameObjects that are used as default values for the GameObject parameters, and something else is wrong?

Right now I have only Player and some thousands of Narration lines which makes it impossible to work with further.

Unity 2018.4.36f1
AC 1.75.0


  • Technically, it may be possible to rely on e.g. the default parameter value, but as parameters are intended to be overwritten at runtime, such data added to the Speech Manager won't accurately represent which character says the line.

    Can you elaborate on the situation, and need for so many lines to be set through parameters? Such a situation technically means that any character can say a given line.

    Aside from the use of parameters, the other way to avoid assigning a GameObject directly into the Action is to rely on Player-switching, and assign your NPCs as Players that can then be assigned via dropdown.

  • I used ActionList parameters for every character throughout the game because I designed everything with dummy characters until now and now as the real characters are being implemented I only need to drag them into the default fields of the ActionList parameters instead of all "Dialogue: Play speech" Actions. While playing the game this works like a charme, there is only the problem with the speaker recognition while gathering text, though.

    And what about an option when gathering text to use parameter names as speaker captions if used in a "Dialogue: Play speech" Action? Even if the value of the parameters changes at runtime (by using an Action for several characters) it would give a better accuracy then always having "Narrator" as the speaker.

  • Even if the value of the parameters changes at runtime (by using an Action for several characters) it would give a better accuracy then always having "Narrator" as the speaker.

    I feel that appearing more accurate but isn't 100% so could be more problematic.

    It is possible, however, to update a speech Action by transferring its default parameter to the Speaker field automatically through script.

    For example:

    using UnityEngine;
    using AC;
    public class UpdateSpeechActions : MonoBehaviour
        [ContextMenu ("Update")]
        private void UpdateAllInScene ()
            ActionList[] actionLists = FindObjectsOfType<ActionList> ();
            foreach (ActionList actionList in actionLists)
                UpdateActionList (actionList);
        private void UpdateActionList (ActionList actionList)
            bool isChanged = false;
            foreach (Action action in actionList.actions)
                if (action == null) continue;
                ActionSpeech actionSpeech = action as ActionSpeech;
                if (actionSpeech == null) continue;
                if (actionSpeech.parameterID >= 0)
                    ActionParameter parameter = actionList.GetParameter (actionSpeech.parameterID);
                    if (parameter == null) continue;
                    if (parameter.parameterType == ParameterType.GameObject && parameter.gameObject && parameter.gameObject.GetComponent<AC.Char> ())
                        actionSpeech.speaker = parameter.gameObject.GetComponent<AC.Char> ();
                        actionSpeech.parameterID = -1;
                        actionSpeech.ShowGUI (actionList.parameters);
                        isChanged = true;
                        Debug.Log ("Updated Action " + actionList.actions.IndexOf (action));
            if (isChanged)
                UnityVersionHandler.CustomSetDirty (actionList, true);

    To use, place in a scene and choose "Update" from its cog menu to update all ActionLists found in that scene.

  • I like the idea, but unfortunately the script throws an error at line 36 (ShowGUI):

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.GUILayoutUtility.DoGetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Modules/IMGUI/GUILayoutUtility.cs:453)
    UnityEngine.GUILayoutUtility.GetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Modules/IMGUI/GUILayoutUtility.cs:450)
    UnityEditor.EditorGUILayout.GetControlRect (System.Boolean hasLabel, System.Single height, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9288)
    UnityEditor.EditorGUILayout.GetControlRect (System.Boolean hasLabel, System.Single height, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9283)
    UnityEditor.EditorGUILayout.LabelField (UnityEngine.GUIContent label, UnityEngine.GUIContent label2, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7451)
    UnityEditor.EditorGUILayout.LabelField (System.String label, System.String label2, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7432)
    AC.ActionSpeech.ShowGUI (System.Collections.Generic.List`1[T] parameters) (at Assets/AdventureCreator/Scripts/Actions/ActionSpeech.cs:363)
    UpdateSpeechActions.UpdateActionList (AC.ActionList actionList) (at Assets/Looky/Objekte/CustomScripts/UpdateSpeechActions.cs:36)
    UpdateSpeechActions.UpdateAllInScene () (at Assets/Looky/Objekte/CustomScripts/UpdateSpeechActions.cs:13)
  • That may be an issue with Unity, but you could bypass it by commenting out the "CustomSetDirty" call at the end. That is there to ensure the changes are recorded by Unity, but you should be able to achieve the same by viewing the ActionLists up in the Editor / Inspector afterwards.

  • No, it's not the "CustomSetDirty", but it seems to work as expected if I remove the line
    actionSpeech.ShowGUI (actionList.parameters);
    This line throughs the error I posted. I'll test the script with other scenes, but it seems it solves my problem very well.
    What exactly does the "ShowGUI" method do? Is it not save to use the script without the line I commented out?

  • No, it's not the "CustomSetDirty"

    You're right - I meant ShowGUI.

    This function is used to draw the Action's UI. It may not strictly be necessary here, but it'll help re-assign Constant ID values with the speaker GameObject if appropriate. Again, you should be able to bypass this particularly if you view the ActionList to check afterwards.

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.