forked from sin365/AxibugEmuOnline
XBM迭代
This commit is contained in:
parent
41e415dc46
commit
2a18dc593a
@ -30,7 +30,7 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 7102897325704768026}
|
||||
m_Father: {fileID: 1639091784002085428}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
@ -49,6 +49,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: fb4f275956ba18440b061e92278f13cd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_listenControlAction: 1
|
||||
m_menuItemRoot: {fileID: 7102897325704768026}
|
||||
GroupRoot: {fileID: 5247317738185020566}
|
||||
Template: {fileID: 2502609279043838113, guid: ece591129eb9bcc48bd83ec153c98018, type: 3}
|
||||
@ -165,6 +166,7 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1639091783724093883}
|
||||
- {fileID: 2355022013370943017}
|
||||
- {fileID: 6855144573435021451}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
@ -174,6 +176,54 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &2556464728420224707
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2355022013370943017}
|
||||
- component: {fileID: 4512092057495325491}
|
||||
m_Layer: 5
|
||||
m_Name: CommandDispatcher
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2355022013370943017
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2556464728420224707}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1639091784002085428}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &4512092057495325491
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2556464728420224707}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4471d8231d16ba3469228e09d4cb3a81, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &3732356966700017678
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -250,4 +300,4 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 2
|
||||
m_VerticalFit: 0
|
||||
m_VerticalFit: 2
|
||||
|
@ -134,6 +134,7 @@ MonoBehaviour:
|
||||
SubMenuItemGroup: {fileID: 2060695589654091386}
|
||||
SelectScale: 1
|
||||
UnSelectScale: 0.85
|
||||
m_progress: 0
|
||||
--- !u!114 &5700455559359757662
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -242,8 +243,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3226730524206505336}
|
||||
- component: {fileID: 7478613319365725124}
|
||||
- component: {fileID: 6947842073264115296}
|
||||
- component: {fileID: 2060695589654091386}
|
||||
- component: {fileID: 6355204462360987243}
|
||||
m_Layer: 5
|
||||
@ -272,46 +271,6 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: -60}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!114 &7478613319365725124
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8218630550162509793}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 0
|
||||
m_VerticalFit: 2
|
||||
--- !u!114 &6947842073264115296
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8218630550162509793}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 1
|
||||
m_Spacing: 30
|
||||
m_ChildForceExpandWidth: 0
|
||||
m_ChildForceExpandHeight: 0
|
||||
m_ChildControlWidth: 0
|
||||
m_ChildControlHeight: 0
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!114 &2060695589654091386
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -324,10 +283,13 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ed40f0945dba47e409627739ce124125, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_listenControlAction: 1
|
||||
m_menuItemRoot: {fileID: 3226730524206505336}
|
||||
SubMenuItemTemplate: {fileID: 2502609279043838113, guid: 01f3c5497992f944eae9b9efa15a19c2, type: 3}
|
||||
layoutGroup: {fileID: 0}
|
||||
alphaGroup: {fileID: 6355204462360987243}
|
||||
m_selectItemPosition: {x: -50, y: -51}
|
||||
step: 120
|
||||
splitStep: 280
|
||||
--- !u!225 &6355204462360987243
|
||||
CanvasGroup:
|
||||
m_ObjectHideFlags: 0
|
||||
|
File diff suppressed because it is too large
Load Diff
68
AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher.cs
Normal file
68
AxibugEmuOnline.Client/Assets/Script/UI/CommandDispatcher.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class CommandDispatcher : MonoBehaviour
|
||||
{
|
||||
public static CommandDispatcher Instance { get; private set; }
|
||||
|
||||
HashSet<MenuItemController> m_register = new HashSet<MenuItemController>();
|
||||
Dictionary<KeyCode, MenuItemController.EnumCommand> m_keyMapper = new Dictionary<KeyCode, MenuItemController.EnumCommand>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
m_keyMapper.Add(KeyCode.A, MenuItemController.EnumCommand.SelectItemLeft);
|
||||
m_keyMapper.Add(KeyCode.D, MenuItemController.EnumCommand.SelectItemRight);
|
||||
m_keyMapper.Add(KeyCode.W, MenuItemController.EnumCommand.SelectItemUp);
|
||||
m_keyMapper.Add(KeyCode.S, MenuItemController.EnumCommand.SelectItemDown);
|
||||
m_keyMapper.Add(KeyCode.K, MenuItemController.EnumCommand.Enter);
|
||||
m_keyMapper.Add(KeyCode.L, MenuItemController.EnumCommand.Back);
|
||||
m_keyMapper.Add(KeyCode.I, MenuItemController.EnumCommand.OptionMenu);
|
||||
|
||||
m_keyMapper.Add(KeyCode.LeftArrow, MenuItemController.EnumCommand.SelectItemLeft);
|
||||
m_keyMapper.Add(KeyCode.RightArrow, MenuItemController.EnumCommand.SelectItemRight);
|
||||
m_keyMapper.Add(KeyCode.UpArrow, MenuItemController.EnumCommand.SelectItemUp);
|
||||
m_keyMapper.Add(KeyCode.DownArrow, MenuItemController.EnumCommand.SelectItemDown);
|
||||
m_keyMapper.Add(KeyCode.Return, MenuItemController.EnumCommand.Enter);
|
||||
m_keyMapper.Add(KeyCode.Escape, MenuItemController.EnumCommand.Back);
|
||||
m_keyMapper.Add(KeyCode.RightShift, MenuItemController.EnumCommand.OptionMenu);
|
||||
m_keyMapper.Add(KeyCode.LeftShift, MenuItemController.EnumCommand.OptionMenu);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
public void RegistController(MenuItemController controller)
|
||||
{
|
||||
m_register.Add(controller);
|
||||
}
|
||||
|
||||
public void UnRegistController(MenuItemController menuItemController)
|
||||
{
|
||||
m_register.Remove(menuItemController);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach (var item in m_keyMapper)
|
||||
{
|
||||
if (Input.GetKeyDown(item.Key))
|
||||
{
|
||||
foreach (var controller in m_register)
|
||||
controller.ExecuteCommand(item.Value, false);
|
||||
}
|
||||
if (Input.GetKeyUp(item.Key))
|
||||
{
|
||||
foreach (var controller in m_register)
|
||||
controller.ExecuteCommand(item.Value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4471d8231d16ba3469228e09d4cb3a81
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -23,7 +23,6 @@ namespace AxibugEmuOnline.Client.UI
|
||||
|
||||
private TweenerCore<Vector2, Vector2, VectorOptions> rollTween;
|
||||
|
||||
|
||||
protected override void OnSelectMenuChanged()
|
||||
{
|
||||
var step = GroupRoot.spacing;
|
||||
@ -50,12 +49,14 @@ namespace AxibugEmuOnline.Client.UI
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
protected override void OnCmdSelectItemLeft()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
SelectIndex += 1;
|
||||
else if (Input.GetKeyDown(KeyCode.A))
|
||||
SelectIndex -= 1;
|
||||
SelectIndex--;
|
||||
}
|
||||
|
||||
protected override void OnCmdSelectItemRight()
|
||||
{
|
||||
SelectIndex++;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
@ -2,6 +2,7 @@ using Coffee.UIExtensions;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static Codice.Client.BaseCommands.Import.Commit;
|
||||
@ -91,5 +92,9 @@ namespace AxibugEmuOnline.Client.UI
|
||||
Root.localScale = Vector3.one * Mathf.Lerp(UnSelectScale, SelectScale, m_progress);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnEnterItem()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@ -6,6 +7,32 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public abstract class MenuItemController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
float PulseInvoke_Delay = 0.4f;
|
||||
[SerializeField]
|
||||
float PulseInvoke_Interval = 0.05f;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_listenControlAction;
|
||||
public bool ListenControlAction
|
||||
{
|
||||
get => m_listenControlAction;
|
||||
set
|
||||
{
|
||||
m_listenControlAction = value;
|
||||
|
||||
if (value)
|
||||
CommandDispatcher.Instance.RegistController(this);
|
||||
else
|
||||
CommandDispatcher.Instance.UnRegistController(this);
|
||||
}
|
||||
}
|
||||
|
||||
private PulseInvoker m_pulsInvoker_Left;
|
||||
private PulseInvoker m_pulsInvoker_Right;
|
||||
private PulseInvoker m_pulsInvoker_Up;
|
||||
private PulseInvoker m_pulsInvoker_Down;
|
||||
|
||||
private int m_selectIndex;
|
||||
protected List<MenuItem> m_runtimeMenuUI = new List<MenuItem>();
|
||||
|
||||
@ -34,10 +61,100 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
Canvas.ForceUpdateCanvases();
|
||||
SelectIndex = 0;
|
||||
|
||||
if (m_listenControlAction)
|
||||
{
|
||||
CommandDispatcher.Instance.RegistController(this);
|
||||
}
|
||||
|
||||
m_pulsInvoker_Left = new PulseInvoker(OnCmdSelectItemLeft, PulseInvoke_Delay, PulseInvoke_Interval);
|
||||
m_pulsInvoker_Right = new PulseInvoker(OnCmdSelectItemRight, PulseInvoke_Delay, PulseInvoke_Interval);
|
||||
m_pulsInvoker_Up = new PulseInvoker(OnCmdSelectItemUp, PulseInvoke_Delay, PulseInvoke_Interval);
|
||||
m_pulsInvoker_Down = new PulseInvoker(OnCmdSelectItemDown, PulseInvoke_Delay, PulseInvoke_Interval);
|
||||
}
|
||||
|
||||
protected virtual void Update() { }
|
||||
private void OnDestroy()
|
||||
{
|
||||
CommandDispatcher.Instance.UnRegistController(this);
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
m_pulsInvoker_Left.Update(Time.deltaTime);
|
||||
m_pulsInvoker_Right.Update(Time.deltaTime);
|
||||
m_pulsInvoker_Up.Update(Time.deltaTime);
|
||||
m_pulsInvoker_Down.Update(Time.deltaTime);
|
||||
}
|
||||
|
||||
protected abstract void OnSelectMenuChanged();
|
||||
|
||||
|
||||
|
||||
public void ExecuteCommand(EnumCommand cmd, bool cancel)
|
||||
{
|
||||
if (!cancel)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case EnumCommand.SelectItemLeft:
|
||||
m_pulsInvoker_Left.SetActive();
|
||||
OnCmdSelectItemLeft(); break;
|
||||
case EnumCommand.SelectItemRight:
|
||||
m_pulsInvoker_Right.SetActive();
|
||||
OnCmdSelectItemRight(); break;
|
||||
case EnumCommand.SelectItemUp:
|
||||
m_pulsInvoker_Up.SetActive();
|
||||
OnCmdSelectItemUp(); break;
|
||||
case EnumCommand.SelectItemDown:
|
||||
m_pulsInvoker_Down.SetActive();
|
||||
OnCmdSelectItemDown(); break;
|
||||
case EnumCommand.Enter:
|
||||
var item = m_runtimeMenuUI[SelectIndex];
|
||||
OnCmdEnter(item);
|
||||
break;
|
||||
case EnumCommand.Back:
|
||||
OnCmdBack(); break;
|
||||
case EnumCommand.OptionMenu:
|
||||
OnCmdOptionMenu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case EnumCommand.SelectItemLeft:
|
||||
m_pulsInvoker_Left.DisActive(); break;
|
||||
case EnumCommand.SelectItemRight:
|
||||
m_pulsInvoker_Right.DisActive(); break;
|
||||
case EnumCommand.SelectItemUp:
|
||||
m_pulsInvoker_Up.DisActive(); break;
|
||||
case EnumCommand.SelectItemDown:
|
||||
m_pulsInvoker_Down.DisActive(); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnCmdSelectItemLeft() { }
|
||||
|
||||
protected virtual void OnCmdSelectItemRight() { }
|
||||
|
||||
protected virtual void OnCmdSelectItemUp() { }
|
||||
|
||||
protected virtual void OnCmdSelectItemDown() { }
|
||||
|
||||
protected virtual void OnCmdOptionMenu() { }
|
||||
protected virtual void OnCmdEnter(MenuItem item) { item.OnEnterItem(); }
|
||||
protected virtual void OnCmdBack() { }
|
||||
public enum EnumCommand
|
||||
{
|
||||
SelectItemLeft,
|
||||
SelectItemRight,
|
||||
SelectItemUp,
|
||||
SelectItemDown,
|
||||
Enter,
|
||||
Back,
|
||||
OptionMenu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
59
AxibugEmuOnline.Client/Assets/Script/UI/PulseInvoker.cs
Normal file
59
AxibugEmuOnline.Client/Assets/Script/UI/PulseInvoker.cs
Normal file
@ -0,0 +1,59 @@
|
||||
namespace AxibugEmuOnline.Client.UI
|
||||
{
|
||||
using System;
|
||||
|
||||
public class PulseInvoker
|
||||
{
|
||||
private Action _action;
|
||||
private float _interval;
|
||||
private float _delay;
|
||||
private float _elapsedTime;
|
||||
private bool _isActive;
|
||||
private bool _isDelayed;
|
||||
|
||||
public PulseInvoker(Action action, float delay, float interval)
|
||||
{
|
||||
_action = action;
|
||||
|
||||
_delay = delay;
|
||||
_interval = interval;
|
||||
}
|
||||
|
||||
public void SetActive()
|
||||
{
|
||||
_elapsedTime = 0f;
|
||||
_isActive = true;
|
||||
_isDelayed = true;
|
||||
}
|
||||
|
||||
public void DisActive()
|
||||
{
|
||||
_isActive = false;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
if (!_isActive) return;
|
||||
|
||||
_elapsedTime += deltaTime;
|
||||
|
||||
if (_isDelayed)
|
||||
{
|
||||
if (_elapsedTime >= _delay)
|
||||
{
|
||||
_elapsedTime -= _delay;
|
||||
_isDelayed = false;
|
||||
_action?.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_elapsedTime >= _interval)
|
||||
{
|
||||
_elapsedTime -= _interval;
|
||||
_action?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
AxibugEmuOnline.Client/Assets/Script/UI/PulseInvoker.cs.meta
Normal file
11
AxibugEmuOnline.Client/Assets/Script/UI/PulseInvoker.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1d72e5ab742c3d4094c7001ed2fc8e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -2,10 +2,9 @@ using AxibugEmuOnline.Client.UI;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
@ -30,15 +29,44 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void Init(List<MenuData> menuDataList)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
while (transform.childCount > 0)
|
||||
{
|
||||
DestroyImmediate(transform.GetChild(0).gameObject);
|
||||
}
|
||||
#else
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
Destroy(transform.GetChild(i).gameObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_runtimeMenuUI.Clear();
|
||||
foreach (MenuData menuData in menuDataList)
|
||||
{
|
||||
Clone(transform).SetData(menuData);
|
||||
var item = Clone(transform);
|
||||
item.SetData(menuData);
|
||||
m_runtimeMenuUI.Add(item);
|
||||
}
|
||||
|
||||
calcItemPosition();
|
||||
|
||||
for (var i = 0; i < m_runtimeMenuUI.Count; i++)
|
||||
{
|
||||
var item = m_runtimeMenuUI[i];
|
||||
var needPos = m_itemUIPosition[i];
|
||||
item.Rect.anchoredPosition = needPos;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCmdSelectItemUp()
|
||||
{
|
||||
SelectIndex--;
|
||||
}
|
||||
|
||||
protected override void OnCmdSelectItemDown()
|
||||
{
|
||||
SelectIndex++;
|
||||
}
|
||||
|
||||
public void SetSelect(bool select)
|
||||
@ -60,23 +88,63 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
selectTween = DOTween.To(() => alphaGroup.alpha, (x) => alphaGroup.alpha = x, 0, 10).SetSpeedBased();
|
||||
}
|
||||
|
||||
ListenControlAction = m_selected;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnSelectMenuChanged()
|
||||
{
|
||||
if (rollTween != null) { rollTween.Kill(); rollTween = null; }
|
||||
|
||||
rollTween = DOTween.To(() => 1, (x) => { }, 1, 1).OnUpdate(() =>
|
||||
float duration = 0.5f;
|
||||
|
||||
calcItemPosition();
|
||||
|
||||
rollTween = DOTween.To(() => 1, (x) => { }, 1, duration).OnUpdate(() =>
|
||||
{
|
||||
var tweenProgress = rollTween.position / rollTween.Duration();
|
||||
for (var i = 0; i < m_runtimeMenuUI.Count; i++)
|
||||
{
|
||||
var item = m_runtimeMenuUI[i];
|
||||
var needPos = m_itemUIPosition[i];
|
||||
item.Rect.anchoredPosition = Vector2.Lerp(item.Rect.anchoredPosition, needPos, tweenProgress);
|
||||
bool isSelectItem = i == SelectIndex;
|
||||
item.SetSelectState(isSelectItem);
|
||||
}
|
||||
}).OnComplete(() =>
|
||||
{
|
||||
for (var i = 0; i < m_runtimeMenuUI.Count; i++)
|
||||
{
|
||||
var item = m_runtimeMenuUI[i];
|
||||
bool isSelectItem = i == SelectIndex;
|
||||
item.SetSelectState(isSelectItem);
|
||||
var needPos = m_itemUIPosition[i];
|
||||
item.Rect.anchoredPosition = needPos;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
Vector2 m_selectItemPosition = new Vector2(50, -51);
|
||||
[SerializeField]
|
||||
float step = 50f;
|
||||
[SerializeField]
|
||||
float splitStep = 200f;
|
||||
|
||||
List<Vector2> m_itemUIPosition = new List<Vector2>();
|
||||
private void calcItemPosition()
|
||||
{
|
||||
m_itemUIPosition.Clear();
|
||||
for (int i = 0; i < m_runtimeMenuUI.Count; i++)
|
||||
{
|
||||
var gap = SelectIndex - i;
|
||||
var start = m_selectItemPosition;
|
||||
start.y += step * gap;
|
||||
if (i < SelectIndex) start.y += splitStep;
|
||||
|
||||
m_itemUIPosition.Add(start);
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem Clone(Transform parent)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
Loading…
Reference in New Issue
Block a user