Forum rules - please read before posting.

Turn off Highlight script on the certain objects?

edited November 2019 in Technical Q&A

Hi Chris:)

My input FlashHotspots is activated, so when I press Space button all my objects that have Highlight script are flashing and show some nice icon (really cool function to show all interactions in the scene as a hint). I have quite a lot of hotspots and for some purposes I need to teleport a few of them out off the scene (where camera will not see them) but leave them to be turned on. In the same time I don't want to flash objects that are associated with these hotspots anymore when I press Space button. I know that I can simply turn off hotspots to do this but I really need to leave these hotspots to be turned on.

Is there a way how to turn off Highlight script on the certain objects and back it again when you need it?

Comments

  • You can connect/disconnect a Highlight component from its Hotspot through script by modifying the Hotspot's highlight variable.

    Example script, attached to the Hotspot:

    using UnityEngine;
    using AC;
    
    public class HotspotHighlightConnector : MonoBehaviour
    {
    
        private Hotspot hotspot;
        private Highlight highlight;
    
        private void OnEnable ()
        {
            hotspot = GetComponent <Hotspot>();
            highlight = GetComponent <Highlight>();
        }
    
        private void OnDisable ()
        {
            Connect ();
        }
    
        public void Connect ()
        {
            if (hotspot) hotspot.highlight = highlight;
        }
    
        public void Disconnect ()
        {
            if (hotspot) hotspot.highlight = null;
        }
    
    }
    

    You could then use the Object: Call event Action to call this script's Connect and Disconnect functions when appropriate.

  • edited November 2019

    Thank you Chris, working perfect!!! <3

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.