-
Notifications
You must be signed in to change notification settings - Fork 0
Referencing RPGObjects from Unity code
Robin van Ee edited this page Jan 22, 2023
·
5 revisions
The RPGObjectReference type is used to reference objects.
[SerializeField] private RPGObjectReference characterReference;
The GetObject() method can be used to retrieve the object from the reference. The first time this is called, the asset is loaded from disk and deserialized, but it's cached afterwards
IRPGObject character = characterReference.GetObject();
GetComponent can then be used to retrieve individual components
ExampleComponent component = character.GetComponent<ExampleComponent>();
In the Unity inspector, a string is required to reference the object.
This should be equal to the Object Reference ID that can be found for each object in the database editor: