Forum rules - please read before posting.

Can't hide cursor

Trying to hide software cursor through script in AC 1.50f
How do I do it?
I'm trying this with no avail:
public Texture2D normalTexture;

// Use this for initialization
void Start () {
        normalTexture = AC.KickStarter.cursorManager.pointerIcon.texture;
    }

    // Update is called once per frame
void Update () {

}
    void OnMouseEnter()
    {
        AC.KickStarter.cursorManager.pointerIcon.texture = null;   
    }

    void OnMouseLeave()
    {
        AC.KickStarter.cursorManager.pointerIcon.texture = normalTexture;

    }

}

Is there any other way to hide cursor?
Thank you.

Comments

  • edited December 2020

    How and when are you calling your OnMouseEnter/OnMouseLeave functions? Does the cursor hide if you e.g. call OnMouseEnter() directly within Update()?

    Are you using Software or Hardware cursor rendering?

    Insead of altering the texture itself, try altering the state of the Cursor Manager's "Display cursor" field:

    AC.KickStarter.cursorManager.cursorDisplay = CursorDisplay.Never;
    
    
    AC.KickStarter.cursorManager.cursorDisplay = CursorDisplay.Always;
    
  • edited December 2020

    Software cursor.
    I attach this script to my hotspot.
    In Use Interaction, drop down list Cursor: Eye to use when hover, in cursor manager that cursor has Icon ID 12.

    I have conditions when I want to show Cursor ID 13 (Hand) instead of ID 12 (Eye) OnMouseEnter and revers OnMouseLeave of my hotspot.
    Cursor Hand ID 13 is animated. But just a single sprite Cursor Hand also would do if it's impossible.

    When mouse enters the hotspot, it hides the main cursor, but still shows Cursor ID 13 (Eye) and when leave hotspot never shows the main cursor. You need to manually set it to Dispaly Always in cursor manager after.

    public class ActiveCursorHover : MonoBehaviour {

        // Use this for initialization
        void Start () {
        }
                // Update is called once per frame
        void Update () {
                    }
        void OnMouseEnter()
        {
            if (AC.GlobalVariables.GetIntegerValue(280) == 1)
            {
                AC.KickStarter.cursorManager.cursorDisplay = CursorDisplay.Never;
            }
        }
    
        void OnMouseLeave()
        {
            AC.KickStarter.cursorManager.cursorDisplay = CursorDisplay.Always;
        }
    
    }
    

    }

    I tried to work around. By adding Cursor Hand as an object to the scene, make it invisible and follow cursor. OnMouseEnter show it and hide Cursor. But still Cursor Eye kicks in from Use interaction's dropdown list Cursor: Eye.
    And still OnMouseLeave I never get the main cursor back, have to manually set to Display always in the manager.

    It seems obvious to me but I can't figure it out.
    Thank you for taking your time on this one Chris.

  • when leave hotspot never shows the main cursor.

    I think you want OnMouseExit rather than OnMouseLeave.

    I have conditions when I want to show Cursor ID 13 (Hand) instead of ID 12 (Eye) OnMouseEnter and revers OnMouseLeave of my hotspot.

    So it's not the main cursor (pointerIcon) you want to change, but which interaction icon is displayed as the cursor?

    The "interaction icon as cursor" behaviour can be set with:

    AC.KickStarter.cursorManager.allowInteractionCursor
    

    But, if you're trying to change which icon is shown - not hide it completely - it'd be worth instead changing the Hotspot itself.

    If you create a second Interaction in your Hotspot, mapped to the same Interaction ActionList, but to the Hand icon (13) instead of Eye (12), then you can enable it (and disable the original) when you want it to show that different icon.

    That can be done with the Hotspot: Change interaction Action.

  • edited December 2020

    Yes, I just want to change the interaction icon of the hotspot when hover it, instead of Eye icon show Hand icon if Difficulty == 0.

    I don't think your last suggestion works.
    I created the second Interaction in my Hotspot by clicking on + (right top conner)
    and mapped exact the same interaction, only changed the Cursor drop list to Hand.

    How do I then enable the Hand icon ?
    This means I have to Enable/Disabel it from the other interaction.

    For instance in my main menu Options if I change difficulty to 0 from 1, I would need to constantly run on the loop (all the time in any scene) an interaction checking for Difficulty conditions and if it is 0 then disable all the hotspots Use interaction Eye so to pave the way for Hand Icon.
    Unless I'm doing it wrong.

    You think it would be easier just to make invisible Hand sprite follow mouse and hide the cursor with OnMouseEnter and show it OnMouseExit and show the Hand Sprite?

    And this would be with the script that I posted before and just drop that script to any hotspot I want to change icons.
    Thanks for OnMouseExit , with this I think I can do above.

  • You didn't specify the circumstances under when you'd want to make such a change. If it's a global option, then no - an Action wouldn't be best.

    What you can instead to is change the Icon ID mapped to a particular interaction, based on a Global Variable's value.

    For example.

    int difficulty = GlobalVariables.GetIntegerValue (2); // where 2 = ID of "Difficulty"
    Button useButton = GetComponent <Hotspot>().GetFirstUseButton ();
    if (difficulty == 0)
    {
        useButton.iconID = 12;
    }
    else
    {
        useButton.iconID = 13;
    }
    
  • Omg, brilliant! Thank you.
    I should have looked into AC.Hotspot Class Reference
    instead of being stuck with AC.CursorManager Class.

    Great asset, great support!

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.