继续重构调整(UI)
- 引入 UniTask 和异步版本的 UIModule - 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI - 将原来的 5 层 UI 迁移到异步实现 - 规范各层的 UI 脚本命名
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class AboutForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private RectTransform _rectTransform = null;
|
||||
[SerializeField] private float _scrollSpeed = 1f;
|
||||
|
||||
private float _initPosition = 0f;
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnInit(object userData)
|
||||
#else
|
||||
protected internal override void OnInit(object userData)
|
||||
#endif
|
||||
{
|
||||
base.OnInit(userData);
|
||||
|
||||
CanvasScaler canvasScaler = GetComponentInParent<CanvasScaler>();
|
||||
if (canvasScaler == null)
|
||||
{
|
||||
Log.Warning("Can not find CanvasScaler component.");
|
||||
return;
|
||||
}
|
||||
|
||||
_initPosition = -0.5f * canvasScaler.referenceResolution.x * Screen.height / Screen.width;
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnOpen(object userData)
|
||||
#else
|
||||
protected internal override void OnOpen(object userData)
|
||||
#endif
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
_rectTransform.SetLocalPositionY(_initPosition);
|
||||
|
||||
// 换个音乐
|
||||
GameEntry.Sound.PlayMusic(3);
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
#else
|
||||
protected internal override void OnClose(bool isShutdown, object userData)
|
||||
#endif
|
||||
{
|
||||
base.OnClose(isShutdown, userData);
|
||||
|
||||
// 还原音乐
|
||||
GameEntry.Sound.PlayMusic(1);
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
#else
|
||||
protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
#endif
|
||||
{
|
||||
base.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
_rectTransform.AddLocalPositionY(_scrollSpeed * elapseSeconds);
|
||||
if (_rectTransform.localPosition.y > _rectTransform.sizeDelta.y - _initPosition)
|
||||
{
|
||||
_rectTransform.SetLocalPositionY(_initPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d18eec7c2f2d3d4ca59e310ef625db1
|
||||
timeCreated: 1528026160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user