This commit is contained in:
parent
b3768a7aa8
commit
94de38362e
|
@ -12,6 +12,7 @@ using System.Net;
|
|||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
using BITKit.Net.Examples;
|
||||
|
||||
namespace BITKit.Net
|
||||
|
@ -324,7 +325,14 @@ namespace BITKit.Net
|
|||
{
|
||||
dynamic result = methodInfo.Invoke(handle, pars)!;
|
||||
|
||||
value = await result;
|
||||
if (methodInfo.ReturnType == typeof(void) || methodInfo.ReturnType == typeof(UniTask))
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = await result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -332,7 +340,10 @@ namespace BITKit.Net
|
|||
}
|
||||
|
||||
returnWriter.Write(true);
|
||||
BITBinary.Write(returnWriter, value);
|
||||
if (value is not null)
|
||||
{
|
||||
BITBinary.Write(returnWriter, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
/// <summary>
|
||||
/// 弹窗输入框
|
||||
/// </summary>
|
||||
public interface IUXInputBox
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示指定容器
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
void Show(object container);
|
||||
/// <summary>
|
||||
/// 关闭
|
||||
/// </summary>
|
||||
void Close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f59706d5664d4a340beb643b5b8de3f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
@ -57,6 +58,7 @@ namespace BITKit.UX
|
|||
[Header(Constant.Header.Components)]
|
||||
public UIDocument document;
|
||||
[Header(Constant.Header.Settings)]
|
||||
[Obsolete("Use bindNameProvider instead")]
|
||||
public string bindName;
|
||||
[SerializeField, SerializeReference, SubclassSelector]
|
||||
protected IReference bindNameProvider = new GetNameFromGameobject();
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace BITKit.UX
|
|||
Touch.onFingerDown += OnFingerDown;
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
cancellationTokenSource.Cancel();
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1b2a8253eaf9b1b48bed89de7ff99242
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,33 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.UX;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
[CustomType(typeof(IUXInputBox))]
|
||||
public class UXInputBox : MonoBehaviourSingleton<IUXInputBox>,IUXInputBox
|
||||
{
|
||||
[SerializeField] private UIDocument document;
|
||||
|
||||
[UXBindPath("return-button")]
|
||||
private Button _returnButton;
|
||||
|
||||
[UXBindPath("input-container")]
|
||||
private VisualElement _inputContainer;
|
||||
|
||||
public void Show(object container)
|
||||
{
|
||||
_inputContainer.Clear();
|
||||
if(container is not VisualElement data) return;
|
||||
_inputContainer.Add(data);
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
_inputContainer.Clear();
|
||||
document.rootVisualElement.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eaf4bbff335ff8d49a864f4af6564b37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -11,11 +11,6 @@ namespace BITKit.UX
|
|||
{
|
||||
public new class UxmlTraits : VisualElement.UxmlTraits
|
||||
{
|
||||
private readonly UxmlIntAttributeDescription m_currentTabAttribute = new ()
|
||||
{
|
||||
name = "CurrentTab",
|
||||
defaultValue = -1
|
||||
};
|
||||
private readonly UxmlStringAttributeDescription m_customTabPathAttribute = new ()
|
||||
{
|
||||
name = "CustomTabPath",
|
||||
|
@ -24,7 +19,6 @@ namespace BITKit.UX
|
|||
{
|
||||
base.Init(ve, bag, cc);
|
||||
var tabContainer = (TabContainer)ve;
|
||||
tabContainer.CurrentTab = m_currentTabAttribute.GetValueFromBag(bag, cc);
|
||||
tabContainer.CustomTabPath = m_customTabPathAttribute.GetValueFromBag(bag, cc);
|
||||
tabContainer.pickingMode = PickingMode.Ignore;
|
||||
tabContainer._container.pickingMode = PickingMode.Ignore;
|
||||
|
@ -33,7 +27,6 @@ namespace BITKit.UX
|
|||
public new class UxmlFactory : UxmlFactory<TabContainer, UxmlTraits> { }
|
||||
public TabContainer()
|
||||
{
|
||||
_internalTabBar = new TabBar();
|
||||
_container = new VisualElement
|
||||
{
|
||||
name = UXConstant.ContextContainer,
|
||||
|
@ -42,14 +35,19 @@ namespace BITKit.UX
|
|||
flexGrow = 1
|
||||
}
|
||||
};
|
||||
hierarchy.Add(_internalTabBar);
|
||||
hierarchy.Add(_container);
|
||||
RegisterCallback<AttachToPanelEvent>(OnAttachToPanel);
|
||||
RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);
|
||||
_internalTabBar.OnTabChanged += EntryTab;
|
||||
RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
|
||||
pickingMode = PickingMode.Ignore;
|
||||
_container.pickingMode = PickingMode.Ignore;
|
||||
}
|
||||
|
||||
private void OnGeometryChanged(GeometryChangedEvent evt)
|
||||
{
|
||||
UpdateTabBar();
|
||||
}
|
||||
|
||||
public override VisualElement contentContainer => _container;
|
||||
public event Action<int> OnTabChanged;
|
||||
private int currentTab=-1;
|
||||
|
@ -83,11 +81,10 @@ namespace BITKit.UX
|
|||
_externalTabBar.OnTabChanged += EntryTab;
|
||||
}
|
||||
}
|
||||
_internalTabBar.SetActive(_externalTabBar is null);
|
||||
viewDataKey=_externalTabBar is null ? "找到了TabBar" :"未找到Tab";
|
||||
}
|
||||
}
|
||||
private readonly VisualElement _container;
|
||||
private readonly TabBar _internalTabBar;
|
||||
private TabBar _externalTabBar;
|
||||
|
||||
private void OnDetachFromPanel(DetachFromPanelEvent evt)
|
||||
|
@ -103,12 +100,7 @@ namespace BITKit.UX
|
|||
CustomTabPath = CustomTabPath;
|
||||
CurrentTab = CurrentTab;
|
||||
_externalTabBar?.SetValueWithoutNotify(CurrentTab);
|
||||
_internalTabBar.SetValueWithoutNotify(CurrentTab);
|
||||
_internalTabBar.Tabs = string.Join(",", _container.Children().Select(x => x.name));
|
||||
}
|
||||
private void OnShowTab(bool value)
|
||||
{
|
||||
_internalTabBar.style.display = value ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
CurrentTab = CurrentTab;
|
||||
}
|
||||
public void EntryTab(int index)
|
||||
{
|
||||
|
@ -116,7 +108,7 @@ namespace BITKit.UX
|
|||
{
|
||||
x.SetActive(false);
|
||||
}
|
||||
if(_container.Children().TryGet(index,out var element))
|
||||
if(_container.Children().TryGetElementAt(index,out var element))
|
||||
element.SetActive(true);
|
||||
OnTabChanged?.Invoke(index);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue