Forum rules - please read before posting.

Unity UI Toolkit?

edited November 10 in Technical Q&A

Hi does AC work with Unity UI Toolkit? Or it only works with Unity uGUI?

Comments

  • Built-in, only Unity uGUI.

    However, it is possible to have UI Toolkit-based Buttons run AC ActionList asset files when clicked with this simple script:

    using UnityEngine;
    using UnityEngine.UIElements;
    using AC;
    
    public class ToolkitButtonActionList : MonoBehaviour
    {
    
        public string buttonName;
        public ActionListAsset actionListAsset;
        public UIDocument uiDocument;
    
        void Start()
        {
            if (uiDocument == null) uiDocument = GetComponent<UIDocument>();
            if (uiDocument == null) return;
    
            var button = uiDocument.rootVisualElement.Q(buttonName) as UnityEngine.UIElements.Button;
            button.RegisterCallback<ClickEvent>(OnClickButton);
        }
    
        void OnClickButton(ClickEvent clickEvent)
        {
            actionListAsset.Interact();
        }
    
    }
    
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.