0

I created a uielement and gameobject in the runtime and set it to follow the world position of the gameObject.

but the uielement is not displayed.

I've tried a few things and found a way to display them.

public void LateUpdate()
{
    var position = gameObject.transform.position;
    var newPosition = RuntimePanelUtils.CameraTransformWorldToPanel(gage.panel, position, Camera.main);
 
    gage.transform.position = new Vector2(
        newPosition.x - gage.layout.width * 0.5f,
        newPosition.y
    );
}
  1. Change the LateUpdate function to Update and it will be displayed.
  2. Select Element from the UI toolkit debugger and change the style and it will be displayed.
  3. Change the element style elsewhere than the function that generated the uielement at runtime and it will be displayed.
  4. Following objects already created in the scene works correctly.

Why is this happening? How do I display elements correctly?

  • It seems to be a bug that only occurs when an object is created within the event function registered as RegisterCallback. Can anyone tell me a solution? – Juwon Maeng Sep 22 '22 at 04:11

0 Answers0