Forum rules - please read before posting.

Easy way to have all cursors off via a variable?

Hi Chris,

Exporting for Iphone and I don't want any cursors visible for the port, is there an easy way to have a variable that shuts them off regardless of cursor enabled/disabled in engine:systems? Thanks

Comments

  • A variable isn't necessary - you can use the Engine: Check platform Action to alter behaviour based on platform.

    If you check Hide cursor when locked in screen's centre?, the cursor will be hidden when locked. You can then use the Player: Constrain Action to lock the cursor and hide it.

  • Hi, so this seems to stop any input for hotspot, I just want the user to be able to click on things but without any visible cursor

  • Set the Cursor Manager's Display cursor field to Never.

    To set this through script at runtime, see this tutorial.

  • edited March 29

    So, i tried this script, but not all cursors are off, look, use etc are still visible

    >! using UnityEngine;
    using AC;
    
    public class CursorManagerController : MonoBehaviour
    {
        void Start()
        {
            // Get reference to the Cursor Manager
            CursorManager cursorManager = KickStarter.cursorManager;
    
            // Set Display cursor field to Never
            cursorManager.cursorDisplay = CursorDisplay.Never;
        }
    }
    

    Any chance you can help?

  • edited March 30

    Got this to work

    using UnityEngine;
    using AC;
    using System.Linq;
    
    public class CursorManagerController : MonoBehaviour
    {
        void Start()
        {
            // Get reference to the Cursor Manager
            CursorManager cursorManager = KickStarter.cursorManager;
    
            // Set Display cursor field to Never
            cursorManager.cursorDisplay = CursorDisplay.Never;
    
            // Get all cursor icons as a list
            var cursorIconsList = cursorManager.cursorIcons;
    
            // Loop through each cursor icon and set its texture to null
            foreach (CursorIcon cursorIcon in cursorIconsList)
            {
                cursorIcon.texture = null;
            }
        }
    }
    

    However, the cutscene cursor is still visibsle

  • This will only take effect if your Cursor rendering is set to Hardware - is that the case in your iOS builds?

  • edited March 30

    no, it is set to software. is there a way to replace the cutscene cursor to a blank cursor sprite through code please?

  • You can use:

    KickStarter.cursorManager.waitIcon.ReplaceTexture (emptyTexture);
    

    Where "emptyTexture" as a public Texture2D variable, set in the Inspector to an invisible texture.

  • Thanks, here is the code as a custom action list for anyone interested in using it:

    using UnityEngine;
    using UnityEditor;
    using AC;
    
    [System.Serializable]
    public class ToggleCursorOptionsAction : Action
    {
        public bool enableCursorOptions = true;
        public Texture2D emptyTexture;
    
        public ToggleCursorOptionsAction()
        {
            this.isDisplayed = true;
            category = ActionCategory.Custom;
            title = "Toggle Cursor Options";
            description = "Toggle the cursor options on or off.";
        }
    
        override public float Run()
        {
            ToggleCursorOptions();
            return 0f;
        }
    
        private void ToggleCursorOptions()
        {
            CursorManager cursorManager = KickStarter.cursorManager;
    
            if (enableCursorOptions)
            {
                cursorManager.cursorDisplay = CursorDisplay.Always;
    
                // Set the texture to some default texture or whatever texture you want
                foreach (CursorIcon cursorIcon in cursorManager.cursorIcons)
                {
                    cursorIcon.texture = emptyTexture;
                }
    
                // Replace the texture of the Cutscene cursor
                cursorManager.waitIcon.ReplaceTexture(emptyTexture);
            }
            else
            {
                cursorManager.cursorDisplay = CursorDisplay.Never;
    
                // Clear all cursor textures
                foreach (CursorIcon cursorIcon in cursorManager.cursorIcons)
                {
                    cursorIcon.texture = null;
                }
    
                // Replace the texture of the Cutscene cursor back to null
                cursorManager.waitIcon.ReplaceTexture(null);
            }
        }
    
        #if UNITY_EDITOR
    
        override public void ShowGUI()
        {
            enableCursorOptions = EditorGUILayout.Toggle("Enable Cursor Options", enableCursorOptions);
            emptyTexture = (Texture2D)EditorGUILayout.ObjectField("Empty Texture", emptyTexture, typeof(Texture2D), false);
        }
    
        override public bool ReferencesObjectOrID(GameObject gameObject, int id)
        {
            return false;
        }
    
        #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.