Forum rules - please read before posting.

Hotspots Flash all clumped together

Hi Chris, after updating to the latest AC, I've noticed that my flash SmallHotspotLabels are now all clumped together rather than placed where the actul hotspot should be. Please see video and screenshots here:

https://www.dropbox.com/scl/fo/gdzhg7naku2zax6tntum0/h?rlkey=muzdtsv8k0xzlrvu93wuy3brb&dl=0

And my flashhotspots code below:

using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

    [System.Serializable]
    public class ActionFlashHotSpots : Action
    {

        public float flashDuration = 1.5f;
        public string menuName = "SmallHotspotLabels"; // The name of the Hotspot Menu to copy
        public string labelName = "HotspotSmallLabel"; // The Label element of the Hotspot Menu
        private List<Menu> localMenus;

        public override ActionCategory Category { get { return ActionCategory.Custom; }}
        public override string Title { get { return "FlashHotspot"; }}

        public override float Run ()
        {
            if (!isRunning)
            {
                localMenus = new List<Menu> ();

                Hotspot[] hotspots = FindObjectsOfType (typeof (Hotspot)) as Hotspot[];
                foreach (Hotspot hotspot in hotspots)
                {
                  if (hotspot.enabled && hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot.highlight && hotspot != KickStarter.playerInteraction.GetActiveHotspot () && (KickStarter.settingsManager.hotspotDetection == HotspotDetection.MouseOver || KickStarter.player.hotspotDetector.IsHotspotInTrigger (hotspot)))



                    {
                        hotspot.Flash ();
                        ShowForHotspot (hotspot);
                    }
                }

                isRunning = true;
                return flashDuration;
            }

            foreach (Menu menu in localMenus)
            {
                menu.TurnOff ();
                KickStarter.playerMenus.UnregisterCustomMenu (menu, false);
            }

            isRunning = false;
            return 0f;
        }

        private void ShowForHotspot (Hotspot hotspot)
        {
            Menu menuToCopy = PlayerMenus.GetMenuWithName (menuName);
            if (menuToCopy == null)
            {
                ACDebug.LogWarning ("Cannot find menu with name '" + menuName + "'", this);
                return;
            }
            Menu 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.title += this.name;
            myMenu.SetHotspot (hotspot, null); // Link it to the Hotspot

            if (!string.IsNullOrEmpty (labelName))
            {
                (myMenu.GetElementWithName (labelName) as MenuLabel).labelType = AC_LabelType.Normal;
                (myMenu.GetElementWithName (labelName) as MenuLabel).label = hotspot.GetName (Options.GetLanguage ());
            }

            myMenu.TurnOn ();

            KickStarter.playerMenus.RegisterCustomMenu (myMenu, true);
            localMenus.Add (myMenu);
        }

        #if UNITY_EDITOR

        public override void ShowGUI ()
        {
            menuName = EditorGUILayout.TextField ("Menu name:", menuName);
            labelName = EditorGUILayout.TextField ("Label name:", labelName);
        }

        #endif

    }

}

Comments

  • What version were you updating from?

  • edited February 11

    I cannot remember. I only tried the flash hotspots recently, a good while after updating, and they were clumped together. I an on Version 1.79.3, UNity 2021.3.15f1

  • Replace:

    myMenu.SetHotspot (hotspot, null); // Link it to the Hotspot
    

    with:

    myMenu.HotspotLabelData.SetData (hotspot, string.Empty);
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.