Forum rules - please read before posting.

Changing cursor icon when mouse is over a hotspot with a specific label

Hi, I wish to change the displayed cursor icon when the mouse is over hotspots with a specific label. I am planning to use the OnHotspotSelect **and **OnHotspotSelect events to change it and back. But then I realize there is only one MainCursor setting. Do I have to change all the main cursor settings in the Cursor Manager? Or is there a way to define another cursor, so I can just switch it?

Also, I realized there is a script mouseovericon, may I ask how to use that properly?

Thanks.

Comments

  • What do you mean by "specific label". As in, the name of the Hotspot itself?

    What's your Interaction method set to? If Context Sensitive, it's possible to change the cursor to match that of the Hotspot's Use interaction icon. Otherwise, you can define a "Hotspot cursor" graphic in the Cursor Manager that is shown when hovering over a Hotspot. This is what mouseOverIcon refers to.

    If you want to change things by script, best to change this, rather than the Main Cursor graphic - as you can then do without an OnHotspotDeselect event.

    To change this texture via OnHotspotSelect, you'd do something like:

    using UnityEngine;
    using AC;
    
    public class ChangeCursor : MonoBehaviour
    {
    
        public string labelCheck = "MyLabel";
        public Texture2D normalTexture, customTexture;
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnHotspotSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnHotspotSelect; }
    
        private void OnHotspotSelect (Hotspot hotspot)
        {
            if (hotspot.gameObject.name == labelCheck)
            {
                KickStarter.cursorManager.mouseOverIcon.ReplaceTexture (customTexture);
            }
            else
            {
                KickStarter.cursorManager.mouseOverIcon.ReplaceTexture (normalTexture);
            }
        }
    
    }
    
  • edited June 2020

    Thanks. I mean the Hotspot label KickStarter.playerInteraction.GetActiveHotspot ().GetFullLabel ()

    I turned out using this:

    if (KickStarter.settingsManager.movementMethod == MovementMethod.PointAndClick &&
    KickStarter.playerInteraction.GetActiveHotspot ().GetFullLabel () == "ExitCloseUp")
    {
    KickStarter.cursorManager.allowInteractionCursor = true;
    } else {
    KickStarter.cursorManager.allowInteractionCursor = false;
    }

    So that I can predefine all the cursor details as one of the Interaction Icons, without needing to change the texture of other settings.

  • Hi @ChrisIceBox, I'm using the latest Adventure Creator version (1.75.6) and this code is not working anymore. I think there is a bug on "ClearCache" function. There are 2 different implementation in CursorIcon class. One is overriding and hiding the concrete implementation.

    I suggest this fix in order to make possible to use ReplaceTexture function.

    public override void ClearCache ()
    {
        base.ClearCache();
        cachedLabel = string.Empty;
    }
    
  • Thank you @nova1337 - good spot!

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.