FANDOM


This script allows you to display multiple Hotspot labels at the same time - one for each highlight Hotspot.  It works by using the Highlight component's On/Off events to control a copy of a Hotspot menu defined in the Menu Manager.

Note that this requires AC v1.60.5 or newer.

First, create a Hotspot menu (or modify the default one) with both an Appear type and Position of On Hotspot.  To prevent it showing up normally as well, also check Start game locked off? (our copies will be unlocked through script).

Next, define a Highlight component for each Hotspot.  If you don't want the Highlight to have a visible effect on any mesh, uncheck Auto-brighten materials?.

Create a new C# script named MultiHotspotLabel, and attach it to each Highlight GameObject:

using UnityEngine;
using AC;

public class MultiHotspotLabel : MonoBehaviour
{

    public string menuName = "Hotspot"; // The name of the Hotspot Menu to copy
    private Menu myMenu; // Our own local Menu


    public void ShowForHotspot (Hotspot hotspot)
    {
        // Call this function to show a new Menu linked to the given Hotspot
        if (myMenu == null)
        {
            // When run for the first time, create a new Menu and use the default Hotspot menu to copy from
            Menu menuToCopy = PlayerMenus.GetMenuWithName (menuName);
            myMenu = ScriptableObject.CreateInstance <Menu>();

            myMenu.CreateDuplicate (menuToCopy); // Copy from the default Menu
            myMenu.appearType = AppearType.Manual; // Set it to Manual so that we can control it easily
            myMenu.isLocked = false; // Unlock it so that the default can remain locked if necessary
            myMenu.SetHotspot (hotspot, null); // Link it to the Hotspot
        }

        // Turn the menu on
        myMenu.TurnOn ();
    }


    public void Hide ()
    {
        // Call this function to hide the Menu
        if (myMenu != null)
        {
            myMenu.TurnOff ();
        }
    }


    private void Update ()
    {
        // Update the Menu every frame
        if (myMenu != null)
        {
            KickStarter.playerMenus.UpdateMenu (myMenu);
        }
    }


    private void OnGUI ()
    {
        // Draw the Menu every OnGUI cycle.  This is not necessary if it is rendered with Unity UI.
        if (myMenu != null && myMenu.menuSource == MenuSource.AdventureCreator)
        {
            KickStarter.playerMenus.DrawMenu (myMenu, 0);
        }
    }

}

In its component Inspector (or by modifying the script), set the Menu Name value to the name of the Hotspot Menu listed in your Menu Manager that should be copied each time.

Back in each Highlight component, check Call custom events? and create new events for both the On Highlight On and On Highlight Off events.  On Highlight On should invoke its associated MultiHotspotLabel's ShowForHotspot method (setting the Hotspot parameter as appropriate), and On Highlight Off should invoke its Hide method.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.