In my game I have a system to hides/shows certain parts of UI based on stuff happening in the game. In Entities 0.51 I just made class IComponentData singleton entity that held references to the UI GameObjects (Buttons, Sliders and stuff) and used ConvertToEntity on single authoring object I put in a scene to convert it at runtime. Now in Entities 1.0 ConvertToEntity was removed and I cannot figure out how to adapt. When I put mu authoring GameObject in SubScene I get a warning about cross-scene reference because the Canvas and all the UI GameObjects are outside of subscene. When I put my singleton authoring GameObject outside of SubScene it never gets converted
#How to reference UI GameObjects now that ConvertToEntity was removed?
1 messages · Page 1 of 1 (latest)
You can inject the singleton outside of a sub scene using ‘World.DefaultGameObjectInjectionWorld’ to access EntityManager. From that you can create your singleton.
This should be avoided at all times. It's an equivalent of injecting something into private field via reflection IMO.
You can just make some static collection of your UI data and access it from system
If you think it's awful - old "convert to entity" way was no better: it injected entities into world via static reference.
Alternative: bake your UI prefabs and instantiate from system