ScriptReference/UIElements.VisualElement-pickingMode #675
Replies: 1 comment
-
|
Note that if you're cloning UXML you can't set pickingMode in a constructor, because the Factory's UxmlTraits will come along and overwrite it. To fix this issue you can create your own public class BetterUxmlTraits : VisualElement.UxmlTraits
{
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
{
PickingMode prevPickingMode = ve.pickingMode;
base.Init(ve, bag, cc);
// Respect the pickingMode set in the constructor.
if (!bag.TryGetAttributeValue(m_PickingMode.name, out _))
ve.pickingMode = prevPickingMode;
}
}which you can subclass and provide to your factory arguments. Sadly in 2023/6+, due to all this being code generated from attributes I'd probably recommend a different workaround. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
ScriptReference/UIElements.VisualElement-pickingMode
https://docs.unity3d.com/ScriptReference/UIElements.VisualElement-pickingMode.html
Beta Was this translation helpful? Give feedback.
All reactions