Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

PanelRenderer.parentUI

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 UIElements.PanelRenderer parentUI;

Description

If the GameObject that this PanelRenderer component is attached to has a parent GameObject, and that parent GameObject also has a PanelRenderer component attached to it, this value is set to the parent GameObject's PanelRenderer component automatically.

If a PanelRenderer has a parent, you cannot add it directly to a panel (PanelSettings). Unity adds it to the parent's root visual element instead.

The advantage of placing PanelRenderer GameObjects under other PanelRenderer GameObjects is that you can have many PanelRenderers all drawing in the same panel (rootVisualElement) and therefore able to batch together. A typical example is rendering health bars on top of characters, which would be more expensive to render in their separate panels (and batches) compared to combining them to a single panel, one batch.