Used to access parts of a Unity GameObject, from rust
| 3 | namespace 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected