Creating Custom Hotspots
Hotspot integrations require three coordinated scripts plus a prefab.
1. Runtime Data (HotspotData)
- Derive from
Revoid.GigaSphere.Hotspots.HotspotData. - Mark the class
[Serializable]if it lives outside an assembly definition. - Override the
Typeproperty; the value must match the prefab folder name underResources/Runtime/Hotspots. - Set optional editor hints like
iconPathin the constructor.
using Revoid.GigaSphere.Hotspots;
using UnityEngine;
[System.Serializable]
public sealed class MyHotspotData : HotspotData
{
public AudioClip clip;
public override string Type => "MyAudio";
public MyHotspotData()
{
iconPath = "Edit/Icons/audio_hotspot";
}
}2. Runtime Anchor (HotspotAnchor)
- Inherit from
Revoid.GigaSphere.Hotspots.HotspotAnchor. - Override
Initializeto cache typed data and hook up visuals or audio. - Override interaction methods (
HandleInteractionClick,HandleInteractionBegin,HandleInteractionEnd) to drive behavior. - Call
base.Initializeso the manager wiring remains intact.
using Revoid.GigaSphere.Controls;
using Revoid.GigaSphere.Hotspots;
using UnityEngine;
public sealed class MyHotspot : HotspotAnchor
{
[SerializeField] private AudioSource audioSource;
public override void Initialize(TourManager manager, HotspotData data)
{
base.Initialize(manager, data);
if (Data is MyHotspotData typed && audioSource)
{
audioSource.clip = typed.clip;
}
}
protected override void HandleInteractionClick()
{
base.HandleInteractionClick();
if (audioSource?.clip == null)
return;
if (audioSource.isPlaying)
{
audioSource.Stop();
}
else
{
audioSource.Play();
}
}
}3. Editor Integration (IHotspotEditor)
- Implement
Revoid.GigaSphere.Editor.IHotspotEditorin an Editor-only folder or assembly. - Decorate the class with
[HotspotEditor(typeof(MyHotspotData))]so the authoring tools register it. - Use
CreateHotspotto instantiate default data when the author adds the hotspot to a location. - Return a friendly menu name from
GetMenuName.
using Revoid.GigaSphere.Editor;
using Revoid.GigaSphere.Graph;
using Revoid.GigaSphere.Hotspots;
using UnityEditor;
using UnityEngine;
[HotspotEditor(typeof(MyHotspotData))]
public sealed class MyHotspotEditor : IHotspotEditor
{
public bool DrawDefaultInspector => true;
public bool CanCreate() => true;
public HotspotData CreateHotspot(Vector3 position)
{
return new MyHotspotData { position = position };
}
public string GetMenuName() => "My Audio Player";
public void Initialize(TourGraph graph, LocationNodeData location) { }
public bool OnInspectorGUI(HotspotData hotspot)
{
var typed = (MyHotspotData)hotspot;
EditorGUI.BeginChangeCheck();
typed.clip = (AudioClip)EditorGUILayout.ObjectField("Audio Clip", typed.clip, typeof(AudioClip), false);
return EditorGUI.EndChangeCheck();
}
}4. Prefab Authoring
- Create a prefab under
Resources/Runtime/Hotspots/MyAudio/. The folder name must equal theTypestring. - Add the custom anchor component and wire serialized references (audio source, button sprites, etc.).
- Optionally attach
PrefabVersionand increment itsversionwhen making breaking prefab updates while you want to keep existing hotspot hierarchy.TourManagerautomatically picks the highest version when multiple candidates exist. - Keep the prefab authoring scale relative to a sphere radius of 7 units;
TourManager.LoadHotspotsrescales at runtime using the active sphere radius so hotspots stay proportional.
Testing
- Add the hotspot to a
LocationInfovia the Tour Graph editor or the inspector. - Enter Play Mode and watch
TourManagerspawn the hotspot. If anything fails, check the console forHotspot prefab not found for Typeor missing component warnings. - Use the
GuidedTourtooling if the hotspot participates in guided steps; the same data class will serialize there as well.