Is there any official tutorial about how to send values between GameObject and Entity world?

In the legacy world of GameObject, we have various of methods to send values between 2 classes or 2 gameObjects.

For example:
Demo for send value between 2 gameobject and class:

XXType xxType = FindFirstObjectOfType<XXXX>(); //find by type
XXType xxType;  //(Directly connect from inspector)
XXType xxType = FindFirstObjectWithTag("Player");  //find by tag
XXType xxType = GameObject.Find("myGO").GetComponent<XXType>();  //find with obj name and then GetComponent by type
 
float newHeath = 5;
xxType.playerHeath = newHeath;

While for Sending value between GameObject world and the Entity, it looks like there’s no official method? I found some tutorials from different places and it looks like they are all using some work around to ahieve the target.

Could we simply list one or a few offial methods like the example above to showcase how to send value between GO and Entity?

Updates:
Method #1 - GameObject Singleton
Simply call it inside a System script of ECS

Approaches kind of run the gamut - you’ll see plenty of examples even in our (GitHub - Unity-Technologies/ECS-Network-Racing-Sample: ECS multiplayer racing sample to showcase using Unity Entities and netcode with best practices and GitHub - Unity-Technologies/EntityComponentSystemSamples) that look like your snippet there, although if you know the relationship will be stable than caching that lookup or otherwise associating a Component with an entity is the way to go.

1 Like