Skip to content

Commit

Permalink
Reworked names for some members to bring project to uniform format.
Browse files Browse the repository at this point in the history
  • Loading branch information
bustedbunny committed Apr 16, 2023
1 parent 7302304 commit d8ff5e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Runtime/Binding/Tooltips/Manipulator/TooltipManipulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ private void OnPointerEnter(PointerEnterEvent evt)
private CancellationTokenSource _cts;


private float timeTillShow;
private float _timeTillShow;

private void ResetTime()
{
timeTillShow = MVVMTKSettings.Instance.tooltipHoverTime / 1000f;
_timeTillShow = MVVMTKSettings.Instance.tooltipHoverTime / 1000f;
}

private async UniTask ShowTooltipAsync(CancellationToken ct)
{
while (timeTillShow > 0)
while (_timeTillShow > 0)
{
if (ct.IsCancellationRequested) return;
timeTillShow -= Time.deltaTime;
_timeTillShow -= Time.deltaTime;
await UniTask.Yield();
}

Expand Down
10 changes: 6 additions & 4 deletions Runtime/Common/UIRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Serialization;
using UnityEngine.UIElements;

namespace MVVMToolkit
{
public class UIRoot : MonoBehaviour
{
[SerializeField] private UIDocument uiDocument;
[FormerlySerializedAs("uiDocument")] [SerializeField]
private UIDocument _initialDocument;

private UIDocument _uiDocument;

Expand All @@ -23,7 +25,9 @@ public UIDocument UIDocument
{
if (_uiDocument != value)
{
// ReSharper disable once Unity.NoNullPropagation
value?.rootVisualElement.Add(Root);
// ReSharper disable once Unity.NoNullPropagation
_uiDocument?.rootVisualElement.Remove(Root);
_uiDocument = value;
}
Expand All @@ -35,7 +39,6 @@ public UIDocument UIDocument
private readonly List<BaseView> _views = new();
private readonly List<ViewModel> _viewModels = new();
private ServiceProvider _serviceProvider;
private StrongReferenceMessenger _messenger;


public const string RootUssClassName = "mvvmtk-root";
Expand All @@ -44,13 +47,12 @@ public async UniTask Initialize(StrongReferenceMessenger messenger, ServiceProvi
{
if (Root is not null) throw new InvalidOperationException("Cannot initialize UIRoot multiple times");

_messenger = messenger;
_serviceProvider = serviceProvider;

Root = new();
Root.AddToClassList(RootUssClassName);
Root.pickingMode = PickingMode.Ignore;
UIDocument = uiDocument;
UIDocument = _initialDocument;

GetComponentsInChildren(_viewModels);
foreach (var viewModel in _viewModels)
Expand Down
14 changes: 7 additions & 7 deletions Runtime/Common/View/BaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public class BaseView : UIObject, IRecipient<CloseViewsMessage>
private LocalizedStringTable[] _localizationStringTables;

public LocalizedStringTable[] LocalizedStringTables => _localizationStringTables;
[SerializeField] private VisualTreeAsset asset;
protected VisualTreeAsset Asset => asset;
[SerializeField] private int sortLayer;
public int SortLayer => sortLayer;
[FormerlySerializedAs("asset")] [SerializeField] private VisualTreeAsset _asset;
protected VisualTreeAsset Asset => _asset;
[FormerlySerializedAs("sortLayer")] [SerializeField] private int _sortLayer;
public int SortLayer => _sortLayer;

[SerializeField] private ViewModel bindingContext;
protected ViewModel BindingContext => bindingContext;
[FormerlySerializedAs("bindingContext")] [SerializeField] private ViewModel _bindingContext;
protected ViewModel BindingContext => _bindingContext;
protected BindingParser BindingParser { get; set; }
public VisualElement RootVisualElement { get; private set; }

Expand All @@ -35,7 +35,7 @@ public class BaseView : UIObject, IRecipient<CloseViewsMessage>

protected VisualElement InstantiateAsset()
{
var root = asset.Instantiate();
var root = _asset.Instantiate();
root.pickingMode = PickingMode.Ignore;
root.name = gameObject.name;
return root;
Expand Down
11 changes: 7 additions & 4 deletions Runtime/Common/View/EmbeddedView.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UIElements;

namespace MVVMToolkit
{
public class EmbeddedView : BaseView
{
[FormerlySerializedAs("containerName")]
[SerializeField, Tooltip("ContainerName will be used to query proper container in parent's RootVisualElement")]
private string containerName;
private string _containerName;

[SerializeField] private BaseView parent;
[FormerlySerializedAs("parent")] [SerializeField]
private BaseView _parent;

public const string EmbeddedRootUssClassName = "mvvmtk-root-view-embedded";

Expand All @@ -21,11 +24,11 @@ protected override VisualElement Instantiate()

public override VisualElement ResolveParent()
{
var container = parent.RootVisualElement.Q(containerName);
var container = _parent.RootVisualElement.Q(_containerName);
if (container is null)
{
throw new(
$"No VisualElement with name: {containerName} was found in hierarchy instantiated from {parent.name}.");
$"No VisualElement with name: {_containerName} was found in hierarchy instantiated from {_parent.name}.");
}

return container;
Expand Down

0 comments on commit d8ff5e9

Please sign in to comment.