Hello, I’m using Unity 6000.0.3f1 (although the problem is also on previous versions).
On Android Profile, UIToolkit used on Runtime. I wonder if it’s a regular behaviour for a VisualElement, which has registered the PointerOutEvent CallBack, to trigger this event when its scale changes ?
It’s very easy to reproduce.
Starting with an empty project, create a document with a VisualElement called RedElement and register these Callbacks :
public class PointerOutBug : MonoBehaviour
{
private VisualElement myElement;
private void Start()
{
var document = GetComponent<UIDocument>();
myElement = document.rootVisualElement.Q<VisualElement>("RedElement");
myElement.RegisterCallback<PointerOverEvent>(OnPointerOver);
myElement.RegisterCallback<PointerOutEvent>(OnPointerOut);
}
private void OnPointerOver(PointerOverEvent evt)
{
Debug.Log("OnPointerOver");
myElement.AddToClassList("activated");
}
private void OnPointerOut(PointerOutEvent evt)
{
Debug.Log("OnPointerOut");
myElement.RemoveFromClassList("activated");
}
}
The default USS style associated is the .red class. PointerOver sets the activated class to the element :
.red {
flex-grow: 0;
width: 20%;
height: 20%;
background-color: rgb(128, 0, 0);
align-self: auto;
justify-content: flex-start;
align-content: auto;
align-items: auto;
}
.activated {
background-color: rgb(0, 0, 128);
scale: 0.9 0.9;
}
If you delete the scale line on .activated class, the background-color changes perfectly into blue when the pointer is on the Element (it means Touch is down). With scale: 0.9 0.9, not, because of the PointerOutEvent.
Thank you