Disabled UI Document always appears in Game view after exiting the play mode
I'm using UI Toolkit and encountered a slight issue I can't solve.
I have a dialogue system that has a UI Document component. This component is disabled in the editor.
So it's disabled when I enter the play mode, during the play mode, and when I exit the play mode. However, after I exit the play mode, UI Document appears in the Game view. Inspector still shows it's disabled.
This behaviour is quite intrusive. I'm using 2021.2.16f1. Does anybody know why this happens?
This looks like a bug. Definitely worth reporting it.
In the meanwhile, a workaround example:
using UnityEngine;
using UnityEngine.UIElements;
[ExecuteAlways]
public class UiDocumentBugfix : MonoBehaviour
{
void Awake ()
{
var comp = GetComponent<UIDocument>();
if( comp && !comp.enabled )
{
comp.enabled = true;
comp.enabled = false;
}
}
}
Your answer
Follow this Question
Related Questions
Spawner design for variable spawned units 1 Answer
Drag and Drop Problem 1 Answer
(Unity 2d) Player isn't "grounded" though clearly on the ground. 0 Answers
Unity2D Hill Climb Racing Tutorial or Project 2 Answers
Game Object Drop 0 Answers