Adventure Creator Wikia
Advertisement

Hotspots can have icons that show either a fixed graphic, or represent the first-available "Use" interaction. These are set under the "Hotspot settings" panel in the Settings Manager.

This script demonstrates how such icons can be shown at any time - in this case, when the player holds down an input button.

To use it:

  • Define an input named "HighlightAll" in Unity's Input Manager and map it to e.g. "space"
  • In the Settings Manager, set Display Hotspot icons to Via Script Only.
  • Paste the code below into a C# script named ShowHotspotIcons, and attach it to a GameObject in your scene

ShowHotspotIcons.cs:

using UnityEngine;
using System.Collections;
using AC;

public class ShowHotspotIcons : MonoBehaviour
{

    public float speed = 5f;
    Hotspot[] hotspots;

    void Start ()
    {
        hotspots = FindObjectsOfType (typeof (Hotspot)) as Hotspot[];
    }

    void Update ()
    {
        if (!KickStarter.stateHandler.IsInGameplay () || KickStarter.playerInput.InputGetButtonUp ("HighlightAll"))
        {
            SetHighlights (false);
        }
		else if (KickStarter.playerInput.InputGetButtonDown ("HighlightAll"))
        {
            SetHighlights (true);
        }
    }

    void SetHighlights (bool show)
    {
        foreach (Hotspot hotspot in hotspots)
        {
            if (hotspot.IsOn () && hotspot.highlight)
            {
                hotspot.SetIconVisibility (show, speed);
            }
            else
            {
                hotspot.SetIconVisibility (false, speed);
            }
        }
    }

}
Advertisement