Hi,
So I have my FlashHotspots script below, but I would like to edit it so that it instead flashes small Hotspot labels above each hotspot. The tricky part is, my in game usual Hotspot labels on hover are centered and large. Would I need to create a seperate Hotspot menu called SmallHotspotLabels set to above hotspot for the new script (which I will need your help with) to turn on when specific input is pressed?
Also, if I wanted my labels (Hotspot and SmallHotspotLabels menus) to animate a little, I assume they would have to be Unity UI prefab? See Script for just highlighting hotspots on input:
using UnityEngine;
if UNITY_EDITOR
using UnityEditor;
endif
namespace AC
{[System.Serializable]
public class ActionFlashHotSpots : Action
{
// Declare variables here
public ActionFlashHotSpots ()
{
this.isDisplayed = true;
category = ActionCategory.Custom;
title = "FlashHotspot";
description = "Flashes Hotspots";
}
override public float Run ()
{
/*
* This function is called when the action is performed.
*
* The float to return is the time that the game
* should wait before moving on to the next action.
* Return 0f to make the action instantenous.
*
* For actions that take longer than one frame,
* you can return "defaultPauseTime" to make the game
* re-run this function a short time later. You can
* use the isRunning boolean to check if the action is
* being run for the first time, eg:
*/Hotspot[] hotspots = FindObjectsOfType (typeof (Hotspot)) as Hotspot[]; foreach (Hotspot hotspot in hotspots) { if (hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot.highlight && hotspot != KickStarter.playerInteraction.GetActiveHotspot ()) { hotspot.highlight.Flash (); } } if (!isRunning) { isRunning = true; return defaultPauseTime; } else { isRunning = false; return 0f; } } override public void Skip () { /* * This function is called when the Action is skipped, as a * result of the player invoking the "EndCutscene" input. * * It should perform the instructions of the Action instantly - * regardless of whether or not the Action itself has been run * normally yet. If this method is left blank, then skipping * the Action will have no effect. If this method is removed, * or if the Run() method call is left below, then skipping the * Action will cause it to run itself as normal. */ Run (); } #if UNITY_EDITOR override public void ShowGUI () { // Action-specific Inspector GUI code here AfterRunningOption (); } public override string SetLabel () { // (Optional) Return a string used to describe the specific action's job. return string.Empty; } #endif
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
A menu can only appear in one place at a time. For menu to appear in multiple places, it needs to be duplicated through script.
A script that duplicates Hotspot menus so that they can appear when multiple Hotspots are highlighted can be found on the AC wiki:
https://adventure-creator.fandom.com/wiki/Simultaneous_Hotspot_labels
ok, i have the script in my project but how do i incorporate it with the above script to flash only those hotspots? thanks!
The script can be attached to any of the Hotspots you want it to show for, but won't respond to Flash calls. Instead, you'll have to call HighlightOn and HighlightOff separately with a short gap in between:
So will all hotspots flash regardless of player vicinity? and I attach this to a gameobject in scene? And will flash the new hotspot menu created for the wiki script?
The code above is an update to your custom Action's run function, which does account for player vicinity with:
Attach the wiki script to your Hotspots.
It will show the Hotspot menu for Hotspots being highlighted.
Ok, so just checking as I am not always using player vicinity, but mouse over, so will this still account for that?
So I add this code to the end of the wiki script?
I have two hotspot menus, mouse over, and flash. I only want the flash hotspots to be visible when the player calls them with an input.
Can the player call this with an input?
I also don't want the new hotspots to be called on mouse over in play, and only called via player input all together.
Plus, currently it is just highlighting the new hotspot singularly when cursor over, instead of highlighting all the hotspots with the script on.
See video here:
https://www.dropbox.com/s/l6uirangesmqrzk/MultiHostposts.mov?dl=0
I only want my main hotspot (big one at top) on mouse over, and smaller ones all to appear at the same time on player input. Thanks
Probably best to combine both scripts into a single Action - that way you can run it via an Active Input:
Getting this error, and script not appearing in the actions manager in Custom list:
The script '/Users/jlightfoot001/Dropbox/Sleepytime Village URP/Assets/Sleepytime Village/Scripts/CustomActions/ActionFlashHotspots.cs' must derive from AC's Action class in order to be available as an Action.
and this:
The script '/Users/jlightfoot001/Dropbox/Sleepytime Village URP/Assets/Sleepytime Village/Scripts/CustomActions/ActionFlashHotspots.cs' must derive from AC's Action class in order to be available as an Action.
The filename must match the class name, ActionFlashHotSpots, and it's case-sensitive.
ok changed that, i get this error:
Assets/Sleepytime Village/Scripts/CustomActions/ActionFlashHotSpots.cs(39,24): error CS0029: Cannot implicitly convert type 'bool' to 'float'
Typo. Replace:
with:
ok awesome thanks! And how do i set this up for input so that when the player presses F for example, all the new smaller hotspots flash?
Use an Active Input to run an ActionList with the above Action.
You can lock the original Hotspot menu - it won't interfere with the duplicates that the Action creates.
ok, I have set it up like so, but on pressing F, nothing happens? Plus, my new flashhostpost only menu is locked off, yet is still active on hover in play? It shows along with my normal hotspots (all in screenshots)
https://www.dropbox.com/sh/0zkr6vzeawd7esm/AAAmUEH16SvHGvJhgEq0rFnfa?dl=0
"Input Button" refers to the listing in Unity's Input Manager - not the key itself.
works perfectly! thanks!!
final q's:
Can i have them stay visible until key is depressed?
How would I get the label background texture to auto resize to length of label string? I assume this is a UI prefab and not AC menu?
When I press F to flash the hotspots, it is flashing hidden hotspots too, any way to sort this?
Also, can hotspots automatically stay out of other hotspots way? see screenshot:
https://www.dropbox.com/sh/0zkr6vzeawd7esm/AAAmUEH16SvHGvJhgEq0rFnfa?dl=0
Not through flashing. Flashing refers to to the highlight effect turning on and off in one go - you would need a rewrite to have the behaviour be different.
Using Unity UI, it's a case of attaching the correct UI components, e.g. Content Size Fitter. This isn't related to AC, however.
Hidden in what way?
A Hotspot menu with a "Position" property of "On Hotspot" will show over that Hotspot's centre. You can override this on a per-Hotspot basis though by creating a new empty GameObject to represent the intended position, and assigning it as the Hotspot's Centre-point (override) Inspector field.
They are disabled but still showing when flashing