Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

PanelRenderer.trackScreenSpacePosition

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public bool trackScreenSpacePosition;

Description

Whether the root visual element follows the position of the GameObject in screen space. The default value is false.

Only takes effect in screen-space render modes. Ignored in PanelRenderMode.WorldSpace.

While enabled, the root visual element is sized by its content and the renderer controls its translate and display inline styles: every frame, the root is translated so its origin matches the position of the GameObject on screen, as seen from the main camera. When that position is not on screen, the root is hidden. When there is no main camera, the last tracked styles are kept.

Use this, for example, for a screen-space health bar that follows a unit moving in the 3D world. Use PanelRenderer.screenSpaceOffset to offset the UI from the tracked position.