MCPcopy Create free account
hub / github.com/TanTanDev/runity / RustyGameObject

Class RustyGameObject

unity/Runity/RustyGameObject.cs:5–25  ·  view source on GitHub ↗

Used to access parts of a Unity GameObject, from rust

Source from the content-addressed store, hash-verified

3namespace Runity {
4 // Used to access parts of a Unity GameObject, from rust
5 public struct RustyGameObject {
6 public UnityEngine.GameObject GameObject;
7 public Dictionary<int, UnityEngine.Component> HashedComponents;
8
9 public RustyGameObject(UnityEngine.GameObject a_gameObject) {
10 GameObject = a_gameObject;
11 HashedComponents = new Dictionary<int, UnityEngine.Component>();
12 }
13
14 public T GetComponentFromId<T>(int a_componentId)
15 where T: UnityEngine.Component
16 {
17 if(HashedComponents.ContainsKey(a_componentId))
18 return HashedComponents[a_componentId] as T;
19 else {
20 var component = GameObject.GetComponent<T>();
21 HashedComponents[a_componentId] = component;
22 return HashedComponents[a_componentId] as T;
23 }
24 }
25 }
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected