1
This commit is contained in:
54
Assets/Domain/Test/HotUpdate/Application/UIViews/Launcher.cs
Normal file
54
Assets/Domain/Test/HotUpdate/Application/UIViews/Launcher.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Stary.Evo;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
public class Launcher : MonoBehaviour
|
||||
{
|
||||
public GameObject Splash;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (Splash == null)
|
||||
{
|
||||
Splash = GameObject.Find(nameof(Splash));
|
||||
}
|
||||
|
||||
StartCor();
|
||||
}
|
||||
|
||||
private async void StartCor()
|
||||
{
|
||||
// var resourceCore = ResourceManager.Instance.GetResourceCore(UIConfig.UIPackageName);
|
||||
//
|
||||
// await resourceCore.InitializeAsync(UIConfig.UIPackageName);
|
||||
|
||||
await UIManager.Instance.InitUIConfig();
|
||||
|
||||
await UIManager.Instance.Preload<UILoadingView>();
|
||||
|
||||
Loading.Instance.StartLoading(EnterGameCor);
|
||||
|
||||
if (Splash != null)
|
||||
{
|
||||
Splash.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator EnterGameCor(Action<float, string> loadingRefresh)
|
||||
{
|
||||
loadingRefresh?.Invoke(0.3f, "loading..........1");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
loadingRefresh?.Invoke(0.6f, "loading..........2");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
loadingRefresh?.Invoke(1, "loading..........3");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
UIManager.Instance.Open<UILoginView>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65f866947dd129249bcabba14c4a3ab2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/Domain/Test/HotUpdate/Application/UIViews/Loading.cs
Normal file
93
Assets/Domain/Test/HotUpdate/Application/UIViews/Loading.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class LoadingData
|
||||
{
|
||||
public LoadingFunc loadingFunc;
|
||||
public bool isCleanupAsset = false;
|
||||
}
|
||||
|
||||
public delegate IEnumerator LoadingFunc(Action<float, string> loadingRefresh);
|
||||
|
||||
/// <summary>
|
||||
/// 实际游戏中的loading
|
||||
/// </summary>
|
||||
public class Loading : SingletonMono<Loading>
|
||||
{
|
||||
private LoadingData _loadingData;
|
||||
private Coroutine _cor;
|
||||
|
||||
public void StartLoading(LoadingFunc loadingFunc, bool isCleanupAsset = false)
|
||||
{
|
||||
StartLoading(new LoadingData { loadingFunc = loadingFunc, isCleanupAsset = isCleanupAsset });
|
||||
}
|
||||
|
||||
private void StartLoading(LoadingData loadingData)
|
||||
{
|
||||
//开启UI
|
||||
UIManager.Instance.Open<UILoadingView>();
|
||||
|
||||
if (loadingData.loadingFunc != null)
|
||||
{
|
||||
_loadingData = loadingData;
|
||||
|
||||
if (_cor != null)
|
||||
{
|
||||
StopCoroutine(_cor);
|
||||
}
|
||||
_cor = StartCoroutine(CorLoading());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("加载错误,没有参数LoadingData!");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator CorLoading()
|
||||
{
|
||||
yield return StartCoroutine(_loadingData.loadingFunc(RefreshLoading));
|
||||
|
||||
// if (_loadingData != null && _loadingData.isCleanupAsset)
|
||||
// {
|
||||
// yield return ResourceManager.Instance.GetResourceCore(UIConfig.UIPackageName).CleanupAsync();
|
||||
// yield return Resources.UnloadUnusedAssets();
|
||||
// }
|
||||
|
||||
// Pool.ReleaseAll();
|
||||
// yield return null;
|
||||
|
||||
GC.Collect();
|
||||
yield return null;
|
||||
|
||||
Exit();
|
||||
|
||||
_cor = null;
|
||||
}
|
||||
|
||||
private void RefreshLoading(float loading, string desc)
|
||||
{
|
||||
// 刷新
|
||||
var view = UIManager.Instance.GetView<UILoadingView>();
|
||||
if (view != null)
|
||||
{
|
||||
view.SetLoading(loading, desc);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
Debug.Log(desc);
|
||||
}
|
||||
}
|
||||
|
||||
private void Exit()
|
||||
{
|
||||
// 关闭UI
|
||||
UIManager.Instance.Close<UILoadingView>();
|
||||
|
||||
ObjectPool<LoadingData>.Release(_loadingData);
|
||||
_loadingData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 713b44a81c68b61488afc7bb065ca96a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Domain/Test/HotUpdate/Application/UIViews/UIEvent.cs
Normal file
10
Assets/Domain/Test/HotUpdate/Application/UIViews/UIEvent.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public enum UIEvent
|
||||
{
|
||||
None,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8e3dcb8d2c6dd349927abfcb3361078
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class UILoadingView : UIView
|
||||
{
|
||||
#region 控件绑定变量声明,自动生成请勿手改
|
||||
#pragma warning disable 0649
|
||||
[ControlBinding]
|
||||
private TextMeshProUGUI TextDes;
|
||||
[ControlBinding]
|
||||
private Image Aniloading;
|
||||
|
||||
#pragma warning restore 0649
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void SetLoading(float value, string desc)
|
||||
{
|
||||
TextDes.text = $"{desc} {value * 100:F0}%";
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
TextDes.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9958976e3e375d148b96f791743cc13a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/Domain/Test/HotUpdate/Application/UIViews/UILoginView.cs
Normal file
106
Assets/Domain/Test/HotUpdate/Application/UIViews/UILoginView.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System.Collections;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class UITestItem : UILoopItem
|
||||
{
|
||||
#region 控件绑定变量声明,自动生成请勿手改
|
||||
|
||||
#pragma warning disable 0649
|
||||
[ControlBinding] private TextMeshProUGUI Text;
|
||||
[ControlBinding] private Button Button;
|
||||
[ControlBinding] private GameObject Select;
|
||||
|
||||
#pragma warning restore 0649
|
||||
|
||||
#endregion
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
Button.AddClick(() => { UIScrollView.Select(Index); });
|
||||
}
|
||||
|
||||
public override void CheckSelect(int index)
|
||||
{
|
||||
base.CheckSelect(index);
|
||||
Select.SetActive(index == Index);
|
||||
}
|
||||
|
||||
protected override void OnUpdateData(IList dataList, int index, object userData)
|
||||
{
|
||||
base.OnUpdateData(dataList, index, userData);
|
||||
|
||||
Text.text = dataList[index].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class UILoginView : UIView
|
||||
{
|
||||
#region 控件绑定变量声明,自动生成请勿手改
|
||||
|
||||
#pragma warning disable 0649
|
||||
[ControlBinding] private Button ButtonStart;
|
||||
[ControlBinding] private Button ButtonSetting;
|
||||
[ControlBinding] private UIScrollView UIScrollView;
|
||||
[ControlBinding] private GameObject Item;
|
||||
[ControlBinding] private RawImage RawImage;
|
||||
|
||||
#pragma warning restore 0649
|
||||
|
||||
#endregion
|
||||
|
||||
public override void OnInit(UIControlData uIControlData, UIViewController controller)
|
||||
{
|
||||
base.OnInit(uIControlData, controller);
|
||||
|
||||
ButtonStart.AddClick(() =>
|
||||
{
|
||||
UIManager.Instance.Open<UIMessageBoxView>(ObjectPool<MessageBoxData>.Get()
|
||||
.Set("提示", "测试弹窗。", () => { Debug.Log("确认"); }));
|
||||
});
|
||||
ButtonSetting.AddClick(() => { UIManager.Instance.Open<UITestView>(); });
|
||||
|
||||
UIScrollView.OnSelectChanged += (index) => { Debug.Log("选中了:" + index); };
|
||||
}
|
||||
|
||||
public override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
// 模拟100个数据
|
||||
List<int> list = new List<int>();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
list.Add(i);
|
||||
}
|
||||
|
||||
UIScrollView.UpdateList(list, Item, typeof(UITestItem));
|
||||
UIScrollView.Select(10);
|
||||
|
||||
UIModelManager.Instance.LoadModelToRawImage("Assets/UI/UISystemPackage/TestModel.prefab", RawImage,
|
||||
scale: Vector3.one * 6, isOrth: false, orthSizeOrFOV: 60);
|
||||
}
|
||||
|
||||
public override void OnAddListener()
|
||||
{
|
||||
base.OnAddListener();
|
||||
}
|
||||
|
||||
public override void OnRemoveListener()
|
||||
{
|
||||
base.OnRemoveListener();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
UIModelManager.Instance.UnLoadModelByRawImage(RawImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 767534c58c67230489467f81f1bfd94b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public enum MessageBoxType
|
||||
{
|
||||
TwoButton,
|
||||
OneButton,
|
||||
}
|
||||
|
||||
public class MessageBoxData
|
||||
{
|
||||
const string DefaultConfirmName = "确认";
|
||||
const string DefaultCancelName = "取消";
|
||||
|
||||
public string title;
|
||||
public string content;
|
||||
public Action confirm;
|
||||
public Action cancel;
|
||||
public string confirmName;
|
||||
public string cancelName;
|
||||
public MessageBoxType type;
|
||||
|
||||
public MessageBoxData Set(string title, string content, Action confirm, Action cancel = null
|
||||
, string confirmName = DefaultConfirmName, string cancelName = DefaultCancelName)
|
||||
{
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
this.confirm = confirm;
|
||||
this.cancel = cancel;
|
||||
this.confirmName = confirmName;
|
||||
this.cancelName = cancelName;
|
||||
this.type = MessageBoxType.TwoButton;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBoxData SetOneButton(string title, string content, Action confirm, Action cancel = null
|
||||
, string confirmName = DefaultConfirmName)
|
||||
{
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
this.confirm = confirm;
|
||||
this.cancel = cancel;
|
||||
this.confirmName = confirmName;
|
||||
this.cancelName = null;
|
||||
this.type = MessageBoxType.OneButton;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class UIMessageBoxView : UIView
|
||||
{
|
||||
#region 控件绑定变量声明,自动生成请勿手改
|
||||
#pragma warning disable 0649
|
||||
[ControlBinding]
|
||||
protected Button ButtonConfirm;
|
||||
[ControlBinding]
|
||||
protected TextMeshProUGUI TextTitle;
|
||||
[ControlBinding]
|
||||
protected TextMeshProUGUI TextContent;
|
||||
[ControlBinding]
|
||||
protected Button[] ButtonCloses;
|
||||
[ControlBinding]
|
||||
protected TextMeshProUGUI TextConfirm;
|
||||
[ControlBinding]
|
||||
protected TextMeshProUGUI TextCancel;
|
||||
|
||||
#pragma warning restore 0649
|
||||
#endregion
|
||||
|
||||
MessageBoxData data;
|
||||
|
||||
public override void OnInit(UIControlData uIControlData, UIViewController controller)
|
||||
{
|
||||
base.OnInit(uIControlData, controller);
|
||||
|
||||
foreach (var button in ButtonCloses)
|
||||
{
|
||||
button.AddClick(() =>
|
||||
{
|
||||
data.cancel?.Invoke();
|
||||
UIManager.Instance.Close(this);
|
||||
});
|
||||
}
|
||||
ButtonConfirm.AddClick(() =>
|
||||
{
|
||||
data.confirm?.Invoke();
|
||||
UIManager.Instance.Close(this);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
data = userData as MessageBoxData;
|
||||
|
||||
TextTitle.text = data.title;
|
||||
TextContent.text = data.content;
|
||||
TextConfirm.text = data.confirmName;
|
||||
TextCancel.text = data.cancelName;
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(TextContent.rectTransform);
|
||||
|
||||
ButtonCloses[1].gameObject.SetActive(data.type == MessageBoxType.TwoButton);
|
||||
}
|
||||
|
||||
public override void OnAddListener()
|
||||
{
|
||||
base.OnAddListener();
|
||||
}
|
||||
|
||||
public override void OnRemoveListener()
|
||||
{
|
||||
base.OnRemoveListener();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
ObjectPool<MessageBoxData>.Release(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05f58bedeae24be49a48df8fbdf016f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
namespace Stary.Evo
|
||||
{
|
||||
public class UITestView : UIView
|
||||
{
|
||||
#region 控件绑定变量声明,自动生成请勿手改
|
||||
#pragma warning disable 0649
|
||||
[ControlBinding]
|
||||
private Button ButtonClose;
|
||||
|
||||
#pragma warning restore 0649
|
||||
#endregion
|
||||
|
||||
public override void OnInit(UIControlData uIControlData, UIViewController controller)
|
||||
{
|
||||
base.OnInit(uIControlData, controller);
|
||||
|
||||
ButtonClose.AddClick(() =>
|
||||
{
|
||||
UIManager.Instance.Close(this);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
}
|
||||
|
||||
public override void OnAddListener()
|
||||
{
|
||||
base.OnAddListener();
|
||||
}
|
||||
|
||||
public override void OnRemoveListener()
|
||||
{
|
||||
base.OnRemoveListener();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1da5d512acbd21a458b830596dc3fb29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user