Forum rules - please read before posting.

FlashHotspots to flash small labels above each hotspot

2»

Comments

  • Disabled, as in the Hotspot component is disabled?

    Replace:

    if (hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot.highlight && hotspot != KickStarter.playerInteraction.GetActiveHotspot ())
    

    with:

    if (hotspot.enabled && hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot.highlight && hotspot != KickStarter.playerInteraction.GetActiveHotspot ())
    
  • Is there a way to also only have hotspots flash within player vicinity when this setting is on?

  • if (hotspot.enabled && hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot.highlight && hotspot != KickStarter.playerInteraction.GetActiveHotspot () && (KickStarter.player.hotspotDetector == null || KickStarter.player.hotspotDetector.IsHotspotInTrigger (hotspot)))
    
  • ah tried this, but then it doesn't work for scenes where hotspot detection is mouse over

  • if (hotspot.enabled && hotspot.IsOn () && hotspot.PlayerIsWithinBoundary () && hotspot.highlight && hotspot != KickStarter.playerInteraction.GetActiveHotspot () && (KickStarter.settingsManager.hotspotDetection == HotspotDetection.MouseOver || KickStarter.player.hotspotDetector.IsHotspotInTrigger (hotspot)))
    
  • Hi, is there a way to keep the hotspots shown until the player release the input key?

  • edited July 2024

    As a reminder here is the script

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
        [System.Serializable]
        public class ActionFlashHotSpots : Action
        {
            public float flashDuration = 3f;
            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;
            private bool keepFlashing = true;
    
            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;
                    keepFlashing = true;
                    CoroutineRunner.Instance.StartCoroutine(FlashHotspotsCoroutine());
                    return flashDuration;
                }
    
                StopFlashing();
                return 0f;
            }
    
            private IEnumerator FlashHotspotsCoroutine()
            {
                float timer = 0f;
    
                while (keepFlashing && timer < flashDuration)
                {
                    if (!Input.GetButton("FlashHotspots")) // Ensure this is configured in the Input Manager
                    {
                        keepFlashing = false;
                    }
    
                    timer += Time.deltaTime;
                    yield return null;
                }
    
                StopFlashing();
            }
    
            private void StopFlashing()
            {
                foreach (Menu menu in localMenus)
                {
                    menu.TurnOff();
                    KickStarter.playerMenus.UnregisterCustomMenu(menu, false);
                }
    
                isRunning = false;
            }
    
            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.HotspotLabelData.SetData(hotspot, string.Empty);
    
                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);
                flashDuration = EditorGUILayout.FloatField("Flash Duration:", flashDuration);
            }
    
            #endif
        }
    }
    

    I tried extending flash duration time to 3f but it didn't change anything fyi

  • A script that allows for the flash input to be held can be found on the AC wiki:
    https://adventure-creator.fandom.com/wiki/Hold_input_to_flash_Hotspots

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.