初始化仓库
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using GameFramework.UI;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 关闭界面完成事件。
|
||||
/// </summary>
|
||||
public sealed class CloseUIFormCompleteEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 关闭界面完成事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(CloseUIFormCompleteEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化关闭界面完成事件的新实例。
|
||||
/// </summary>
|
||||
public CloseUIFormCompleteEventArgs()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroup = null;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取关闭界面完成事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面序列编号。
|
||||
/// </summary>
|
||||
public int SerialId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面资源名称。
|
||||
/// </summary>
|
||||
public string UIFormAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面所属的界面组。
|
||||
/// </summary>
|
||||
public IUIGroup UIGroup
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建关闭界面完成事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的关闭界面完成事件。</returns>
|
||||
public static CloseUIFormCompleteEventArgs Create(GameFramework.UI.CloseUIFormCompleteEventArgs e)
|
||||
{
|
||||
CloseUIFormCompleteEventArgs closeUIFormCompleteEventArgs = ReferencePool.Acquire<CloseUIFormCompleteEventArgs>();
|
||||
closeUIFormCompleteEventArgs.SerialId = e.SerialId;
|
||||
closeUIFormCompleteEventArgs.UIFormAssetName = e.UIFormAssetName;
|
||||
closeUIFormCompleteEventArgs.UIGroup = e.UIGroup;
|
||||
closeUIFormCompleteEventArgs.UserData = e.UserData;
|
||||
return closeUIFormCompleteEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理关闭界面完成事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroup = null;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5119cf2f6bdac343a0b73ee3a0aa400
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认界面辅助器。
|
||||
/// </summary>
|
||||
public class DefaultUIFormHelper : UIFormHelperBase
|
||||
{
|
||||
private ResourceComponent m_ResourceComponent = null;
|
||||
|
||||
/// <summary>
|
||||
/// 实例化界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAsset">要实例化的界面资源。</param>
|
||||
/// <returns>实例化后的界面。</returns>
|
||||
public override object InstantiateUIForm(object uiFormAsset)
|
||||
{
|
||||
return Instantiate((Object)uiFormAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormInstance">界面实例。</param>
|
||||
/// <param name="uiGroup">界面所属的界面组。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>界面。</returns>
|
||||
public override IUIForm CreateUIForm(object uiFormInstance, IUIGroup uiGroup, object userData)
|
||||
{
|
||||
GameObject gameObject = uiFormInstance as GameObject;
|
||||
if (gameObject == null)
|
||||
{
|
||||
Log.Error("UI form instance is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
Transform transform = gameObject.transform;
|
||||
transform.SetParent(((MonoBehaviour)uiGroup.Helper).transform);
|
||||
transform.localScale = Vector3.one;
|
||||
|
||||
return gameObject.GetOrAddComponent<UIForm>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAsset">要释放的界面资源。</param>
|
||||
/// <param name="uiFormInstance">要释放的界面实例。</param>
|
||||
public override void ReleaseUIForm(object uiFormAsset, object uiFormInstance)
|
||||
{
|
||||
m_ResourceComponent.UnloadAsset(uiFormAsset);
|
||||
Destroy((Object)uiFormInstance);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_ResourceComponent = GameEntry.GetComponent<ResourceComponent>();
|
||||
if (m_ResourceComponent == null)
|
||||
{
|
||||
Log.Fatal("Resource component is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0703eb62bea8944aa3fe2aa95df420a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认界面组辅助器。
|
||||
/// </summary>
|
||||
public class DefaultUIGroupHelper : UIGroupHelperBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置界面组深度。
|
||||
/// </summary>
|
||||
/// <param name="depth">界面组深度。</param>
|
||||
public override void SetDepth(int depth)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a9d94772d704094da287912ccaf5b4a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,155 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面时加载依赖资源事件。
|
||||
/// </summary>
|
||||
public sealed class OpenUIFormDependencyAssetEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面时加载依赖资源事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(OpenUIFormDependencyAssetEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化打开界面时加载依赖资源事件的新实例。
|
||||
/// </summary>
|
||||
public OpenUIFormDependencyAssetEventArgs()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroupName = null;
|
||||
PauseCoveredUIForm = false;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打开界面时加载依赖资源事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面序列编号。
|
||||
/// </summary>
|
||||
public int SerialId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面资源名称。
|
||||
/// </summary>
|
||||
public string UIFormAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组名称。
|
||||
/// </summary>
|
||||
public string UIGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否暂停被覆盖的界面。
|
||||
/// </summary>
|
||||
public bool PauseCoveredUIForm
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取被加载的依赖资源名称。
|
||||
/// </summary>
|
||||
public string DependencyAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前已加载依赖资源数量。
|
||||
/// </summary>
|
||||
public int LoadedCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取总共加载依赖资源数量。
|
||||
/// </summary>
|
||||
public int TotalCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建打开界面时加载依赖资源事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的打开界面时加载依赖资源事件。</returns>
|
||||
public static OpenUIFormDependencyAssetEventArgs Create(GameFramework.UI.OpenUIFormDependencyAssetEventArgs e)
|
||||
{
|
||||
OpenUIFormDependencyAssetEventArgs openUIFormDependencyAssetEventArgs = ReferencePool.Acquire<OpenUIFormDependencyAssetEventArgs>();
|
||||
openUIFormDependencyAssetEventArgs.SerialId = e.SerialId;
|
||||
openUIFormDependencyAssetEventArgs.UIFormAssetName = e.UIFormAssetName;
|
||||
openUIFormDependencyAssetEventArgs.UIGroupName = e.UIGroupName;
|
||||
openUIFormDependencyAssetEventArgs.PauseCoveredUIForm = e.PauseCoveredUIForm;
|
||||
openUIFormDependencyAssetEventArgs.DependencyAssetName = e.DependencyAssetName;
|
||||
openUIFormDependencyAssetEventArgs.LoadedCount = e.LoadedCount;
|
||||
openUIFormDependencyAssetEventArgs.TotalCount = e.TotalCount;
|
||||
openUIFormDependencyAssetEventArgs.UserData = e.UserData;
|
||||
return openUIFormDependencyAssetEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理打开界面时加载依赖资源事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroupName = null;
|
||||
PauseCoveredUIForm = false;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29b2ea8e2fa48e143adc8e647e8103bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面失败事件。
|
||||
/// </summary>
|
||||
public sealed class OpenUIFormFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(OpenUIFormFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化打开界面失败事件的新实例。
|
||||
/// </summary>
|
||||
public OpenUIFormFailureEventArgs()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroupName = null;
|
||||
PauseCoveredUIForm = false;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打开界面失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面序列编号。
|
||||
/// </summary>
|
||||
public int SerialId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面资源名称。
|
||||
/// </summary>
|
||||
public string UIFormAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组名称。
|
||||
/// </summary>
|
||||
public string UIGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否暂停被覆盖的界面。
|
||||
/// </summary>
|
||||
public bool PauseCoveredUIForm
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错误信息。
|
||||
/// </summary>
|
||||
public string ErrorMessage
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建打开界面失败事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的打开界面失败事件。</returns>
|
||||
public static OpenUIFormFailureEventArgs Create(GameFramework.UI.OpenUIFormFailureEventArgs e)
|
||||
{
|
||||
OpenUIFormFailureEventArgs openUIFormFailureEventArgs = ReferencePool.Acquire<OpenUIFormFailureEventArgs>();
|
||||
openUIFormFailureEventArgs.SerialId = e.SerialId;
|
||||
openUIFormFailureEventArgs.UIFormAssetName = e.UIFormAssetName;
|
||||
openUIFormFailureEventArgs.UIGroupName = e.UIGroupName;
|
||||
openUIFormFailureEventArgs.PauseCoveredUIForm = e.PauseCoveredUIForm;
|
||||
openUIFormFailureEventArgs.ErrorMessage = e.ErrorMessage;
|
||||
openUIFormFailureEventArgs.UserData = e.UserData;
|
||||
return openUIFormFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理打开界面失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroupName = null;
|
||||
PauseCoveredUIForm = false;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7a6ba1b6a998054a893693b3ae07794
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面成功事件。
|
||||
/// </summary>
|
||||
public sealed class OpenUIFormSuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(OpenUIFormSuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化打开界面成功事件的新实例。
|
||||
/// </summary>
|
||||
public OpenUIFormSuccessEventArgs()
|
||||
{
|
||||
UIForm = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打开界面成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打开成功的界面。
|
||||
/// </summary>
|
||||
public UIForm UIForm
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载持续时间。
|
||||
/// </summary>
|
||||
public float Duration
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建打开界面成功事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的打开界面成功事件。</returns>
|
||||
public static OpenUIFormSuccessEventArgs Create(GameFramework.UI.OpenUIFormSuccessEventArgs e)
|
||||
{
|
||||
OpenUIFormSuccessEventArgs openUIFormSuccessEventArgs = ReferencePool.Acquire<OpenUIFormSuccessEventArgs>();
|
||||
openUIFormSuccessEventArgs.UIForm = (UIForm)e.UIForm;
|
||||
openUIFormSuccessEventArgs.Duration = e.Duration;
|
||||
openUIFormSuccessEventArgs.UserData = e.UserData;
|
||||
return openUIFormSuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理打开界面成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
UIForm = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 269e4d0709b02614d8509248981e82d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面更新事件。
|
||||
/// </summary>
|
||||
public sealed class OpenUIFormUpdateEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开界面更新事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(OpenUIFormUpdateEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化打开界面更新事件的新实例。
|
||||
/// </summary>
|
||||
public OpenUIFormUpdateEventArgs()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroupName = null;
|
||||
PauseCoveredUIForm = false;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打开界面更新事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面序列编号。
|
||||
/// </summary>
|
||||
public int SerialId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面资源名称。
|
||||
/// </summary>
|
||||
public string UIFormAssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组名称。
|
||||
/// </summary>
|
||||
public string UIGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否暂停被覆盖的界面。
|
||||
/// </summary>
|
||||
public bool PauseCoveredUIForm
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打开界面进度。
|
||||
/// </summary>
|
||||
public float Progress
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户自定义数据。
|
||||
/// </summary>
|
||||
public object UserData
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建打开界面更新事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的打开界面更新事件。</returns>
|
||||
public static OpenUIFormUpdateEventArgs Create(GameFramework.UI.OpenUIFormUpdateEventArgs e)
|
||||
{
|
||||
OpenUIFormUpdateEventArgs openUIFormUpdateEventArgs = ReferencePool.Acquire<OpenUIFormUpdateEventArgs>();
|
||||
openUIFormUpdateEventArgs.SerialId = e.SerialId;
|
||||
openUIFormUpdateEventArgs.UIFormAssetName = e.UIFormAssetName;
|
||||
openUIFormUpdateEventArgs.UIGroupName = e.UIGroupName;
|
||||
openUIFormUpdateEventArgs.PauseCoveredUIForm = e.PauseCoveredUIForm;
|
||||
openUIFormUpdateEventArgs.Progress = e.Progress;
|
||||
openUIFormUpdateEventArgs.UserData = e.UserData;
|
||||
return openUIFormUpdateEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理打开界面更新事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
SerialId = 0;
|
||||
UIFormAssetName = null;
|
||||
UIGroupName = null;
|
||||
PauseCoveredUIForm = false;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 314460751754f5d468a04af842439e8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class UIComponent : GameFrameworkComponent
|
||||
{
|
||||
[Serializable]
|
||||
private sealed class UIGroup
|
||||
{
|
||||
[SerializeField]
|
||||
private string m_Name = null;
|
||||
|
||||
[SerializeField]
|
||||
private int m_Depth = 0;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
|
||||
public int Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f90c498e6b5e013499a1536555584b93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,730 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.ObjectPool;
|
||||
using GameFramework.Resource;
|
||||
using GameFramework.UI;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面组件。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Game Framework/UI")]
|
||||
public sealed partial class UIComponent : GameFrameworkComponent
|
||||
{
|
||||
private const int DefaultPriority = 0;
|
||||
|
||||
private IUIManager m_UIManager = null;
|
||||
private EventComponent m_EventComponent = null;
|
||||
|
||||
private readonly List<IUIForm> m_InternalUIFormResults = new List<IUIForm>();
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableOpenUIFormSuccessEvent = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableOpenUIFormFailureEvent = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableOpenUIFormUpdateEvent = false;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableOpenUIFormDependencyAssetEvent = false;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableCloseUIFormCompleteEvent = true;
|
||||
|
||||
[SerializeField]
|
||||
private float m_InstanceAutoReleaseInterval = 60f;
|
||||
|
||||
[SerializeField]
|
||||
private int m_InstanceCapacity = 16;
|
||||
|
||||
[SerializeField]
|
||||
private float m_InstanceExpireTime = 60f;
|
||||
|
||||
[SerializeField]
|
||||
private int m_InstancePriority = 0;
|
||||
|
||||
[SerializeField]
|
||||
private Transform m_InstanceRoot = null;
|
||||
|
||||
[SerializeField]
|
||||
private string m_UIFormHelperTypeName = "UnityGameFramework.Runtime.DefaultUIFormHelper";
|
||||
|
||||
[SerializeField]
|
||||
private UIFormHelperBase m_CustomUIFormHelper = null;
|
||||
|
||||
[SerializeField]
|
||||
private string m_UIGroupHelperTypeName = "UnityGameFramework.Runtime.DefaultUIGroupHelper";
|
||||
|
||||
[SerializeField]
|
||||
private UIGroupHelperBase m_CustomUIGroupHelper = null;
|
||||
|
||||
[SerializeField]
|
||||
private UIGroup[] m_UIGroups = null;
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组数量。
|
||||
/// </summary>
|
||||
public int UIGroupCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIManager.UIGroupCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置界面实例对象池自动释放可释放对象的间隔秒数。
|
||||
/// </summary>
|
||||
public float InstanceAutoReleaseInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIManager.InstanceAutoReleaseInterval;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_UIManager.InstanceAutoReleaseInterval = m_InstanceAutoReleaseInterval = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置界面实例对象池的容量。
|
||||
/// </summary>
|
||||
public int InstanceCapacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIManager.InstanceCapacity;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_UIManager.InstanceCapacity = m_InstanceCapacity = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置界面实例对象池对象过期秒数。
|
||||
/// </summary>
|
||||
public float InstanceExpireTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIManager.InstanceExpireTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_UIManager.InstanceExpireTime = m_InstanceExpireTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置界面实例对象池的优先级。
|
||||
/// </summary>
|
||||
public int InstancePriority
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIManager.InstancePriority;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_UIManager.InstancePriority = m_InstancePriority = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏框架组件初始化。
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
m_UIManager = GameFrameworkEntry.GetModule<IUIManager>();
|
||||
if (m_UIManager == null)
|
||||
{
|
||||
Log.Fatal("UI manager is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_EnableOpenUIFormSuccessEvent)
|
||||
{
|
||||
m_UIManager.OpenUIFormSuccess += OnOpenUIFormSuccess;
|
||||
}
|
||||
|
||||
m_UIManager.OpenUIFormFailure += OnOpenUIFormFailure;
|
||||
|
||||
if (m_EnableOpenUIFormUpdateEvent)
|
||||
{
|
||||
m_UIManager.OpenUIFormUpdate += OnOpenUIFormUpdate;
|
||||
}
|
||||
|
||||
if (m_EnableOpenUIFormDependencyAssetEvent)
|
||||
{
|
||||
m_UIManager.OpenUIFormDependencyAsset += OnOpenUIFormDependencyAsset;
|
||||
}
|
||||
|
||||
if (m_EnableCloseUIFormCompleteEvent)
|
||||
{
|
||||
m_UIManager.CloseUIFormComplete += OnCloseUIFormComplete;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
BaseComponent baseComponent = GameEntry.GetComponent<BaseComponent>();
|
||||
if (baseComponent == null)
|
||||
{
|
||||
Log.Fatal("Base component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_EventComponent = GameEntry.GetComponent<EventComponent>();
|
||||
if (m_EventComponent == null)
|
||||
{
|
||||
Log.Fatal("Event component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (baseComponent.EditorResourceMode)
|
||||
{
|
||||
m_UIManager.SetResourceManager(baseComponent.EditorResourceHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_UIManager.SetResourceManager(GameFrameworkEntry.GetModule<IResourceManager>());
|
||||
}
|
||||
|
||||
m_UIManager.SetObjectPoolManager(GameFrameworkEntry.GetModule<IObjectPoolManager>());
|
||||
m_UIManager.InstanceAutoReleaseInterval = m_InstanceAutoReleaseInterval;
|
||||
m_UIManager.InstanceCapacity = m_InstanceCapacity;
|
||||
m_UIManager.InstanceExpireTime = m_InstanceExpireTime;
|
||||
m_UIManager.InstancePriority = m_InstancePriority;
|
||||
|
||||
UIFormHelperBase uiFormHelper = Helper.CreateHelper(m_UIFormHelperTypeName, m_CustomUIFormHelper);
|
||||
if (uiFormHelper == null)
|
||||
{
|
||||
Log.Error("Can not create UI form helper.");
|
||||
return;
|
||||
}
|
||||
|
||||
uiFormHelper.name = "UI Form Helper";
|
||||
Transform transform = uiFormHelper.transform;
|
||||
transform.SetParent(this.transform);
|
||||
transform.localScale = Vector3.one;
|
||||
|
||||
m_UIManager.SetUIFormHelper(uiFormHelper);
|
||||
|
||||
if (m_InstanceRoot == null)
|
||||
{
|
||||
m_InstanceRoot = new GameObject("UI Form Instances").transform;
|
||||
m_InstanceRoot.SetParent(gameObject.transform);
|
||||
m_InstanceRoot.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");
|
||||
|
||||
for (int i = 0; i < m_UIGroups.Length; i++)
|
||||
{
|
||||
if (!AddUIGroup(m_UIGroups[i].Name, m_UIGroups[i].Depth))
|
||||
{
|
||||
Log.Warning("Add UI group '{0}' failure.", m_UIGroups[i].Name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在界面组。
|
||||
/// </summary>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <returns>是否存在界面组。</returns>
|
||||
public bool HasUIGroup(string uiGroupName)
|
||||
{
|
||||
return m_UIManager.HasUIGroup(uiGroupName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组。
|
||||
/// </summary>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <returns>要获取的界面组。</returns>
|
||||
public IUIGroup GetUIGroup(string uiGroupName)
|
||||
{
|
||||
return m_UIManager.GetUIGroup(uiGroupName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有界面组。
|
||||
/// </summary>
|
||||
/// <returns>所有界面组。</returns>
|
||||
public IUIGroup[] GetAllUIGroups()
|
||||
{
|
||||
return m_UIManager.GetAllUIGroups();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有界面组。
|
||||
/// </summary>
|
||||
/// <param name="results">所有界面组。</param>
|
||||
public void GetAllUIGroups(List<IUIGroup> results)
|
||||
{
|
||||
m_UIManager.GetAllUIGroups(results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加界面组。
|
||||
/// </summary>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <returns>是否增加界面组成功。</returns>
|
||||
public bool AddUIGroup(string uiGroupName)
|
||||
{
|
||||
return AddUIGroup(uiGroupName, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加界面组。
|
||||
/// </summary>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="depth">界面组深度。</param>
|
||||
/// <returns>是否增加界面组成功。</returns>
|
||||
public bool AddUIGroup(string uiGroupName, int depth)
|
||||
{
|
||||
if (m_UIManager.HasUIGroup(uiGroupName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
UIGroupHelperBase uiGroupHelper = Helper.CreateHelper(m_UIGroupHelperTypeName, m_CustomUIGroupHelper, UIGroupCount);
|
||||
if (uiGroupHelper == null)
|
||||
{
|
||||
Log.Error("Can not create UI group helper.");
|
||||
return false;
|
||||
}
|
||||
|
||||
uiGroupHelper.name = Utility.Text.Format("UI Group - {0}", uiGroupName);
|
||||
uiGroupHelper.gameObject.layer = LayerMask.NameToLayer("UI");
|
||||
Transform transform = uiGroupHelper.transform;
|
||||
transform.SetParent(m_InstanceRoot);
|
||||
transform.localScale = Vector3.one;
|
||||
|
||||
return m_UIManager.AddUIGroup(uiGroupName, depth, uiGroupHelper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在界面。
|
||||
/// </summary>
|
||||
/// <param name="serialId">界面序列编号。</param>
|
||||
/// <returns>是否存在界面。</returns>
|
||||
public bool HasUIForm(int serialId)
|
||||
{
|
||||
return m_UIManager.HasUIForm(serialId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <returns>是否存在界面。</returns>
|
||||
public bool HasUIForm(string uiFormAssetName)
|
||||
{
|
||||
return m_UIManager.HasUIForm(uiFormAssetName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面。
|
||||
/// </summary>
|
||||
/// <param name="serialId">界面序列编号。</param>
|
||||
/// <returns>要获取的界面。</returns>
|
||||
public UIForm GetUIForm(int serialId)
|
||||
{
|
||||
return (UIForm)m_UIManager.GetUIForm(serialId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <returns>要获取的界面。</returns>
|
||||
public UIForm GetUIForm(string uiFormAssetName)
|
||||
{
|
||||
return (UIForm)m_UIManager.GetUIForm(uiFormAssetName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <returns>要获取的界面。</returns>
|
||||
public UIForm[] GetUIForms(string uiFormAssetName)
|
||||
{
|
||||
IUIForm[] uiForms = m_UIManager.GetUIForms(uiFormAssetName);
|
||||
UIForm[] uiFormImpls = new UIForm[uiForms.Length];
|
||||
for (int i = 0; i < uiForms.Length; i++)
|
||||
{
|
||||
uiFormImpls[i] = (UIForm)uiForms[i];
|
||||
}
|
||||
|
||||
return uiFormImpls;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="results">要获取的界面。</param>
|
||||
public void GetUIForms(string uiFormAssetName, List<UIForm> results)
|
||||
{
|
||||
if (results == null)
|
||||
{
|
||||
Log.Error("Results is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
results.Clear();
|
||||
m_UIManager.GetUIForms(uiFormAssetName, m_InternalUIFormResults);
|
||||
foreach (IUIForm uiForm in m_InternalUIFormResults)
|
||||
{
|
||||
results.Add((UIForm)uiForm);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有已加载的界面。
|
||||
/// </summary>
|
||||
/// <returns>所有已加载的界面。</returns>
|
||||
public UIForm[] GetAllLoadedUIForms()
|
||||
{
|
||||
IUIForm[] uiForms = m_UIManager.GetAllLoadedUIForms();
|
||||
UIForm[] uiFormImpls = new UIForm[uiForms.Length];
|
||||
for (int i = 0; i < uiForms.Length; i++)
|
||||
{
|
||||
uiFormImpls[i] = (UIForm)uiForms[i];
|
||||
}
|
||||
|
||||
return uiFormImpls;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有已加载的界面。
|
||||
/// </summary>
|
||||
/// <param name="results">所有已加载的界面。</param>
|
||||
public void GetAllLoadedUIForms(List<UIForm> results)
|
||||
{
|
||||
if (results == null)
|
||||
{
|
||||
Log.Error("Results is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
results.Clear();
|
||||
m_UIManager.GetAllLoadedUIForms(m_InternalUIFormResults);
|
||||
foreach (IUIForm uiForm in m_InternalUIFormResults)
|
||||
{
|
||||
results.Add((UIForm)uiForm);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有正在加载界面的序列编号。
|
||||
/// </summary>
|
||||
/// <returns>所有正在加载界面的序列编号。</returns>
|
||||
public int[] GetAllLoadingUIFormSerialIds()
|
||||
{
|
||||
return m_UIManager.GetAllLoadingUIFormSerialIds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有正在加载界面的序列编号。
|
||||
/// </summary>
|
||||
/// <param name="results">所有正在加载界面的序列编号。</param>
|
||||
public void GetAllLoadingUIFormSerialIds(List<int> results)
|
||||
{
|
||||
m_UIManager.GetAllLoadingUIFormSerialIds(results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否正在加载界面。
|
||||
/// </summary>
|
||||
/// <param name="serialId">界面序列编号。</param>
|
||||
/// <returns>是否正在加载界面。</returns>
|
||||
public bool IsLoadingUIForm(int serialId)
|
||||
{
|
||||
return m_UIManager.IsLoadingUIForm(serialId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否正在加载界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <returns>是否正在加载界面。</returns>
|
||||
public bool IsLoadingUIForm(string uiFormAssetName)
|
||||
{
|
||||
return m_UIManager.IsLoadingUIForm(uiFormAssetName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是合法的界面。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">界面。</param>
|
||||
/// <returns>界面是否合法。</returns>
|
||||
public bool IsValidUIForm(UIForm uiForm)
|
||||
{
|
||||
return m_UIManager.IsValidUIForm(uiForm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, DefaultPriority, false, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="priority">加载界面资源的优先级。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, int priority)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, priority, false, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, bool pauseCoveredUIForm)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, DefaultPriority, pauseCoveredUIForm, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, object userData)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, DefaultPriority, false, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="priority">加载界面资源的优先级。</param>
|
||||
/// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, int priority, bool pauseCoveredUIForm)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, priority, pauseCoveredUIForm, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="priority">加载界面资源的优先级。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, int priority, object userData)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, priority, false, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, bool pauseCoveredUIForm, object userData)
|
||||
{
|
||||
return OpenUIForm(uiFormAssetName, uiGroupName, DefaultPriority, pauseCoveredUIForm, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroupName">界面组名称。</param>
|
||||
/// <param name="priority">加载界面资源的优先级。</param>
|
||||
/// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>界面的序列编号。</returns>
|
||||
public int OpenUIForm(string uiFormAssetName, string uiGroupName, int priority, bool pauseCoveredUIForm, object userData)
|
||||
{
|
||||
return m_UIManager.OpenUIForm(uiFormAssetName, uiGroupName, priority, pauseCoveredUIForm, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭界面。
|
||||
/// </summary>
|
||||
/// <param name="serialId">要关闭界面的序列编号。</param>
|
||||
public void CloseUIForm(int serialId)
|
||||
{
|
||||
m_UIManager.CloseUIForm(serialId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭界面。
|
||||
/// </summary>
|
||||
/// <param name="serialId">要关闭界面的序列编号。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void CloseUIForm(int serialId, object userData)
|
||||
{
|
||||
m_UIManager.CloseUIForm(serialId, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭界面。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">要关闭的界面。</param>
|
||||
public void CloseUIForm(UIForm uiForm)
|
||||
{
|
||||
m_UIManager.CloseUIForm(uiForm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭界面。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">要关闭的界面。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void CloseUIForm(UIForm uiForm, object userData)
|
||||
{
|
||||
m_UIManager.CloseUIForm(uiForm, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭所有已加载的界面。
|
||||
/// </summary>
|
||||
public void CloseAllLoadedUIForms()
|
||||
{
|
||||
m_UIManager.CloseAllLoadedUIForms();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭所有已加载的界面。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void CloseAllLoadedUIForms(object userData)
|
||||
{
|
||||
m_UIManager.CloseAllLoadedUIForms(userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭所有正在加载的界面。
|
||||
/// </summary>
|
||||
public void CloseAllLoadingUIForms()
|
||||
{
|
||||
m_UIManager.CloseAllLoadingUIForms();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活界面。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">要激活的界面。</param>
|
||||
public void RefocusUIForm(UIForm uiForm)
|
||||
{
|
||||
m_UIManager.RefocusUIForm(uiForm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活界面。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">要激活的界面。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void RefocusUIForm(UIForm uiForm, object userData)
|
||||
{
|
||||
m_UIManager.RefocusUIForm(uiForm, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置界面是否被加锁。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">要设置是否被加锁的界面。</param>
|
||||
/// <param name="locked">界面是否被加锁。</param>
|
||||
public void SetUIFormInstanceLocked(UIForm uiForm, bool locked)
|
||||
{
|
||||
if (uiForm == null)
|
||||
{
|
||||
Log.Warning("UI form is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_UIManager.SetUIFormInstanceLocked(uiForm.gameObject, locked);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置界面的优先级。
|
||||
/// </summary>
|
||||
/// <param name="uiForm">要设置优先级的界面。</param>
|
||||
/// <param name="priority">界面优先级。</param>
|
||||
public void SetUIFormInstancePriority(UIForm uiForm, int priority)
|
||||
{
|
||||
if (uiForm == null)
|
||||
{
|
||||
Log.Warning("UI form is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_UIManager.SetUIFormInstancePriority(uiForm.gameObject, priority);
|
||||
}
|
||||
|
||||
private void OnOpenUIFormSuccess(object sender, GameFramework.UI.OpenUIFormSuccessEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, OpenUIFormSuccessEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnOpenUIFormFailure(object sender, GameFramework.UI.OpenUIFormFailureEventArgs e)
|
||||
{
|
||||
Log.Warning("Open UI form failure, asset name '{0}', UI group name '{1}', pause covered UI form '{2}', error message '{3}'.", e.UIFormAssetName, e.UIGroupName, e.PauseCoveredUIForm, e.ErrorMessage);
|
||||
if (m_EnableOpenUIFormFailureEvent)
|
||||
{
|
||||
m_EventComponent.Fire(this, OpenUIFormFailureEventArgs.Create(e));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOpenUIFormUpdate(object sender, GameFramework.UI.OpenUIFormUpdateEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, OpenUIFormUpdateEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnOpenUIFormDependencyAsset(object sender, GameFramework.UI.OpenUIFormDependencyAssetEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, OpenUIFormDependencyAssetEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnCloseUIFormComplete(object sender, GameFramework.UI.CloseUIFormCompleteEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, CloseUIFormCompleteEventArgs.Create(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a1ef15380caaed42b55022cadc93649
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,305 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.UI;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面。
|
||||
/// </summary>
|
||||
public sealed class UIForm : MonoBehaviour, IUIForm
|
||||
{
|
||||
private int m_SerialId;
|
||||
private string m_UIFormAssetName;
|
||||
private IUIGroup m_UIGroup;
|
||||
private int m_DepthInUIGroup;
|
||||
private bool m_PauseCoveredUIForm;
|
||||
private UIFormLogic m_UIFormLogic;
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面序列编号。
|
||||
/// </summary>
|
||||
public int SerialId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SerialId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面资源名称。
|
||||
/// </summary>
|
||||
public string UIFormAssetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIFormAssetName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面实例。
|
||||
/// </summary>
|
||||
public object Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
return gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面所属的界面组。
|
||||
/// </summary>
|
||||
public IUIGroup UIGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIGroup;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面深度。
|
||||
/// </summary>
|
||||
public int DepthInUIGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DepthInUIGroup;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否暂停被覆盖的界面。
|
||||
/// </summary>
|
||||
public bool PauseCoveredUIForm
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_PauseCoveredUIForm;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面逻辑。
|
||||
/// </summary>
|
||||
public UIFormLogic Logic
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UIFormLogic;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化界面。
|
||||
/// </summary>
|
||||
/// <param name="serialId">界面序列编号。</param>
|
||||
/// <param name="uiFormAssetName">界面资源名称。</param>
|
||||
/// <param name="uiGroup">界面所处的界面组。</param>
|
||||
/// <param name="pauseCoveredUIForm">是否暂停被覆盖的界面。</param>
|
||||
/// <param name="isNewInstance">是否是新实例。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnInit(int serialId, string uiFormAssetName, IUIGroup uiGroup, bool pauseCoveredUIForm, bool isNewInstance, object userData)
|
||||
{
|
||||
m_SerialId = serialId;
|
||||
m_UIFormAssetName = uiFormAssetName;
|
||||
m_UIGroup = uiGroup;
|
||||
m_DepthInUIGroup = 0;
|
||||
m_PauseCoveredUIForm = pauseCoveredUIForm;
|
||||
|
||||
if (!isNewInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_UIFormLogic = GetComponent<UIFormLogic>();
|
||||
if (m_UIFormLogic == null)
|
||||
{
|
||||
Log.Error("UI form '{0}' can not get UI form logic.", uiFormAssetName);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnInit(userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnInit with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面回收。
|
||||
/// </summary>
|
||||
public void OnRecycle()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnRecycle();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnRecycle with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
|
||||
m_SerialId = 0;
|
||||
m_DepthInUIGroup = 0;
|
||||
m_PauseCoveredUIForm = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面打开。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnOpen(object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnOpen(userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnOpen with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面关闭。
|
||||
/// </summary>
|
||||
/// <param name="isShutdown">是否是关闭界面管理器时触发。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnClose(isShutdown, userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnClose with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面暂停。
|
||||
/// </summary>
|
||||
public void OnPause()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnPause();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnPause with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面暂停恢复。
|
||||
/// </summary>
|
||||
public void OnResume()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnResume();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnResume with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面遮挡。
|
||||
/// </summary>
|
||||
public void OnCover()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnCover();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnCover with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面遮挡恢复。
|
||||
/// </summary>
|
||||
public void OnReveal()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnReveal();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnReveal with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面激活。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void OnRefocus(object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnRefocus(userData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnRefocus with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面轮询。
|
||||
/// </summary>
|
||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnUpdate with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面深度改变。
|
||||
/// </summary>
|
||||
/// <param name="uiGroupDepth">界面组深度。</param>
|
||||
/// <param name="depthInUIGroup">界面在界面组中的深度。</param>
|
||||
public void OnDepthChanged(int uiGroupDepth, int depthInUIGroup)
|
||||
{
|
||||
m_DepthInUIGroup = depthInUIGroup;
|
||||
try
|
||||
{
|
||||
m_UIFormLogic.OnDepthChanged(uiGroupDepth, depthInUIGroup);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error("UI form '[{0}]{1}' OnDepthChanged with exception '{2}'.", m_SerialId, m_UIFormAssetName, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f627c32af5133a24f829e711fafe42fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class UIFormHelperBase : MonoBehaviour, IUIFormHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAsset">要实例化的界面资源。</param>
|
||||
/// <returns>实例化后的界面。</returns>
|
||||
public abstract object InstantiateUIForm(object uiFormAsset);
|
||||
|
||||
/// <summary>
|
||||
/// 创建界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormInstance">界面实例。</param>
|
||||
/// <param name="uiGroup">界面所属的界面组。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>界面。</returns>
|
||||
public abstract IUIForm CreateUIForm(object uiFormInstance, IUIGroup uiGroup, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 释放界面。
|
||||
/// </summary>
|
||||
/// <param name="uiFormAsset">要释放的界面资源。</param>
|
||||
/// <param name="uiFormInstance">要释放的界面实例。</param>
|
||||
public abstract void ReleaseUIForm(object uiFormAsset, object uiFormInstance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a33f1f48cf25a4a44bd85661139f76ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,201 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面逻辑基类。
|
||||
/// </summary>
|
||||
public abstract class UIFormLogic : MonoBehaviour
|
||||
{
|
||||
private bool m_Available = false;
|
||||
private bool m_Visible = false;
|
||||
private UIForm m_UIForm = null;
|
||||
private Transform m_CachedTransform = null;
|
||||
private int m_OriginalLayer = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面。
|
||||
/// </summary>
|
||||
public UIForm UIForm => m_UIForm;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置界面名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return gameObject.name;
|
||||
}
|
||||
set
|
||||
{
|
||||
gameObject.name = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面是否可用。
|
||||
/// </summary>
|
||||
public bool Available
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置界面是否可见。
|
||||
/// </summary>
|
||||
public bool Visible
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Available && m_Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!m_Available)
|
||||
{
|
||||
Log.Warning("UI form '{0}' is not available.", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Visible == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Visible = value;
|
||||
InternalSetVisible(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已缓存的 Transform。
|
||||
/// </summary>
|
||||
public Transform CachedTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CachedTransform;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面初始化。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnInit(object userData)
|
||||
{
|
||||
if (m_CachedTransform == null)
|
||||
{
|
||||
m_CachedTransform = transform;
|
||||
}
|
||||
|
||||
m_UIForm = GetComponent<UIForm>();
|
||||
m_OriginalLayer = gameObject.layer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面回收。
|
||||
/// </summary>
|
||||
protected internal virtual void OnRecycle()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面打开。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnOpen(object userData)
|
||||
{
|
||||
m_Available = true;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面关闭。
|
||||
/// </summary>
|
||||
/// <param name="isShutdown">是否是关闭界面管理器时触发。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
gameObject.SetLayerRecursively(m_OriginalLayer);
|
||||
Visible = false;
|
||||
m_Available = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面暂停。
|
||||
/// </summary>
|
||||
protected internal virtual void OnPause()
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面暂停恢复。
|
||||
/// </summary>
|
||||
protected internal virtual void OnResume()
|
||||
{
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面遮挡。
|
||||
/// </summary>
|
||||
protected internal virtual void OnCover()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面遮挡恢复。
|
||||
/// </summary>
|
||||
protected internal virtual void OnReveal()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面激活。
|
||||
/// </summary>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
protected internal virtual void OnRefocus(object userData)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面轮询。
|
||||
/// </summary>
|
||||
/// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param>
|
||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||
protected internal virtual void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 界面深度改变。
|
||||
/// </summary>
|
||||
/// <param name="uiGroupDepth">界面组深度。</param>
|
||||
/// <param name="depthInUIGroup">界面在界面组中的深度。</param>
|
||||
protected internal virtual void OnDepthChanged(int uiGroupDepth, int depthInUIGroup)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置界面的可见性。
|
||||
/// </summary>
|
||||
/// <param name="visible">界面的可见性。</param>
|
||||
protected virtual void InternalSetVisible(bool visible)
|
||||
{
|
||||
gameObject.SetActive(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0293f872933ead649893db69d7f4e2ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面组辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class UIGroupHelperBase : MonoBehaviour, IUIGroupHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置界面组深度。
|
||||
/// </summary>
|
||||
/// <param name="depth">界面组深度。</param>
|
||||
public abstract void SetDepth(int depth);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02539b9fb3e30984ea1707e6f87bc3d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面整型主键。
|
||||
/// </summary>
|
||||
public sealed class UIIntKey : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_Key = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置主键。
|
||||
/// </summary>
|
||||
public int Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Key;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Key = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 606f38525c5bccb4d9355c54a60746f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面字符型主键。
|
||||
/// </summary>
|
||||
public sealed class UIStringKey : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string m_Key = null;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置主键。
|
||||
/// </summary>
|
||||
public string Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Key ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Key = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 087a56c75d247be4f8f7cf82ceb68e4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user