Adventure Creator Wikia

The built-in method of highlighting Hotspots when selecting them is to brighten their materials. This script provides a way to instead display an outline effect around them - through use of the Easy Performant Outline asset. This asset provides outline effects in 2D, 3D and the render pipeliens.

To use it:

  1. Import Easy Performant Outline into your AC project
  2. Attach the Outliner component to your AC MainCamera
  3. Create a new C# script file named EasyOutline.cs, and paste in the code below
  4. To any Hotspot you want to affect, attach the Easy Outline component to it. The Hotspot's Highlight field, if set, can be removed.
  5. An Outlinable component will be added automatically. Configure its Inspector so that it affects the correct meshes.
  6. The script will, by default, only show the front outline in a white colour. The script can be editied to change the style of outline if desired.

EasyOutline.cs:

using UnityEngine;
using System.Collections;
using EPOOutline;
using AC;


[RequireComponent (typeof (Outlinable))]
public class EasyOutline : MonoBehaviour
{

#region Variables

private Hotspot hotspot = null;
private Outlinable outlinable = null;
private const float speed = 5f;

#endregion


#region UnityStandards

private void Awake ()
{
hotspot = GetComponent<Hotspot>();
outlinable = GetComponent<Outlinable>();

outlinable.RenderStyle = RenderStyle.FrontBack;
outlinable.enabled = false;
outlinable.BackParameters.Enabled = false;
outlinable.FrontParameters.Color = Color.white;
outlinable.FrontParameters.DilateShift = 0f;
}


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


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

#endregion


#region PrivateFunctions

private void OnHotspotSelect (Hotspot hotspot)
{
if (this.hotspot == hotspot)
{
StopAllCoroutines ();
StartCoroutine (TransitionOn ());
}
}


private void OnHotspotDeselect (Hotspot hotspot)
{
if (this.hotspot == hotspot)
{
StopAllCoroutines ();
StartCoroutine (TransitionOff ());
}
}


private IEnumerator TransitionOn ()
{
outlinable.enabled = true;

while (outlinable.FrontParameters.DilateShift < 1f)
{
float newShift = outlinable.FrontParameters.DilateShift + (speed * Time.deltaTime);
newShift = Mathf.Clamp01 (newShift);
outlinable.FrontParameters.DilateShift = newShift;
yield return new WaitForEndOfFrame ();
}
}


private IEnumerator TransitionOff ()
{
while (outlinable.FrontParameters.DilateShift > 0f)
{
float newShift = outlinable.FrontParameters.DilateShift - (speed * Time.deltaTime);
newShift = Mathf.Clamp01 (newShift);
outlinable.FrontParameters.DilateShift = newShift;
yield return new WaitForEndOfFrame ();
}

outlinable.enabled = false;
}

#endregion

}