cool
This commit is contained in:
@@ -19,6 +19,11 @@ namespace BITKit.UX
|
||||
{
|
||||
name = "ReleasePress"
|
||||
};
|
||||
|
||||
private readonly UxmlStringAttributeDescription m_TextAttribute = new()
|
||||
{
|
||||
name = "Text"
|
||||
};
|
||||
|
||||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
|
||||
{
|
||||
@@ -26,12 +31,19 @@ namespace BITKit.UX
|
||||
var table = (OnScreenButton)ve;
|
||||
table.PressedValue = m_PressedValueAttribute.GetValueFromBag(bag, cc);
|
||||
table.ReleasePress = m_ReleasePressAttribute.GetValueFromBag(bag, cc);
|
||||
table.Text = m_TextAttribute.GetValueFromBag(bag, cc);
|
||||
}
|
||||
}
|
||||
public new class UxmlFactory : UxmlFactory<OnScreenButton, UxmlTraits> { }
|
||||
public float PressedValue { get; set; }= 1f;
|
||||
public bool ReleasePress { get; set; }
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => _label.text;
|
||||
set => _label.text = value;
|
||||
}
|
||||
|
||||
private bool _isPressed;
|
||||
private int _pointerId=-1;
|
||||
private Label _label;
|
||||
@@ -44,6 +56,7 @@ namespace BITKit.UX
|
||||
RegisterCallback<PointerMoveEvent>(OnPointerMove);
|
||||
this.AddManipulator(new Clickable(OnClick));
|
||||
_label = this.Create<Label>();
|
||||
_label.pickingMode = PickingMode.Ignore;
|
||||
|
||||
_isTriggered.AddListener(x =>
|
||||
{
|
||||
|
@@ -64,10 +64,18 @@ namespace BITKit.UX
|
||||
button.RegisterCallback<PointerOverEvent>(_ =>
|
||||
{
|
||||
SendValueToControl((Vector2)value);
|
||||
|
||||
button.AddToClassList("selected");
|
||||
});
|
||||
button.RegisterCallback<PointerUpEvent>(_ =>
|
||||
{
|
||||
SendValueToControl((Vector2)default);
|
||||
|
||||
button.RemoveFromClassList("selected");
|
||||
});
|
||||
button.RegisterCallback<PointerCancelEvent>(_ =>
|
||||
{
|
||||
button.RemoveFromClassList("selected");
|
||||
});
|
||||
|
||||
// var label = button.Create<Label>();
|
||||
|
@@ -45,12 +45,16 @@ namespace BITKit.UX
|
||||
SendValueToControl(Vector2.zero);
|
||||
_startPosition = evt.position;
|
||||
_ignoreFrame = 1;
|
||||
|
||||
this.ReleasePointer(evt.pointerId);
|
||||
}
|
||||
|
||||
private void OnPointerDown(PointerDownEvent evt)
|
||||
{
|
||||
_ignoreFrame = 1;
|
||||
_startPosition = evt.position;
|
||||
|
||||
this.CapturePointer(evt.pointerId);
|
||||
}
|
||||
|
||||
private void OnPointerMove(PointerMoveEvent evt)
|
||||
|
Reference in New Issue
Block a user