FANDOM


The "FlashHotspots" input button can be used to flash up Hotspot highlight effects to reveal their location. However, this only works for the moment the input button is first pressed. The following script allows you to instead highlight Hotspots for the entire duration an input button is held down.

To use it:

  1. Define an input button in Unity's Input Manager named "FlashHold". This can replace the existing "FlashHotspots" input, if defined.
  2. Create a new C# script named HoldToFlash.cs, and paste the code below into it
  3. Attach the new Flash To Hold component to an empty GameObject in the scene

HoldToFlash.cs:

using UnityEngine;

namespace AC.WC
{

public class HoldToFlash : MonoBehaviour
{

#region Variables

public string inputName = "FlashHold";
private bool isInGameplay;

#endregion


#region Variables

private void OnEnable ()
{
EventManager.OnExitGameState += OnExitGameState;
}


private void OnDisable ()
{
EventManager.OnExitGameState -= OnExitGameState;
}


private void Update ()
{
if (isInGameplay)
{
if (Input.GetButtonDown (inputName))
{
FlashHotspots ();
}
else if (Input.GetButtonUp (inputName))
{
FlashHotspots (true);
}
}
}

#endregion


#region PrivateFunctions

private void OnExitGameState (GameState gameState)
{
isInGameplay = (gameState != GameState.Normal);
if (!isInGameplay)
{
FlashHotspots (true);
}
}


private void FlashHotspots (bool cancel = false)
{
Hotspot[] hotspots = KickStarter.stateHandler.Hotspots.ToArray ();
foreach (Hotspot hotspot in hotspots)
{
if (hotspot.highlight)
{
if (cancel)
{
hotspot.highlight.CancelFlash ();
}
else if (hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot != KickStarter.playerInteraction.GetActiveHotspot ())
{
hotspot.highlight.flashHoldTime = 1000f;
hotspot.highlight.Flash ();
}
}
}
}

#endregion

}

}
Community content is available under CC-BY-SA unless otherwise noted.