using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; namespace BITKit.UX { public class OnScreenButton : OnScreenControl { public new class UxmlTraits : VisualElement.UxmlTraits { private readonly UxmlFloatAttributeDescription m_PressedValueAttribute = new () { name = "PressedValue", defaultValue = 1f, }; private readonly UxmlBoolAttributeDescription m_ReleasePressAttribute = new() { name = "ReleasePress" }; public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) { base.Init(ve, bag, cc); var table = (OnScreenButton)ve; table.PressedValue = m_PressedValueAttribute.GetValueFromBag(bag, cc); table.ReleasePress = m_ReleasePressAttribute.GetValueFromBag(bag, cc); } } public new class UxmlFactory : UxmlFactory { } public float PressedValue { get; set; }= 1f; public bool ReleasePress { get; set; } private bool _isPressed; private int _pointerId=-1; private Label _label; private readonly ValidHandle _isTriggered = new(); public OnScreenButton() { RegisterCallback(OnPointerUp); RegisterCallback(OnPointerDown); RegisterCallback(OnPointerMove); this.AddManipulator(new Clickable(OnClick)); _label = this.Create