Skip to content

Commit 4de66ac

Browse files
committed
Rename ButtonUITK to BaseButton.
1 parent 31e14f2 commit 4de66ac

File tree

7 files changed

+26
-22
lines changed

7 files changed

+26
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using UnityEngine.UIElements;
2+
3+
namespace UnityMvvmToolkit.UITK.BindableUIElements
4+
{
5+
public abstract partial class BaseButton : Button
6+
{
7+
public bool Enabled
8+
{
9+
get => enabledSelf;
10+
set => SetEnabled(value);
11+
}
12+
}
13+
}

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/BaseButton.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/BindableButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace UnityMvvmToolkit.UITK.BindableUIElements
77
{
8-
public partial class BindableButton : ButtonUITK, IBindableElement
8+
public partial class BindableButton : BaseButton, IBindableElement
99
{
1010
private int? _buttonId;
1111

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
using UnityEngine.UIElements;
2+
using UnityMvvmToolkit.UITK.Extensions;
23

34
namespace UnityMvvmToolkit.UITK.BindableUIElements
45
{
5-
public class ButtonUITK : Button
6+
partial class BaseButton
67
{
7-
public bool Enabled
8-
{
9-
get => enabledSelf;
10-
set => SetEnabled(value);
11-
}
12-
13-
public new class UxmlFactory : UxmlFactory<ButtonUITK, UxmlTraits>
14-
{
15-
}
16-
178
public new class UxmlTraits : Button.UxmlTraits
189
{
1910
private readonly UxmlBoolAttributeDescription _enabledAttribute = new()
@@ -22,9 +13,7 @@ public bool Enabled
2213
public override void Init(VisualElement visualElement, IUxmlAttributes bag, CreationContext context)
2314
{
2415
base.Init(visualElement, bag, context);
25-
26-
var bindableButton = (ButtonUITK) visualElement;
27-
bindableButton.Enabled = _enabledAttribute.GetValueFromBag(bag, context);
16+
visualElement.As<BaseButton>().Enabled = _enabledAttribute.GetValueFromBag(bag, context);
2817
}
2918
}
3019
}

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/Uxmls/BaseButton.Uxml.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/Uxmls/BindableButton.Uxml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using UnityEngine.UIElements;
2+
using UnityMvvmToolkit.UITK.Extensions;
23

34
namespace UnityMvvmToolkit.UITK.BindableUIElements
45
{
@@ -10,17 +11,15 @@ partial class BindableButton
1011
{
1112
}
1213

13-
public new class UxmlTraits : ButtonUITK.UxmlTraits
14+
public new class UxmlTraits : BaseButton.UxmlTraits
1415
{
1516
private readonly UxmlStringAttributeDescription _commandAttribute = new()
1617
{ name = "command", defaultValue = "" };
1718

1819
public override void Init(VisualElement visualElement, IUxmlAttributes bag, CreationContext context)
1920
{
2021
base.Init(visualElement, bag, context);
21-
22-
var bindableButton = (BindableButton) visualElement;
23-
bindableButton.Command = _commandAttribute.GetValueFromBag(bag, context);
22+
visualElement.As<BindableButton>().Command = _commandAttribute.GetValueFromBag(bag, context);
2423
}
2524
}
2625
}

src/UnityMvvmToolkit.UnityPackage/Assets/Plugins/UnityMvvmToolkit/Runtime/UITK/BindableUIElements/Uxmls/ButtonUITK.Uxml.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)