Files
ShrinkTutorial/Runtime/Trigger/ShrinkTutorialAnchorRegistry.cs
cneicy 1180be88a6
Publish UPM package / publish (push) Failing after 1s
chore: initialize standalone UPM package
2026-08-26 02:50:43 +08:00

43 lines
1.1 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace ShrinkTutorial
{
public static class ShrinkTutorialAnchorRegistry
{
private static readonly Dictionary<string, ShrinkTutorialAnchor> Anchors = new();
public static void Register(ShrinkTutorialAnchor anchor)
{
if (!anchor || string.IsNullOrWhiteSpace(anchor.AnchorId))
return;
Anchors[anchor.AnchorId] = anchor;
}
public static void Unregister(ShrinkTutorialAnchor anchor)
{
if (!anchor || string.IsNullOrWhiteSpace(anchor.AnchorId))
return;
if (Anchors.TryGetValue(anchor.AnchorId, out var current) && current == anchor)
Anchors.Remove(anchor.AnchorId);
}
public static Transform Get(string anchorId)
{
if (string.IsNullOrWhiteSpace(anchorId))
return null;
return Anchors.TryGetValue(anchorId, out var anchor) && anchor
? anchor.transform
: null;
}
public static void Reset()
{
Anchors.Clear();
}
}
}