Forum rules - please read before posting.

Highlight Calling Custom Events not working for sprite change

I have a sprite that highlights on hotspot rollover, and in addition, I've been testing calling custom events. I know that it's working by selecting the sprite that has the hotspot, because having it run Examine Interactions, for example, worked.

What I'm now trying to do is call the Sprite Renderer and change the sprite to one thing with Highlight On and back to the original with Highlight Off. However, this particular custom event does not seem to fire (no change is made to the sprite.

Am I missing anything here?

Thanks!

Comments

  • For reference, here are my Highlight settings. The object on the left is the object with the hotspot, and the hotspot is set to highlight the same object.

    https://www.dropbox.com/s/uic0d4kog1feqrn/highlight.png?dl=0

  • Also, changing from Runtime Only to Editor and Runtime did not make a difference.

  • Works for me - what's your Unity version?

    When it comes to triggering events, an alternative to using the Highlight component is to rely on script-based events. The OnHotspotSelect and OnHotspotDeselect events generally serve the same purpose:

    using UnityEngine;
    using AC;
    
    public class HotspotSpriteChanger : MonoBehaviour
    {
    
        public Hotspot hotspot;
        public SpriteRenderer spriteRenderer;
        public Sprite onSprite;
        public Sprite offSprite;
    
        private void OnEnable ()
        {
            EventManager.OnHotspotSelect += MySelect;
            EventManager.OnHotspotDeselect += MyDeselect;
        }
    
        private void OnDisable ()
        {
            EventManager.OnHotspotSelect += MySelect;
            EventManager.OnHotspotDeselect += MyDeselect;
        }
    
        private void MySelect (Hotspot hotspot)
        {
            if (this.hotspot == hotspot)
            {
                spriteRenderer.sprite = onSprite;
            }
        }
    
        private void MyDeselect (Hotspot hotspot)
        {
            if (this.hotspot == hotspot)
            {
                spriteRenderer.sprite = offSprite;
            }
        }
    
    }
    
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.