Forum rules - please read before posting.

Action to Change the Main Cursor

Just in case someone find it useful:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{
    [System.Serializable]
    public class ActionChangeMainCursor : Action
    {
        public Texture2D newCursorTexture;

        public ActionChangeMainCursor()
        {
            isDisplayed = true;
            category = ActionCategory.Custom;
            title = "Change Main Cursor";
            description = "Change the main cursor texture.";
        }

        public override float Run()
        {
            if (KickStarter.cursorManager != null)
            {
                // Replace the texture of the main cursor
                KickStarter.cursorManager.pointerIcon.ReplaceTexture(newCursorTexture);
            }
            else
            {
                ACDebug.LogWarning("CursorManager not found in the scene.");
            }

            return 0f;
        }

#if UNITY_EDITOR
        public override void ShowGUI()
        {
            newCursorTexture = (Texture2D)EditorGUILayout.ObjectField("New Cursor Texture:", newCursorTexture, typeof(Texture2D), false);

            AfterRunningOption();
        }
#endif
    }
}
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.