UniVRM/Assets/VRM10_Samples/VRM10Viewer/uGui/ObjectMap.cs
2025-03-10 21:07:41 +09:00

24 lines
581 B
C#

using System.Collections.Generic;
using UnityEngine;
namespace UniVRM10.VRM10Viewer
{
class ObjectMap
{
Dictionary<string, GameObject> _map = new();
public IReadOnlyDictionary<string, GameObject> Objects => _map;
public ObjectMap(GameObject root)
{
foreach (var x in root.GetComponentsInChildren<Transform>())
{
_map[x.name] = x.gameObject;
}
}
public T Get<T>(string name) where T : Component
{
return _map[name].GetComponent<T>();
}
}
}