清理项目目录,引入 InputModule 做多平台输入适配
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using SepCore.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 对话框显示数据。
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ namespace SepCore.UI
|
||||
|
||||
protected override void RefreshUI(DisplayItemInfoForm form, DisplayItemInfoContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
form.RefreshUI(context).Forget();
|
||||
}
|
||||
|
||||
protected override void CloseLoadedFormDirect(DisplayItemInfoForm form)
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshUI(context);
|
||||
RefreshUI(context).Forget();
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1f796998c8814d45993d47e84e802ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class JoystickContext : UIContext
|
||||
{
|
||||
public Vector2 Direction { get; set; }
|
||||
public float Magnitude { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52c3c2991dab492439d786507182ec4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Definition;
|
||||
using SepCore.InputModule;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class JoystickController : UIControllerBase<JoystickContext, JoystickForm>
|
||||
{
|
||||
protected override UIFormType UIFormType => UIFormType.JoystickForm;
|
||||
|
||||
protected override void RefreshUI(JoystickForm form, JoystickContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.InputModule.CommandTriggered += OnCommandTriggered;
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.InputModule.CommandTriggered -= OnCommandTriggered;
|
||||
}
|
||||
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
JoystickContext context = new JoystickContext();
|
||||
await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
Log.Info("JoystickController doesn't need UseCase");
|
||||
}
|
||||
|
||||
private void OnCommandTriggered(InputCommand cmd)
|
||||
{
|
||||
if (cmd.ActionId != InputActionId.Move) return;
|
||||
if (Context == null || Form == null) return;
|
||||
|
||||
Context.Direction = cmd.Vector2Value;
|
||||
Context.Magnitude = cmd.Vector2Value.magnitude;
|
||||
Form.RefreshUI(Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea7ab1500ac7fa540b3ed92295f7687c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class JoystickForm : UGuiForm
|
||||
{
|
||||
public void RefreshUI(JoystickContext context)
|
||||
{
|
||||
}
|
||||
|
||||
#region FSM
|
||||
|
||||
protected override void OnInit(object userData)
|
||||
{
|
||||
base.OnInit(userData);
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62121b0e23245f14fb22e8ca418c8ddf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -61,7 +61,7 @@ namespace SepCore.UI
|
||||
EnsureItemCount(targetCount);
|
||||
for (int i = 0; i < targetCount; i++)
|
||||
{
|
||||
_activeItems[i].OnInit(context.ItemContexts[i], i);
|
||||
_activeItems[i].OnInit(context.ItemContexts[i], i).Forget();
|
||||
}
|
||||
|
||||
LayoutItems();
|
||||
@@ -98,7 +98,7 @@ namespace SepCore.UI
|
||||
|
||||
int index = _activeItems.Count;
|
||||
_activeItems.Add(item);
|
||||
item.OnInit(itemContext, index);
|
||||
item.OnInit(itemContext, index).Forget();
|
||||
item.SetIndex(index);
|
||||
|
||||
int columnCount = _fixedColumnCount > 0 ? _fixedColumnCount : CalculateColumnCount(GetRootWidth());
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace SepCore.UI
|
||||
{
|
||||
if (roleIndex < _context.RoleItemContexts.Length)
|
||||
{
|
||||
_roleItems[itemIndex].OnInit(_context.RoleItemContexts[roleIndex]);
|
||||
_roleItems[itemIndex].OnInit(_context.RoleItemContexts[roleIndex]).Forget();
|
||||
_roleItems[itemIndex].gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
@@ -97,4 +97,4 @@ namespace SepCore.UI
|
||||
GameEntry.Event.Fire(this, MenuSelectRoleReturnEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:363c5eb08ff8e6a439b85e37b8c20d96",
|
||||
"GUID:47a82ffa13c291447ab895cd0bc251cd",
|
||||
"GUID:436e23dbdc31e7d4fb5c3f804548b2df"
|
||||
"GUID:436e23dbdc31e7d4fb5c3f804548b2df",
|
||||
"GUID:d54b9488b03814a44ab937f0aeb738b1"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user