FANDOM


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
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 () || Input.GetButtonUp ("HighlightAll"))
{
SetHighlights (false);
}
else if (Input.GetButtonDown ("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);
}
}
}

}