Forum rules - please read before posting.

Is it possible to edit the order that hotspots are highlighted when using CycleHotspot input?

edited February 2019 in Technical Q&A

So I'm trying to cycle through hotspots using the CycleHotspot input, but I don't understand what affects the order by which these hotspots are highlighted, as they seem to cycle through them randomly (at least not in the order of their placement in the scene) I'm guessing they are cycled through in the order that the hotspots were created? Is there any way I can define the order?

Also, how can I extend the time hotspots are flashed for without editing each hotspot separately through the inspector for each? Anyway to do it for all hotspots in a game? (Editing the code maybe?)

Comments

  • I'm guessing they are cycled through in the order that the hotspots were created?

    Hotspots are detected using Unity's provided OnTrigger functions. They should be listed in the order in which they enter the "Hotspot Detector" region, but if multiple appear in the same frame it's then involving Unity so I can't say.

    Is there any way I can define the order?

    Not currently, but I'll consider how this may be possible. Possible by use of a new custom event.

    Also, how can I extend the time hotspots are flashed for without editing each hotspot separately through the inspector for each?

    In Highlight.cs, replace line 396's "flashHoldTime" with the float value of your choice.

  • "Not currently, but I'll consider how this may be possible. Possible by use of a new custom event."

    That would be lovely, thanks!

    "In Highlight.cs, replace line 396's "flashHoldTime" with the float value of your choice."

    Awesome, thank you!

  • Just curious. Did this control of order of cycled hotspots ever happen?

  • Yes - the List of Hotspot objects can be modified by hooking into the OnModifyHotspotDetectorCollection custom event:

    using UnityEngine;
    using AC;
    using System.Collections.Generic;
    
    public class CustomHotspotOrdering : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnModifyHotspotDetectorCollection += OnModifyHotspotDetectorCollection; }
        private void OnDisable () { EventManager.OnModifyHotspotDetectorCollection -= OnModifyHotspotDetectorCollection; }
    
        private List<Hotspot> OnModifyHotspotDetectorCollection (DetectHotspots hotspotDetector, List<Hotspot> hotspots)
        {
            return hotspots;
        }
    
    }
    
  • Man I am having a tough go at this. I want to order my hotspots from left to right in the scene. Say furthest left is 0 in the list and furthest right is 5 out of 5. I cannot seem to rap my head around how to implement this. Seems simple enough but I can not get it. Sorry to be such a nuisance. 😖

  • This should do it:

    hotspots.Sort (delegate (Hotspot a, Hotspot b) { return a.GetIconScreenPosition ().x.CompareTo (b.GetIconScreenPosition ().x); });
    return hotspots;
    
  • She's workin. Thanks so much for the effort. I never would have got that one! 🎊

  • Happy to help, @Mundash, and reviews are always welcome.

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.