Forum rules - please read before posting.

Change AC menu font color through Action

edited May 2023 in Technical Q&A

Hi there,
I've successfully created a custom action to change a menu element font and font size but I can't succeed in changing font color.
This is my script:

using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{
    [System.Serializable]
    public class ActionChangeFontColor : Action
    {
        // Declare variables here
        public string MenuName;
        public string ElementName;
        public Color MyFontColor;

        public ActionChangeFontColor()
        {
            this.isDisplayed = true;
            category = ActionCategory.Menu;
            title = "Change Menu Font Color";
            description = "Change Menu Font color";
        }
        override public float Run()
        {
            AC.PlayerMenus.GetElementWithName(MenuName, ElementName).fontColor = MyFontColor;
            return 0f;
        }
#if UNITY_EDITOR

        override public void ShowGUI()
        {
            // Action-specific Inspector GUI code here
            MenuName = EditorGUILayout.TextField("Menu name:", MenuName);
            ElementName = EditorGUILayout.TextField("Element name:", ElementName);
            MyFontColor = EditorGUILayout.ColorField("Font Color:", MyFontColor);

            AfterRunningOption();
        }
#endif
    }
}

no matter which color I choose, the text stops appearing.
What am I doing wrong?
Thanks!

Comments

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.