初始化仓库
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fef53289940cb524687e31ef870f5029
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,425 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Localization;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础组件。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Game Framework/Base")]
|
||||
public sealed class BaseComponent : GameFrameworkComponent
|
||||
{
|
||||
private const int DefaultDpi = 96; // default windows dpi
|
||||
|
||||
private float m_GameSpeedBeforePause = 1f;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EditorResourceMode = true;
|
||||
|
||||
[SerializeField]
|
||||
private Language m_EditorLanguage = Language.Unspecified;
|
||||
|
||||
[SerializeField]
|
||||
private string m_TextHelperTypeName = "UnityGameFramework.Runtime.DefaultTextHelper";
|
||||
|
||||
[SerializeField]
|
||||
private string m_VersionHelperTypeName = "UnityGameFramework.Runtime.DefaultVersionHelper";
|
||||
|
||||
[SerializeField]
|
||||
private string m_LogHelperTypeName = "UnityGameFramework.Runtime.DefaultLogHelper";
|
||||
|
||||
[SerializeField]
|
||||
private string m_CompressionHelperTypeName = "UnityGameFramework.Runtime.DefaultCompressionHelper";
|
||||
|
||||
[SerializeField]
|
||||
private string m_JsonHelperTypeName = "UnityGameFramework.Runtime.DefaultJsonHelper";
|
||||
|
||||
[SerializeField]
|
||||
private int m_FrameRate = 30;
|
||||
|
||||
[SerializeField]
|
||||
private float m_GameSpeed = 1f;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_RunInBackground = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_NeverSleep = true;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否使用编辑器资源模式(仅编辑器内有效)。
|
||||
/// </summary>
|
||||
public bool EditorResourceMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EditorResourceMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_EditorResourceMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置编辑器语言(仅编辑器内有效)。
|
||||
/// </summary>
|
||||
public Language EditorLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_EditorLanguage;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_EditorLanguage = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置编辑器资源辅助器。
|
||||
/// </summary>
|
||||
public IResourceManager EditorResourceHelper
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置游戏帧率。
|
||||
/// </summary>
|
||||
public int FrameRate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FrameRate;
|
||||
}
|
||||
set
|
||||
{
|
||||
Application.targetFrameRate = m_FrameRate = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置游戏速度。
|
||||
/// </summary>
|
||||
public float GameSpeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_GameSpeed;
|
||||
}
|
||||
set
|
||||
{
|
||||
Time.timeScale = m_GameSpeed = value >= 0f ? value : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取游戏是否暂停。
|
||||
/// </summary>
|
||||
public bool IsGamePaused
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_GameSpeed <= 0f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否正常游戏速度。
|
||||
/// </summary>
|
||||
public bool IsNormalGameSpeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_GameSpeed == 1f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否允许后台运行。
|
||||
/// </summary>
|
||||
public bool RunInBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_RunInBackground;
|
||||
}
|
||||
set
|
||||
{
|
||||
Application.runInBackground = m_RunInBackground = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置是否禁止休眠。
|
||||
/// </summary>
|
||||
public bool NeverSleep
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_NeverSleep;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_NeverSleep = value;
|
||||
Screen.sleepTimeout = value ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏框架组件初始化。
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
InitTextHelper();
|
||||
InitVersionHelper();
|
||||
InitLogHelper();
|
||||
Log.Info("Game Framework Version: {0}", GameFramework.Version.GameFrameworkVersion);
|
||||
Log.Info("Game Version: {0} ({1})", GameFramework.Version.GameVersion, GameFramework.Version.InternalGameVersion);
|
||||
Log.Info("Unity Version: {0}", Application.unityVersion);
|
||||
|
||||
#if UNITY_5_3_OR_NEWER || UNITY_5_3
|
||||
InitCompressionHelper();
|
||||
InitJsonHelper();
|
||||
|
||||
Utility.Converter.ScreenDpi = Screen.dpi;
|
||||
if (Utility.Converter.ScreenDpi <= 0)
|
||||
{
|
||||
Utility.Converter.ScreenDpi = DefaultDpi;
|
||||
}
|
||||
|
||||
m_EditorResourceMode &= Application.isEditor;
|
||||
if (m_EditorResourceMode)
|
||||
{
|
||||
Log.Info("During this run, Game Framework will use editor resource files, which you should validate first.");
|
||||
}
|
||||
|
||||
Application.targetFrameRate = m_FrameRate;
|
||||
Time.timeScale = m_GameSpeed;
|
||||
Application.runInBackground = m_RunInBackground;
|
||||
Screen.sleepTimeout = m_NeverSleep ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting;
|
||||
#else
|
||||
Log.Error("Game Framework only applies with Unity 5.3 and above, but current Unity version is {0}.", Application.unityVersion);
|
||||
GameEntry.Shutdown(ShutdownType.Quit);
|
||||
#endif
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
Application.lowMemory += OnLowMemory;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
GameFrameworkEntry.Update(Time.deltaTime, Time.unscaledDeltaTime);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
Application.lowMemory -= OnLowMemory;
|
||||
#endif
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
GameFrameworkEntry.Shutdown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停游戏。
|
||||
/// </summary>
|
||||
public void PauseGame()
|
||||
{
|
||||
if (IsGamePaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_GameSpeedBeforePause = GameSpeed;
|
||||
GameSpeed = 0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复游戏。
|
||||
/// </summary>
|
||||
public void ResumeGame()
|
||||
{
|
||||
if (!IsGamePaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameSpeed = m_GameSpeedBeforePause;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置为正常游戏速度。
|
||||
/// </summary>
|
||||
public void ResetNormalGameSpeed()
|
||||
{
|
||||
if (IsNormalGameSpeed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameSpeed = 1f;
|
||||
}
|
||||
|
||||
internal void Shutdown()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void InitTextHelper()
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_TextHelperTypeName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type textHelperType = Utility.Assembly.GetType(m_TextHelperTypeName);
|
||||
if (textHelperType == null)
|
||||
{
|
||||
Log.Error("Can not find text helper type '{0}'.", m_TextHelperTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Utility.Text.ITextHelper textHelper = (Utility.Text.ITextHelper)Activator.CreateInstance(textHelperType);
|
||||
if (textHelper == null)
|
||||
{
|
||||
Log.Error("Can not create text helper instance '{0}'.", m_TextHelperTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Utility.Text.SetTextHelper(textHelper);
|
||||
}
|
||||
|
||||
private void InitVersionHelper()
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_VersionHelperTypeName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type versionHelperType = Utility.Assembly.GetType(m_VersionHelperTypeName);
|
||||
if (versionHelperType == null)
|
||||
{
|
||||
throw new GameFrameworkException(Utility.Text.Format("Can not find version helper type '{0}'.", m_VersionHelperTypeName));
|
||||
}
|
||||
|
||||
GameFramework.Version.IVersionHelper versionHelper = (GameFramework.Version.IVersionHelper)Activator.CreateInstance(versionHelperType);
|
||||
if (versionHelper == null)
|
||||
{
|
||||
throw new GameFrameworkException(Utility.Text.Format("Can not create version helper instance '{0}'.", m_VersionHelperTypeName));
|
||||
}
|
||||
|
||||
GameFramework.Version.SetVersionHelper(versionHelper);
|
||||
}
|
||||
|
||||
private void InitLogHelper()
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_LogHelperTypeName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type logHelperType = Utility.Assembly.GetType(m_LogHelperTypeName);
|
||||
if (logHelperType == null)
|
||||
{
|
||||
throw new GameFrameworkException(Utility.Text.Format("Can not find log helper type '{0}'.", m_LogHelperTypeName));
|
||||
}
|
||||
|
||||
GameFrameworkLog.ILogHelper logHelper = (GameFrameworkLog.ILogHelper)Activator.CreateInstance(logHelperType);
|
||||
if (logHelper == null)
|
||||
{
|
||||
throw new GameFrameworkException(Utility.Text.Format("Can not create log helper instance '{0}'.", m_LogHelperTypeName));
|
||||
}
|
||||
|
||||
GameFrameworkLog.SetLogHelper(logHelper);
|
||||
}
|
||||
|
||||
private void InitCompressionHelper()
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_CompressionHelperTypeName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type compressionHelperType = Utility.Assembly.GetType(m_CompressionHelperTypeName);
|
||||
if (compressionHelperType == null)
|
||||
{
|
||||
Log.Error("Can not find compression helper type '{0}'.", m_CompressionHelperTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Utility.Compression.ICompressionHelper compressionHelper = (Utility.Compression.ICompressionHelper)Activator.CreateInstance(compressionHelperType);
|
||||
if (compressionHelper == null)
|
||||
{
|
||||
Log.Error("Can not create compression helper instance '{0}'.", m_CompressionHelperTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Utility.Compression.SetCompressionHelper(compressionHelper);
|
||||
}
|
||||
|
||||
private void InitJsonHelper()
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_JsonHelperTypeName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type jsonHelperType = Utility.Assembly.GetType(m_JsonHelperTypeName);
|
||||
if (jsonHelperType == null)
|
||||
{
|
||||
Log.Error("Can not find JSON helper type '{0}'.", m_JsonHelperTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Utility.Json.IJsonHelper jsonHelper = (Utility.Json.IJsonHelper)Activator.CreateInstance(jsonHelperType);
|
||||
if (jsonHelper == null)
|
||||
{
|
||||
Log.Error("Can not create JSON helper instance '{0}'.", m_JsonHelperTypeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Utility.Json.SetJsonHelper(jsonHelper);
|
||||
}
|
||||
|
||||
private void OnLowMemory()
|
||||
{
|
||||
Log.Info("Low memory reported...");
|
||||
|
||||
ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent<ObjectPoolComponent>();
|
||||
if (objectPoolComponent != null)
|
||||
{
|
||||
objectPoolComponent.ReleaseAllUnused();
|
||||
}
|
||||
|
||||
ResourceComponent resourceCompoent = GameEntry.GetComponent<ResourceComponent>();
|
||||
if (resourceCompoent != null)
|
||||
{
|
||||
resourceCompoent.ForceUnloadUnusedAssets(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f98acd7d3bd2bf54dadf9644f60e5cb9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏入口。
|
||||
/// </summary>
|
||||
public static class GameEntry
|
||||
{
|
||||
private static readonly GameFrameworkLinkedList<GameFrameworkComponent> s_GameFrameworkComponents = new GameFrameworkLinkedList<GameFrameworkComponent>();
|
||||
|
||||
/// <summary>
|
||||
/// 游戏框架所在的场景编号。
|
||||
/// </summary>
|
||||
internal const int GameFrameworkSceneId = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取游戏框架组件。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要获取的游戏框架组件类型。</typeparam>
|
||||
/// <returns>要获取的游戏框架组件。</returns>
|
||||
public static T GetComponent<T>() where T : GameFrameworkComponent
|
||||
{
|
||||
return (T)GetComponent(typeof(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取游戏框架组件。
|
||||
/// </summary>
|
||||
/// <param name="type">要获取的游戏框架组件类型。</param>
|
||||
/// <returns>要获取的游戏框架组件。</returns>
|
||||
public static GameFrameworkComponent GetComponent(Type type)
|
||||
{
|
||||
LinkedListNode<GameFrameworkComponent> current = s_GameFrameworkComponents.First;
|
||||
while (current != null)
|
||||
{
|
||||
if (current.Value.GetType() == type)
|
||||
{
|
||||
return current.Value;
|
||||
}
|
||||
|
||||
current = current.Next;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取游戏框架组件。
|
||||
/// </summary>
|
||||
/// <param name="typeName">要获取的游戏框架组件类型名称。</param>
|
||||
/// <returns>要获取的游戏框架组件。</returns>
|
||||
public static GameFrameworkComponent GetComponent(string typeName)
|
||||
{
|
||||
LinkedListNode<GameFrameworkComponent> current = s_GameFrameworkComponents.First;
|
||||
while (current != null)
|
||||
{
|
||||
Type type = current.Value.GetType();
|
||||
if (type.FullName == typeName || type.Name == typeName)
|
||||
{
|
||||
return current.Value;
|
||||
}
|
||||
|
||||
current = current.Next;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭游戏框架。
|
||||
/// </summary>
|
||||
/// <param name="shutdownType">关闭游戏框架类型。</param>
|
||||
public static void Shutdown(ShutdownType shutdownType)
|
||||
{
|
||||
Log.Info("Shutdown Game Framework ({0})...", shutdownType);
|
||||
BaseComponent baseComponent = GetComponent<BaseComponent>();
|
||||
if (baseComponent != null)
|
||||
{
|
||||
baseComponent.Shutdown();
|
||||
baseComponent = null;
|
||||
}
|
||||
|
||||
s_GameFrameworkComponents.Clear();
|
||||
|
||||
if (shutdownType == ShutdownType.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (shutdownType == ShutdownType.Restart)
|
||||
{
|
||||
SceneManager.LoadScene(GameFrameworkSceneId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (shutdownType == ShutdownType.Quit)
|
||||
{
|
||||
Application.Quit();
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册游戏框架组件。
|
||||
/// </summary>
|
||||
/// <param name="gameFrameworkComponent">要注册的游戏框架组件。</param>
|
||||
internal static void RegisterComponent(GameFrameworkComponent gameFrameworkComponent)
|
||||
{
|
||||
if (gameFrameworkComponent == null)
|
||||
{
|
||||
Log.Error("Game Framework component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
Type type = gameFrameworkComponent.GetType();
|
||||
|
||||
LinkedListNode<GameFrameworkComponent> current = s_GameFrameworkComponents.First;
|
||||
while (current != null)
|
||||
{
|
||||
if (current.Value.GetType() == type)
|
||||
{
|
||||
Log.Error("Game Framework component type '{0}' is already exist.", type.FullName);
|
||||
return;
|
||||
}
|
||||
|
||||
current = current.Next;
|
||||
}
|
||||
|
||||
s_GameFrameworkComponents.AddLast(gameFrameworkComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd346220e820e384b816477cdf1e1bb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------
|
||||
// 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 GameFrameworkComponent : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏框架组件初始化。
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
GameEntry.RegisterComponent(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbf5faef1b7b7d24c8375006438a0cd0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------
|
||||
// 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 enum ShutdownType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 仅关闭游戏框架。
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 关闭游戏框架并重启游戏。
|
||||
/// </summary>
|
||||
Restart,
|
||||
|
||||
/// <summary>
|
||||
/// 关闭游戏框架并退出游戏。
|
||||
/// </summary>
|
||||
Quit,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e19747752388e14bbe312e0f4c44e00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff4afea74c892e04e984aa34aa089b89
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,408 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Config;
|
||||
using GameFramework.Resource;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局配置组件。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Game Framework/Config")]
|
||||
public sealed class ConfigComponent : GameFrameworkComponent
|
||||
{
|
||||
private const int DefaultPriority = 0;
|
||||
|
||||
private IConfigManager m_ConfigManager = null;
|
||||
private EventComponent m_EventComponent = null;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableLoadConfigUpdateEvent = false;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableLoadConfigDependencyAssetEvent = false;
|
||||
|
||||
[SerializeField]
|
||||
private string m_ConfigHelperTypeName = "UnityGameFramework.Runtime.DefaultConfigHelper";
|
||||
|
||||
[SerializeField]
|
||||
private ConfigHelperBase m_CustomConfigHelper = null;
|
||||
|
||||
[SerializeField]
|
||||
private int m_CachedBytesSize = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取全局配置项数量。
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ConfigManager.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓冲二进制流的大小。
|
||||
/// </summary>
|
||||
public int CachedBytesSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ConfigManager.CachedBytesSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏框架组件初始化。
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
m_ConfigManager = GameFrameworkEntry.GetModule<IConfigManager>();
|
||||
if (m_ConfigManager == null)
|
||||
{
|
||||
Log.Fatal("Config manager is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_ConfigManager.ReadDataSuccess += OnReadDataSuccess;
|
||||
m_ConfigManager.ReadDataFailure += OnReadDataFailure;
|
||||
|
||||
if (m_EnableLoadConfigUpdateEvent)
|
||||
{
|
||||
m_ConfigManager.ReadDataUpdate += OnReadDataUpdate;
|
||||
}
|
||||
|
||||
if (m_EnableLoadConfigDependencyAssetEvent)
|
||||
{
|
||||
m_ConfigManager.ReadDataDependencyAsset += OnReadDataDependencyAsset;
|
||||
}
|
||||
}
|
||||
|
||||
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_ConfigManager.SetResourceManager(baseComponent.EditorResourceHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ConfigManager.SetResourceManager(GameFrameworkEntry.GetModule<IResourceManager>());
|
||||
}
|
||||
|
||||
ConfigHelperBase configHelper = Helper.CreateHelper(m_ConfigHelperTypeName, m_CustomConfigHelper);
|
||||
if (configHelper == null)
|
||||
{
|
||||
Log.Error("Can not create config helper.");
|
||||
return;
|
||||
}
|
||||
|
||||
configHelper.name = "Config Helper";
|
||||
Transform transform = configHelper.transform;
|
||||
transform.SetParent(this.transform);
|
||||
transform.localScale = Vector3.one;
|
||||
|
||||
m_ConfigManager.SetDataProviderHelper(configHelper);
|
||||
m_ConfigManager.SetConfigHelper(configHelper);
|
||||
if (m_CachedBytesSize > 0)
|
||||
{
|
||||
EnsureCachedBytesSize(m_CachedBytesSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确保二进制流缓存分配足够大小的内存并缓存。
|
||||
/// </summary>
|
||||
/// <param name="ensureSize">要确保二进制流缓存分配内存的大小。</param>
|
||||
public void EnsureCachedBytesSize(int ensureSize)
|
||||
{
|
||||
m_ConfigManager.EnsureCachedBytesSize(ensureSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放缓存的二进制流。
|
||||
/// </summary>
|
||||
public void FreeCachedBytes()
|
||||
{
|
||||
m_ConfigManager.FreeCachedBytes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
public void ReadData(string configAssetName)
|
||||
{
|
||||
m_ConfigManager.ReadData(configAssetName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="priority">加载全局配置资源的优先级。</param>
|
||||
public void ReadData(string configAssetName, int priority)
|
||||
{
|
||||
m_ConfigManager.ReadData(configAssetName, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void ReadData(string configAssetName, object userData)
|
||||
{
|
||||
m_ConfigManager.ReadData(configAssetName, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="priority">加载全局配置资源的优先级。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public void ReadData(string configAssetName, int priority, object userData)
|
||||
{
|
||||
m_ConfigManager.ReadData(configAssetName, priority, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configString">要解析的全局配置字符串。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public bool ParseData(string configString)
|
||||
{
|
||||
return m_ConfigManager.ParseData(configString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configString">要解析的全局配置字符串。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public bool ParseData(string configString, object userData)
|
||||
{
|
||||
return m_ConfigManager.ParseData(configString, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configBytes">要解析的全局配置二进制流。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public bool ParseData(byte[] configBytes)
|
||||
{
|
||||
return m_ConfigManager.ParseData(configBytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configBytes">要解析的全局配置二进制流。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public bool ParseData(byte[] configBytes, object userData)
|
||||
{
|
||||
return m_ConfigManager.ParseData(configBytes, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configBytes">要解析的全局配置二进制流。</param>
|
||||
/// <param name="startIndex">全局配置二进制流的起始位置。</param>
|
||||
/// <param name="length">全局配置二进制流的长度。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public bool ParseData(byte[] configBytes, int startIndex, int length)
|
||||
{
|
||||
return m_ConfigManager.ParseData(configBytes, startIndex, length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configBytes">要解析的全局配置二进制流。</param>
|
||||
/// <param name="startIndex">全局配置二进制流的起始位置。</param>
|
||||
/// <param name="length">全局配置二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public bool ParseData(byte[] configBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
return m_ConfigManager.ParseData(configBytes, startIndex, length, userData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否存在指定全局配置项。
|
||||
/// </summary>
|
||||
/// <param name="configName">要检查全局配置项的名称。</param>
|
||||
/// <returns>指定的全局配置项是否存在。</returns>
|
||||
public bool HasConfig(string configName)
|
||||
{
|
||||
return m_ConfigManager.HasConfig(configName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取布尔值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <returns>读取的布尔值。</returns>
|
||||
public bool GetBool(string configName)
|
||||
{
|
||||
return m_ConfigManager.GetBool(configName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取布尔值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <param name="defaultValue">当指定的全局配置项不存在时,返回此默认值。</param>
|
||||
/// <returns>读取的布尔值。</returns>
|
||||
public bool GetBool(string configName, bool defaultValue)
|
||||
{
|
||||
return m_ConfigManager.GetBool(configName, defaultValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取整数值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <returns>读取的整数值。</returns>
|
||||
public int GetInt(string configName)
|
||||
{
|
||||
return m_ConfigManager.GetInt(configName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取整数值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <param name="defaultValue">当指定的全局配置项不存在时,返回此默认值。</param>
|
||||
/// <returns>读取的整数值。</returns>
|
||||
public int GetInt(string configName, int defaultValue)
|
||||
{
|
||||
return m_ConfigManager.GetInt(configName, defaultValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取浮点数值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <returns>读取的浮点数值。</returns>
|
||||
public float GetFloat(string configName)
|
||||
{
|
||||
return m_ConfigManager.GetFloat(configName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取浮点数值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <param name="defaultValue">当指定的全局配置项不存在时,返回此默认值。</param>
|
||||
/// <returns>读取的浮点数值。</returns>
|
||||
public float GetFloat(string configName, float defaultValue)
|
||||
{
|
||||
return m_ConfigManager.GetFloat(configName, defaultValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取字符串值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <returns>读取的字符串值。</returns>
|
||||
public string GetString(string configName)
|
||||
{
|
||||
return m_ConfigManager.GetString(configName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从指定全局配置项中读取字符串值。
|
||||
/// </summary>
|
||||
/// <param name="configName">要获取全局配置项的名称。</param>
|
||||
/// <param name="defaultValue">当指定的全局配置项不存在时,返回此默认值。</param>
|
||||
/// <returns>读取的字符串值。</returns>
|
||||
public string GetString(string configName, string defaultValue)
|
||||
{
|
||||
return m_ConfigManager.GetString(configName, defaultValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加指定全局配置项。
|
||||
/// </summary>
|
||||
/// <param name="configName">要增加全局配置项的名称。</param>
|
||||
/// <param name="boolValue">全局配置项布尔值。</param>
|
||||
/// <param name="intValue">全局配置项整数值。</param>
|
||||
/// <param name="floatValue">全局配置项浮点数值。</param>
|
||||
/// <param name="stringValue">全局配置项字符串值。</param>
|
||||
/// <returns>是否增加全局配置项成功。</returns>
|
||||
public bool AddConfig(string configName, bool boolValue, int intValue, float floatValue, string stringValue)
|
||||
{
|
||||
return m_ConfigManager.AddConfig(configName, boolValue, intValue, floatValue, stringValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除指定全局配置项。
|
||||
/// </summary>
|
||||
/// <param name="configName">要移除全局配置项的名称。</param>
|
||||
/// <returns>是否移除全局配置项成功。</returns>
|
||||
public bool RemoveConfig(string configName)
|
||||
{
|
||||
return m_ConfigManager.RemoveConfig(configName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有全局配置项。
|
||||
/// </summary>
|
||||
public void RemoveAllConfigs()
|
||||
{
|
||||
m_ConfigManager.RemoveAllConfigs();
|
||||
}
|
||||
|
||||
private void OnReadDataSuccess(object sender, ReadDataSuccessEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, LoadConfigSuccessEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnReadDataFailure(object sender, ReadDataFailureEventArgs e)
|
||||
{
|
||||
Log.Warning("Load config failure, asset name '{0}', error message '{1}'.", e.DataAssetName, e.ErrorMessage);
|
||||
m_EventComponent.Fire(this, LoadConfigFailureEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnReadDataUpdate(object sender, ReadDataUpdateEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, LoadConfigUpdateEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnReadDataDependencyAsset(object sender, ReadDataDependencyAssetEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, LoadConfigDependencyAssetEventArgs.Create(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e847b2b3e22e9b4792ca7ea6e1714c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Config;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局配置辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class ConfigHelperBase : MonoBehaviour, IDataProviderHelper<IConfigManager>, IConfigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="configAsset">全局配置资源。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取全局配置成功。</returns>
|
||||
public abstract bool ReadData(IConfigManager configManager, string configAssetName, object configAsset, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="configBytes">全局配置二进制流。</param>
|
||||
/// <param name="startIndex">全局配置二进制流的起始位置。</param>
|
||||
/// <param name="length">全局配置二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取全局配置成功。</returns>
|
||||
public abstract bool ReadData(IConfigManager configManager, string configAssetName, byte[] configBytes, int startIndex, int length, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configString">要解析的全局配置字符串。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public abstract bool ParseData(IConfigManager configManager, string configString, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configBytes">要解析的全局配置二进制流。</param>
|
||||
/// <param name="startIndex">全局配置二进制流的起始位置。</param>
|
||||
/// <param name="length">全局配置二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public abstract bool ParseData(IConfigManager configManager, byte[] configBytes, int startIndex, int length, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 释放全局配置资源。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configAsset">要释放的全局配置资源。</param>
|
||||
public abstract void ReleaseDataAsset(IConfigManager configManager, object configAsset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5588940f3b356ec4b9cee3c5b4a905f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,181 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Config;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认全局配置辅助器。
|
||||
/// </summary>
|
||||
public class DefaultConfigHelper : ConfigHelperBase
|
||||
{
|
||||
private static readonly string[] ColumnSplitSeparator = new string[] { "\t" };
|
||||
private static readonly string BytesAssetExtension = ".bytes";
|
||||
private const int ColumnCount = 4;
|
||||
|
||||
private ResourceComponent m_ResourceComponent = null;
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="configAsset">全局配置资源。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取全局配置成功。</returns>
|
||||
public override bool ReadData(IConfigManager configManager, string configAssetName, object configAsset, object userData)
|
||||
{
|
||||
TextAsset configTextAsset = configAsset as TextAsset;
|
||||
if (configTextAsset != null)
|
||||
{
|
||||
if (configAssetName.EndsWith(BytesAssetExtension, StringComparison.Ordinal))
|
||||
{
|
||||
return configManager.ParseData(configTextAsset.bytes, userData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return configManager.ParseData(configTextAsset.text, userData);
|
||||
}
|
||||
}
|
||||
|
||||
Log.Warning("Config asset '{0}' is invalid.", configAssetName);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configAssetName">全局配置资源名称。</param>
|
||||
/// <param name="configBytes">全局配置二进制流。</param>
|
||||
/// <param name="startIndex">全局配置二进制流的起始位置。</param>
|
||||
/// <param name="length">全局配置二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取全局配置成功。</returns>
|
||||
public override bool ReadData(IConfigManager configManager, string configAssetName, byte[] configBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
if (configAssetName.EndsWith(BytesAssetExtension, StringComparison.Ordinal))
|
||||
{
|
||||
return configManager.ParseData(configBytes, startIndex, length, userData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return configManager.ParseData(Utility.Converter.GetString(configBytes, startIndex, length), userData);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configString">要解析的全局配置字符串。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public override bool ParseData(IConfigManager configManager, string configString, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
int position = 0;
|
||||
string configLineString = null;
|
||||
while ((configLineString = configString.ReadLine(ref position)) != null)
|
||||
{
|
||||
if (configLineString[0] == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] splitedLine = configLineString.Split(ColumnSplitSeparator, StringSplitOptions.None);
|
||||
if (splitedLine.Length != ColumnCount)
|
||||
{
|
||||
Log.Warning("Can not parse config line string '{0}' which column count is invalid.", configLineString);
|
||||
return false;
|
||||
}
|
||||
|
||||
string configName = splitedLine[1];
|
||||
string configValue = splitedLine[3];
|
||||
if (!configManager.AddConfig(configName, configValue))
|
||||
{
|
||||
Log.Warning("Can not add config with config name '{0}' which may be invalid or duplicate.", configName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Can not parse config string with exception '{0}'.", exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析全局配置。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configBytes">要解析的全局配置二进制流。</param>
|
||||
/// <param name="startIndex">全局配置二进制流的起始位置。</param>
|
||||
/// <param name="length">全局配置二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析全局配置成功。</returns>
|
||||
public override bool ParseData(IConfigManager configManager, byte[] configBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(configBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
|
||||
{
|
||||
string configName = binaryReader.ReadString();
|
||||
string configValue = binaryReader.ReadString();
|
||||
if (!configManager.AddConfig(configName, configValue))
|
||||
{
|
||||
Log.Warning("Can not add config with config name '{0}' which may be invalid or duplicate.", configName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Can not parse config bytes with exception '{0}'.", exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放全局配置资源。
|
||||
/// </summary>
|
||||
/// <param name="configManager">全局配置管理器。</param>
|
||||
/// <param name="configAsset">要释放的全局配置资源。</param>
|
||||
public override void ReleaseDataAsset(IConfigManager configManager, object configAsset)
|
||||
{
|
||||
m_ResourceComponent.UnloadAsset(configAsset);
|
||||
}
|
||||
|
||||
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: 9c039b1ea5c75e24fa12a58ab3227ab7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// 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 LoadConfigDependencyAssetEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载全局配置失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadConfigDependencyAssetEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载全局配置时加载依赖资源事件的新实例。
|
||||
/// </summary>
|
||||
public LoadConfigDependencyAssetEventArgs()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载全局配置失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全局配置资源名称。
|
||||
/// </summary>
|
||||
public string ConfigAssetName
|
||||
{
|
||||
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 LoadConfigDependencyAssetEventArgs Create(ReadDataDependencyAssetEventArgs e)
|
||||
{
|
||||
LoadConfigDependencyAssetEventArgs loadConfigDependencyAssetEventArgs = ReferencePool.Acquire<LoadConfigDependencyAssetEventArgs>();
|
||||
loadConfigDependencyAssetEventArgs.ConfigAssetName = e.DataAssetName;
|
||||
loadConfigDependencyAssetEventArgs.DependencyAssetName = e.DependencyAssetName;
|
||||
loadConfigDependencyAssetEventArgs.LoadedCount = e.LoadedCount;
|
||||
loadConfigDependencyAssetEventArgs.TotalCount = e.TotalCount;
|
||||
loadConfigDependencyAssetEventArgs.UserData = e.UserData;
|
||||
return loadConfigDependencyAssetEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载全局配置时加载依赖资源事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 224a6c56bac19dc47b5a08f772e59af1
|
||||
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 LoadConfigFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载全局配置失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadConfigFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载全局配置失败事件的新实例。
|
||||
/// </summary>
|
||||
public LoadConfigFailureEventArgs()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载全局配置失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全局配置资源名称。
|
||||
/// </summary>
|
||||
public string ConfigAssetName
|
||||
{
|
||||
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 LoadConfigFailureEventArgs Create(ReadDataFailureEventArgs e)
|
||||
{
|
||||
LoadConfigFailureEventArgs loadConfigFailureEventArgs = ReferencePool.Acquire<LoadConfigFailureEventArgs>();
|
||||
loadConfigFailureEventArgs.ConfigAssetName = e.DataAssetName;
|
||||
loadConfigFailureEventArgs.ErrorMessage = e.ErrorMessage;
|
||||
loadConfigFailureEventArgs.UserData = e.UserData;
|
||||
return loadConfigFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载全局配置失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca7b842aaf795c6428b7a23287dec802
|
||||
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 LoadConfigSuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载全局配置成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadConfigSuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载全局配置成功事件编号的新实例。
|
||||
/// </summary>
|
||||
public LoadConfigSuccessEventArgs()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载全局配置成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全局配置资源名称。
|
||||
/// </summary>
|
||||
public string ConfigAssetName
|
||||
{
|
||||
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 LoadConfigSuccessEventArgs Create(ReadDataSuccessEventArgs e)
|
||||
{
|
||||
LoadConfigSuccessEventArgs loadConfigSuccessEventArgs = ReferencePool.Acquire<LoadConfigSuccessEventArgs>();
|
||||
loadConfigSuccessEventArgs.ConfigAssetName = e.DataAssetName;
|
||||
loadConfigSuccessEventArgs.Duration = e.Duration;
|
||||
loadConfigSuccessEventArgs.UserData = e.UserData;
|
||||
return loadConfigSuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载全局配置成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8edee6cdf050d4f47ac48581f944d4ae
|
||||
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 LoadConfigUpdateEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载全局配置失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadConfigUpdateEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载全局配置更新事件的新实例。
|
||||
/// </summary>
|
||||
public LoadConfigUpdateEventArgs()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载全局配置失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全局配置资源名称。
|
||||
/// </summary>
|
||||
public string ConfigAssetName
|
||||
{
|
||||
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 LoadConfigUpdateEventArgs Create(ReadDataUpdateEventArgs e)
|
||||
{
|
||||
LoadConfigUpdateEventArgs loadConfigUpdateEventArgs = ReferencePool.Acquire<LoadConfigUpdateEventArgs>();
|
||||
loadConfigUpdateEventArgs.ConfigAssetName = e.DataAssetName;
|
||||
loadConfigUpdateEventArgs.Progress = e.Progress;
|
||||
loadConfigUpdateEventArgs.UserData = e.UserData;
|
||||
return loadConfigUpdateEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载全局配置更新事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
ConfigAssetName = null;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07c976efcbda2464bb7ef36e80504f3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f919642531f20564094b12cd52df111d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,210 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.DataNode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据结点组件。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Game Framework/Data Node")]
|
||||
public sealed class DataNodeComponent : GameFrameworkComponent
|
||||
{
|
||||
private IDataNodeManager m_DataNodeManager = null;
|
||||
|
||||
/// <summary>
|
||||
/// 获取根数据结点。
|
||||
/// </summary>
|
||||
public IDataNode Root
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DataNodeManager.Root;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏框架组件初始化。
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
m_DataNodeManager = GameFrameworkEntry.GetModule<IDataNodeManager>();
|
||||
if (m_DataNodeManager == null)
|
||||
{
|
||||
Log.Fatal("Data node manager is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据类型获取数据结点的数据。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要获取的数据类型。</typeparam>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <returns>指定类型的数据。</returns>
|
||||
public T GetData<T>(string path) where T : Variable
|
||||
{
|
||||
return m_DataNodeManager.GetData<T>(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据结点的数据。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <returns>数据结点的数据。</returns>
|
||||
public Variable GetData(string path)
|
||||
{
|
||||
return m_DataNodeManager.GetData(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据类型获取数据结点的数据。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要获取的数据类型。</typeparam>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
/// <returns>指定类型的数据。</returns>
|
||||
public T GetData<T>(string path, IDataNode node) where T : Variable
|
||||
{
|
||||
return m_DataNodeManager.GetData<T>(path, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据结点的数据。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
/// <returns>数据结点的数据。</returns>
|
||||
public Variable GetData(string path, IDataNode node)
|
||||
{
|
||||
return m_DataNodeManager.GetData(path, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置数据结点的数据。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要设置的数据类型。</typeparam>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="data">要设置的数据。</param>
|
||||
public void SetData<T>(string path, T data) where T : Variable
|
||||
{
|
||||
m_DataNodeManager.SetData(path, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置数据结点的数据。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="data">要设置的数据。</param>
|
||||
public void SetData(string path, Variable data)
|
||||
{
|
||||
m_DataNodeManager.SetData(path, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置数据结点的数据。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要设置的数据类型。</typeparam>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="data">要设置的数据。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
public void SetData<T>(string path, T data, IDataNode node) where T : Variable
|
||||
{
|
||||
m_DataNodeManager.SetData(path, data, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置数据结点的数据。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="data">要设置的数据。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
public void SetData(string path, Variable data, IDataNode node)
|
||||
{
|
||||
m_DataNodeManager.SetData(path, data, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据结点。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <returns>指定位置的数据结点,如果没有找到,则返回空。</returns>
|
||||
public IDataNode GetNode(string path)
|
||||
{
|
||||
return m_DataNodeManager.GetNode(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据结点。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
/// <returns>指定位置的数据结点,如果没有找到,则返回空。</returns>
|
||||
public IDataNode GetNode(string path, IDataNode node)
|
||||
{
|
||||
return m_DataNodeManager.GetNode(path, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或增加数据结点。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <returns>指定位置的数据结点,如果没有找到,则增加相应的数据结点。</returns>
|
||||
public IDataNode GetOrAddNode(string path)
|
||||
{
|
||||
return m_DataNodeManager.GetOrAddNode(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或增加数据结点。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
/// <returns>指定位置的数据结点,如果没有找到,则增加相应的数据结点。</returns>
|
||||
public IDataNode GetOrAddNode(string path, IDataNode node)
|
||||
{
|
||||
return m_DataNodeManager.GetOrAddNode(path, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除数据结点。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
public void RemoveNode(string path)
|
||||
{
|
||||
m_DataNodeManager.RemoveNode(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除数据结点。
|
||||
/// </summary>
|
||||
/// <param name="path">相对于 node 的查找路径。</param>
|
||||
/// <param name="node">查找起始结点。</param>
|
||||
public void RemoveNode(string path, IDataNode node)
|
||||
{
|
||||
m_DataNodeManager.RemoveNode(path, node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除所有数据结点。
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
m_DataNodeManager.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67038fd9feefc894aa31ae3869a45b72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c37122151fcac7a4d82295f02039a322
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.DataTable;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据表行基类。
|
||||
/// </summary>
|
||||
public abstract class DataRowBase : IDataRow
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取数据表行的编号。
|
||||
/// </summary>
|
||||
public abstract int Id
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析数据表行。
|
||||
/// </summary>
|
||||
/// <param name="dataRowString">要解析的数据表行字符串。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析数据表行成功。</returns>
|
||||
public virtual bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
Log.Warning("Not implemented ParseDataRow(string dataRowString, object userData).");
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析数据表行。
|
||||
/// </summary>
|
||||
/// <param name="dataRowBytes">要解析的数据表行二进制流。</param>
|
||||
/// <param name="startIndex">数据表行二进制流的起始位置。</param>
|
||||
/// <param name="length">数据表行二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析数据表行成功。</returns>
|
||||
public virtual bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
Log.Warning("Not implemented ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData).");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2e51f0c2dffb5748b75e474971bbe09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,399 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.DataTable;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据表组件。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("Game Framework/Data Table")]
|
||||
public sealed class DataTableComponent : GameFrameworkComponent
|
||||
{
|
||||
private const int DefaultPriority = 0;
|
||||
|
||||
private IDataTableManager m_DataTableManager = null;
|
||||
private EventComponent m_EventComponent = null;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableLoadDataTableUpdateEvent = false;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_EnableLoadDataTableDependencyAssetEvent = false;
|
||||
|
||||
[SerializeField]
|
||||
private string m_DataTableHelperTypeName = "UnityGameFramework.Runtime.DefaultDataTableHelper";
|
||||
|
||||
[SerializeField]
|
||||
private DataTableHelperBase m_CustomDataTableHelper = null;
|
||||
|
||||
[SerializeField]
|
||||
private int m_CachedBytesSize = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表数量。
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DataTableManager.Count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓冲二进制流的大小。
|
||||
/// </summary>
|
||||
public int CachedBytesSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DataTableManager.CachedBytesSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏框架组件初始化。
|
||||
/// </summary>
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
m_DataTableManager = GameFrameworkEntry.GetModule<IDataTableManager>();
|
||||
if (m_DataTableManager == null)
|
||||
{
|
||||
Log.Fatal("Data table manager is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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_DataTableManager.SetResourceManager(baseComponent.EditorResourceHelper);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DataTableManager.SetResourceManager(GameFrameworkEntry.GetModule<IResourceManager>());
|
||||
}
|
||||
|
||||
DataTableHelperBase dataTableHelper = Helper.CreateHelper(m_DataTableHelperTypeName, m_CustomDataTableHelper);
|
||||
if (dataTableHelper == null)
|
||||
{
|
||||
Log.Error("Can not create data table helper.");
|
||||
return;
|
||||
}
|
||||
|
||||
dataTableHelper.name = "Data Table Helper";
|
||||
Transform transform = dataTableHelper.transform;
|
||||
transform.SetParent(this.transform);
|
||||
transform.localScale = Vector3.one;
|
||||
|
||||
m_DataTableManager.SetDataProviderHelper(dataTableHelper);
|
||||
m_DataTableManager.SetDataTableHelper(dataTableHelper);
|
||||
if (m_CachedBytesSize > 0)
|
||||
{
|
||||
EnsureCachedBytesSize(m_CachedBytesSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确保二进制流缓存分配足够大小的内存并缓存。
|
||||
/// </summary>
|
||||
/// <param name="ensureSize">要确保二进制流缓存分配内存的大小。</param>
|
||||
public void EnsureCachedBytesSize(int ensureSize)
|
||||
{
|
||||
m_DataTableManager.EnsureCachedBytesSize(ensureSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放缓存的二进制流。
|
||||
/// </summary>
|
||||
public void FreeCachedBytes()
|
||||
{
|
||||
m_DataTableManager.FreeCachedBytes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <returns>是否存在数据表。</returns>
|
||||
public bool HasDataTable<T>() where T : IDataRow
|
||||
{
|
||||
return m_DataTableManager.HasDataTable<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <returns>是否存在数据表。</returns>
|
||||
public bool HasDataTable(Type dataRowType)
|
||||
{
|
||||
return m_DataTableManager.HasDataTable(dataRowType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>是否存在数据表。</returns>
|
||||
public bool HasDataTable<T>(string name) where T : IDataRow
|
||||
{
|
||||
return m_DataTableManager.HasDataTable<T>(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>是否存在数据表。</returns>
|
||||
public bool HasDataTable(Type dataRowType, string name)
|
||||
{
|
||||
return m_DataTableManager.HasDataTable(dataRowType, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <returns>要获取的数据表。</returns>
|
||||
public IDataTable<T> GetDataTable<T>() where T : IDataRow
|
||||
{
|
||||
return m_DataTableManager.GetDataTable<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <returns>要获取的数据表。</returns>
|
||||
public DataTableBase GetDataTable(Type dataRowType)
|
||||
{
|
||||
return m_DataTableManager.GetDataTable(dataRowType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>要获取的数据表。</returns>
|
||||
public IDataTable<T> GetDataTable<T>(string name) where T : IDataRow
|
||||
{
|
||||
return m_DataTableManager.GetDataTable<T>(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>要获取的数据表。</returns>
|
||||
public DataTableBase GetDataTable(Type dataRowType, string name)
|
||||
{
|
||||
return m_DataTableManager.GetDataTable(dataRowType, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有数据表。
|
||||
/// </summary>
|
||||
public DataTableBase[] GetAllDataTables()
|
||||
{
|
||||
return m_DataTableManager.GetAllDataTables();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有数据表。
|
||||
/// </summary>
|
||||
/// <param name="results">所有数据表。</param>
|
||||
public void GetAllDataTables(List<DataTableBase> results)
|
||||
{
|
||||
m_DataTableManager.GetAllDataTables(results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <returns>要创建的数据表。</returns>
|
||||
public IDataTable<T> CreateDataTable<T>() where T : class, IDataRow, new()
|
||||
{
|
||||
return CreateDataTable<T>(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <returns>要创建的数据表。</returns>
|
||||
public DataTableBase CreateDataTable(Type dataRowType)
|
||||
{
|
||||
return CreateDataTable(dataRowType, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>要创建的数据表。</returns>
|
||||
public IDataTable<T> CreateDataTable<T>(string name) where T : class, IDataRow, new()
|
||||
{
|
||||
IDataTable<T> dataTable = m_DataTableManager.CreateDataTable<T>(name);
|
||||
DataTableBase dataTableBase = (DataTableBase)dataTable;
|
||||
dataTableBase.ReadDataSuccess += OnReadDataSuccess;
|
||||
dataTableBase.ReadDataFailure += OnReadDataFailure;
|
||||
|
||||
if (m_EnableLoadDataTableUpdateEvent)
|
||||
{
|
||||
dataTableBase.ReadDataUpdate += OnReadDataUpdate;
|
||||
}
|
||||
|
||||
if (m_EnableLoadDataTableDependencyAssetEvent)
|
||||
{
|
||||
dataTableBase.ReadDataDependencyAsset += OnReadDataDependencyAsset;
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>要创建的数据表。</returns>
|
||||
public DataTableBase CreateDataTable(Type dataRowType, string name)
|
||||
{
|
||||
DataTableBase dataTable = m_DataTableManager.CreateDataTable(dataRowType, name);
|
||||
dataTable.ReadDataSuccess += OnReadDataSuccess;
|
||||
dataTable.ReadDataFailure += OnReadDataFailure;
|
||||
|
||||
if (m_EnableLoadDataTableUpdateEvent)
|
||||
{
|
||||
dataTable.ReadDataUpdate += OnReadDataUpdate;
|
||||
}
|
||||
|
||||
if (m_EnableLoadDataTableDependencyAssetEvent)
|
||||
{
|
||||
dataTable.ReadDataDependencyAsset += OnReadDataDependencyAsset;
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <returns>是否销毁数据表成功。</returns>
|
||||
public bool DestroyDataTable<T>() where T : IDataRow, new()
|
||||
{
|
||||
return m_DataTableManager.DestroyDataTable<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <returns>是否销毁数据表成功。</returns>
|
||||
public bool DestroyDataTable(Type dataRowType)
|
||||
{
|
||||
return m_DataTableManager.DestroyDataTable(dataRowType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>是否销毁数据表成功。</returns>
|
||||
public bool DestroyDataTable<T>(string name) where T : IDataRow
|
||||
{
|
||||
return m_DataTableManager.DestroyDataTable<T>(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataRowType">数据表行的类型。</param>
|
||||
/// <param name="name">数据表名称。</param>
|
||||
/// <returns>是否销毁数据表成功。</returns>
|
||||
public bool DestroyDataTable(Type dataRowType, string name)
|
||||
{
|
||||
return m_DataTableManager.DestroyDataTable(dataRowType, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁数据表。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据表行的类型。</typeparam>
|
||||
/// <param name="dataTable">要销毁的数据表。</param>
|
||||
/// <returns>是否销毁数据表成功。</returns>
|
||||
public bool DestroyDataTable<T>(IDataTable<T> dataTable) where T : IDataRow
|
||||
{
|
||||
return m_DataTableManager.DestroyDataTable(dataTable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">要销毁的数据表。</param>
|
||||
/// <returns>是否销毁数据表成功。</returns>
|
||||
public bool DestroyDataTable(DataTableBase dataTable)
|
||||
{
|
||||
return m_DataTableManager.DestroyDataTable(dataTable);
|
||||
}
|
||||
|
||||
private void OnReadDataSuccess(object sender, ReadDataSuccessEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, LoadDataTableSuccessEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnReadDataFailure(object sender, ReadDataFailureEventArgs e)
|
||||
{
|
||||
Log.Warning("Load data table failure, asset name '{0}', error message '{1}'.", e.DataAssetName, e.ErrorMessage);
|
||||
m_EventComponent.Fire(this, LoadDataTableFailureEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnReadDataUpdate(object sender, ReadDataUpdateEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, LoadDataTableUpdateEventArgs.Create(e));
|
||||
}
|
||||
|
||||
private void OnReadDataDependencyAsset(object sender, ReadDataDependencyAssetEventArgs e)
|
||||
{
|
||||
m_EventComponent.Fire(this, LoadDataTableDependencyAssetEventArgs.Create(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54066418ab853614483ea44b531049f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.DataTable;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据表辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class DataTableHelperBase : MonoBehaviour, IDataProviderHelper<DataTableBase>, IDataTableHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableAssetName">数据表资源名称。</param>
|
||||
/// <param name="dataTableAsset">数据表资源。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取数据表成功。</returns>
|
||||
public abstract bool ReadData(DataTableBase dataTable, string dataTableAssetName, object dataTableAsset, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableAssetName">数据表资源名称。</param>
|
||||
/// <param name="dataTableBytes">数据表二进制流。</param>
|
||||
/// <param name="startIndex">数据表二进制流的起始位置。</param>
|
||||
/// <param name="length">数据表二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取数据表成功。</returns>
|
||||
public abstract bool ReadData(DataTableBase dataTable, string dataTableAssetName, byte[] dataTableBytes, int startIndex, int length, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 解析数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableString">要解析的数据表字符串。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析数据表成功。</returns>
|
||||
public abstract bool ParseData(DataTableBase dataTable, string dataTableString, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 解析数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableBytes">要解析的数据表二进制流。</param>
|
||||
/// <param name="startIndex">数据表二进制流的起始位置。</param>
|
||||
/// <param name="length">数据表二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析数据表成功。</returns>
|
||||
public abstract bool ParseData(DataTableBase dataTable, byte[] dataTableBytes, int startIndex, int length, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 释放数据表资源。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableAsset">要释放的数据表资源。</param>
|
||||
public abstract void ReleaseDataAsset(DataTableBase dataTable, object dataTableAsset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c48521d647fac4408f41cca9820ec55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,171 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.DataTable;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认数据表辅助器。
|
||||
/// </summary>
|
||||
public class DefaultDataTableHelper : DataTableHelperBase
|
||||
{
|
||||
private static readonly string BytesAssetExtension = ".bytes";
|
||||
|
||||
private ResourceComponent m_ResourceComponent = null;
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableAssetName">数据表资源名称。</param>
|
||||
/// <param name="dataTableAsset">数据表资源。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取数据表成功。</returns>
|
||||
public override bool ReadData(DataTableBase dataTable, string dataTableAssetName, object dataTableAsset, object userData)
|
||||
{
|
||||
TextAsset dataTableTextAsset = dataTableAsset as TextAsset;
|
||||
if (dataTableTextAsset != null)
|
||||
{
|
||||
if (dataTableAssetName.EndsWith(BytesAssetExtension, StringComparison.Ordinal))
|
||||
{
|
||||
return dataTable.ParseData(dataTableTextAsset.bytes, userData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return dataTable.ParseData(dataTableTextAsset.text, userData);
|
||||
}
|
||||
}
|
||||
|
||||
Log.Warning("Data table asset '{0}' is invalid.", dataTableAssetName);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableAssetName">数据表资源名称。</param>
|
||||
/// <param name="dataTableBytes">数据表二进制流。</param>
|
||||
/// <param name="startIndex">数据表二进制流的起始位置。</param>
|
||||
/// <param name="length">数据表二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否读取数据表成功。</returns>
|
||||
public override bool ReadData(DataTableBase dataTable, string dataTableAssetName, byte[] dataTableBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
if (dataTableAssetName.EndsWith(BytesAssetExtension, StringComparison.Ordinal))
|
||||
{
|
||||
return dataTable.ParseData(dataTableBytes, startIndex, length, userData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return dataTable.ParseData(Utility.Converter.GetString(dataTableBytes, startIndex, length), userData);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableString">要解析的数据表字符串。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析数据表成功。</returns>
|
||||
public override bool ParseData(DataTableBase dataTable, string dataTableString, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
int position = 0;
|
||||
string dataRowString = null;
|
||||
while ((dataRowString = dataTableString.ReadLine(ref position)) != null)
|
||||
{
|
||||
if (dataRowString[0] == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!dataTable.AddDataRow(dataRowString, userData))
|
||||
{
|
||||
Log.Warning("Can not parse data row string '{0}'.", dataRowString);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Can not parse data table string with exception '{0}'.", exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析数据表。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableBytes">要解析的数据表二进制流。</param>
|
||||
/// <param name="startIndex">数据表二进制流的起始位置。</param>
|
||||
/// <param name="length">数据表二进制流的长度。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
/// <returns>是否解析数据表成功。</returns>
|
||||
public override bool ParseData(DataTableBase dataTable, byte[] dataTableBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataTableBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
|
||||
{
|
||||
int dataRowBytesLength = binaryReader.Read7BitEncodedInt32();
|
||||
if (!dataTable.AddDataRow(dataTableBytes, (int)binaryReader.BaseStream.Position, dataRowBytesLength, userData))
|
||||
{
|
||||
Log.Warning("Can not parse data row bytes.");
|
||||
return false;
|
||||
}
|
||||
|
||||
binaryReader.BaseStream.Position += dataRowBytesLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Can not parse dictionary bytes with exception '{0}'.", exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放数据表资源。
|
||||
/// </summary>
|
||||
/// <param name="dataTable">数据表。</param>
|
||||
/// <param name="dataTableAsset">要释放的数据表资源。</param>
|
||||
public override void ReleaseDataAsset(DataTableBase dataTable, object dataTableAsset)
|
||||
{
|
||||
m_ResourceComponent.UnloadAsset(dataTableAsset);
|
||||
}
|
||||
|
||||
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: f6a52ac548bf3654a93c12610240a67d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// 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 LoadDataTableDependencyAssetEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载数据表时加载依赖资源事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadDataTableDependencyAssetEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载数据表时加载依赖资源事件的新实例。
|
||||
/// </summary>
|
||||
public LoadDataTableDependencyAssetEventArgs()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载数据表时加载依赖资源事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表资源名称。
|
||||
/// </summary>
|
||||
public string DataTableAssetName
|
||||
{
|
||||
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 LoadDataTableDependencyAssetEventArgs Create(ReadDataDependencyAssetEventArgs e)
|
||||
{
|
||||
LoadDataTableDependencyAssetEventArgs loadDataTableDependencyAssetEventArgs = ReferencePool.Acquire<LoadDataTableDependencyAssetEventArgs>();
|
||||
loadDataTableDependencyAssetEventArgs.DataTableAssetName = e.DataAssetName;
|
||||
loadDataTableDependencyAssetEventArgs.DependencyAssetName = e.DependencyAssetName;
|
||||
loadDataTableDependencyAssetEventArgs.LoadedCount = e.LoadedCount;
|
||||
loadDataTableDependencyAssetEventArgs.TotalCount = e.TotalCount;
|
||||
loadDataTableDependencyAssetEventArgs.UserData = e.UserData;
|
||||
return loadDataTableDependencyAssetEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载数据表时加载依赖资源事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
DependencyAssetName = null;
|
||||
LoadedCount = 0;
|
||||
TotalCount = 0;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d55700c511451364c85eca18f23c5e9e
|
||||
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 LoadDataTableFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载数据表失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadDataTableFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载数据表失败事件的新实例。
|
||||
/// </summary>
|
||||
public LoadDataTableFailureEventArgs()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载数据表失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表资源名称。
|
||||
/// </summary>
|
||||
public string DataTableAssetName
|
||||
{
|
||||
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 LoadDataTableFailureEventArgs Create(ReadDataFailureEventArgs e)
|
||||
{
|
||||
LoadDataTableFailureEventArgs loadDataTableFailureEventArgs = ReferencePool.Acquire<LoadDataTableFailureEventArgs>();
|
||||
loadDataTableFailureEventArgs.DataTableAssetName = e.DataAssetName;
|
||||
loadDataTableFailureEventArgs.ErrorMessage = e.ErrorMessage;
|
||||
loadDataTableFailureEventArgs.UserData = e.UserData;
|
||||
return loadDataTableFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载数据表失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
ErrorMessage = null;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7196ee8c6ea2e0c4ebd4825fe6c9dcd1
|
||||
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 LoadDataTableSuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载数据表成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadDataTableSuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载数据表成功事件的新实例。
|
||||
/// </summary>
|
||||
public LoadDataTableSuccessEventArgs()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载数据表成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表资源名称。
|
||||
/// </summary>
|
||||
public string DataTableAssetName
|
||||
{
|
||||
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 LoadDataTableSuccessEventArgs Create(ReadDataSuccessEventArgs e)
|
||||
{
|
||||
LoadDataTableSuccessEventArgs loadDataTableSuccessEventArgs = ReferencePool.Acquire<LoadDataTableSuccessEventArgs>();
|
||||
loadDataTableSuccessEventArgs.DataTableAssetName = e.DataAssetName;
|
||||
loadDataTableSuccessEventArgs.Duration = e.Duration;
|
||||
loadDataTableSuccessEventArgs.UserData = e.UserData;
|
||||
return loadDataTableSuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载数据表成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
Duration = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed41d1abe08b7754481956fece8dfba4
|
||||
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 LoadDataTableUpdateEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载数据表更新事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(LoadDataTableUpdateEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化加载数据表更新事件的新实例。
|
||||
/// </summary>
|
||||
public LoadDataTableUpdateEventArgs()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载数据表更新事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表资源名称。
|
||||
/// </summary>
|
||||
public string DataTableAssetName
|
||||
{
|
||||
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 LoadDataTableUpdateEventArgs Create(ReadDataUpdateEventArgs e)
|
||||
{
|
||||
LoadDataTableUpdateEventArgs loadDataTableUpdateEventArgs = ReferencePool.Acquire<LoadDataTableUpdateEventArgs>();
|
||||
loadDataTableUpdateEventArgs.DataTableAssetName = e.DataAssetName;
|
||||
loadDataTableUpdateEventArgs.Progress = e.Progress;
|
||||
loadDataTableUpdateEventArgs.UserData = e.UserData;
|
||||
return loadDataTableUpdateEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载数据表更新事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
DataTableAssetName = null;
|
||||
Progress = 0f;
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35eba4a8a9ee9954392a0e99aa8111d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eadd5c8c1a8797c45b1c8a9635f8cf52
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
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
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 调试器激活窗口类型。
|
||||
/// </summary>
|
||||
public enum DebuggerActiveWindowType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 总是打开。
|
||||
/// </summary>
|
||||
AlwaysOpen = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 仅在开发模式时打开。
|
||||
/// </summary>
|
||||
OnlyOpenWhenDevelopment,
|
||||
|
||||
/// <summary>
|
||||
/// 仅在编辑器中打开。
|
||||
/// </summary>
|
||||
OnlyOpenInEditor,
|
||||
|
||||
/// <summary>
|
||||
/// 总是关闭。
|
||||
/// </summary>
|
||||
AlwaysClose,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1baccfe5abb590428eb0322088bf4ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,509 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Debugger;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
[Serializable]
|
||||
private sealed class ConsoleWindow : IDebuggerWindow
|
||||
{
|
||||
private readonly Queue<LogNode> m_LogNodes = new Queue<LogNode>();
|
||||
|
||||
private SettingComponent m_SettingComponent = null;
|
||||
private Vector2 m_LogScrollPosition = Vector2.zero;
|
||||
private Vector2 m_StackScrollPosition = Vector2.zero;
|
||||
private int m_InfoCount = 0;
|
||||
private int m_WarningCount = 0;
|
||||
private int m_ErrorCount = 0;
|
||||
private int m_FatalCount = 0;
|
||||
private LogNode m_SelectedNode = null;
|
||||
private bool m_LastLockScroll = true;
|
||||
private bool m_LastInfoFilter = true;
|
||||
private bool m_LastWarningFilter = true;
|
||||
private bool m_LastErrorFilter = true;
|
||||
private bool m_LastFatalFilter = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_LockScroll = true;
|
||||
|
||||
[SerializeField]
|
||||
private int m_MaxLine = 100;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_InfoFilter = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_WarningFilter = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_ErrorFilter = true;
|
||||
|
||||
[SerializeField]
|
||||
private bool m_FatalFilter = true;
|
||||
|
||||
[SerializeField]
|
||||
private Color32 m_InfoColor = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
private Color32 m_WarningColor = Color.yellow;
|
||||
|
||||
[SerializeField]
|
||||
private Color32 m_ErrorColor = Color.red;
|
||||
|
||||
[SerializeField]
|
||||
private Color32 m_FatalColor = new Color(0.7f, 0.2f, 0.2f);
|
||||
|
||||
public bool LockScroll
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LockScroll;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_LockScroll = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int MaxLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MaxLine;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MaxLine = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool InfoFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InfoFilter;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_InfoFilter = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool WarningFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_WarningFilter;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_WarningFilter = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ErrorFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ErrorFilter;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ErrorFilter = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FatalFilter
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FatalFilter;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_FatalFilter = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int InfoCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InfoCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int WarningCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_WarningCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int ErrorCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ErrorCount;
|
||||
}
|
||||
}
|
||||
|
||||
public int FatalCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FatalCount;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 InfoColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_InfoColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_InfoColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 WarningColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_WarningColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_WarningColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 ErrorColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ErrorColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_ErrorColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 FatalColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FatalColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_FatalColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(params object[] args)
|
||||
{
|
||||
m_SettingComponent = GameEntry.GetComponent<SettingComponent>();
|
||||
if (m_SettingComponent == null)
|
||||
{
|
||||
Log.Fatal("Setting component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
Application.logMessageReceived += OnLogMessageReceived;
|
||||
m_LockScroll = m_LastLockScroll = m_SettingComponent.GetBool("Debugger.Console.LockScroll", true);
|
||||
m_InfoFilter = m_LastInfoFilter = m_SettingComponent.GetBool("Debugger.Console.InfoFilter", true);
|
||||
m_WarningFilter = m_LastWarningFilter = m_SettingComponent.GetBool("Debugger.Console.WarningFilter", true);
|
||||
m_ErrorFilter = m_LastErrorFilter = m_SettingComponent.GetBool("Debugger.Console.ErrorFilter", true);
|
||||
m_FatalFilter = m_LastFatalFilter = m_SettingComponent.GetBool("Debugger.Console.FatalFilter", true);
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
Application.logMessageReceived -= OnLogMessageReceived;
|
||||
Clear();
|
||||
}
|
||||
|
||||
public void OnEnter()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnLeave()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
if (m_LastLockScroll != m_LockScroll)
|
||||
{
|
||||
m_LastLockScroll = m_LockScroll;
|
||||
m_SettingComponent.SetBool("Debugger.Console.LockScroll", m_LockScroll);
|
||||
}
|
||||
|
||||
if (m_LastInfoFilter != m_InfoFilter)
|
||||
{
|
||||
m_LastInfoFilter = m_InfoFilter;
|
||||
m_SettingComponent.SetBool("Debugger.Console.InfoFilter", m_InfoFilter);
|
||||
}
|
||||
|
||||
if (m_LastWarningFilter != m_WarningFilter)
|
||||
{
|
||||
m_LastWarningFilter = m_WarningFilter;
|
||||
m_SettingComponent.SetBool("Debugger.Console.WarningFilter", m_WarningFilter);
|
||||
}
|
||||
|
||||
if (m_LastErrorFilter != m_ErrorFilter)
|
||||
{
|
||||
m_LastErrorFilter = m_ErrorFilter;
|
||||
m_SettingComponent.SetBool("Debugger.Console.ErrorFilter", m_ErrorFilter);
|
||||
}
|
||||
|
||||
if (m_LastFatalFilter != m_FatalFilter)
|
||||
{
|
||||
m_LastFatalFilter = m_FatalFilter;
|
||||
m_SettingComponent.SetBool("Debugger.Console.FatalFilter", m_FatalFilter);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDraw()
|
||||
{
|
||||
RefreshCount();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Clear All", GUILayout.Width(100f)))
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
m_LockScroll = GUILayout.Toggle(m_LockScroll, "Lock Scroll", GUILayout.Width(90f));
|
||||
GUILayout.FlexibleSpace();
|
||||
m_InfoFilter = GUILayout.Toggle(m_InfoFilter, Utility.Text.Format("Info ({0})", m_InfoCount), GUILayout.Width(90f));
|
||||
m_WarningFilter = GUILayout.Toggle(m_WarningFilter, Utility.Text.Format("Warning ({0})", m_WarningCount), GUILayout.Width(90f));
|
||||
m_ErrorFilter = GUILayout.Toggle(m_ErrorFilter, Utility.Text.Format("Error ({0})", m_ErrorCount), GUILayout.Width(90f));
|
||||
m_FatalFilter = GUILayout.Toggle(m_FatalFilter, Utility.Text.Format("Fatal ({0})", m_FatalCount), GUILayout.Width(90f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
if (m_LockScroll)
|
||||
{
|
||||
m_LogScrollPosition.y = float.MaxValue;
|
||||
}
|
||||
|
||||
m_LogScrollPosition = GUILayout.BeginScrollView(m_LogScrollPosition);
|
||||
{
|
||||
bool selected = false;
|
||||
foreach (LogNode logNode in m_LogNodes)
|
||||
{
|
||||
switch (logNode.LogType)
|
||||
{
|
||||
case LogType.Log:
|
||||
if (!m_InfoFilter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case LogType.Warning:
|
||||
if (!m_WarningFilter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case LogType.Error:
|
||||
if (!m_ErrorFilter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case LogType.Exception:
|
||||
if (!m_FatalFilter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (GUILayout.Toggle(m_SelectedNode == logNode, GetLogString(logNode)))
|
||||
{
|
||||
selected = true;
|
||||
if (m_SelectedNode != logNode)
|
||||
{
|
||||
m_SelectedNode = logNode;
|
||||
m_StackScrollPosition = Vector2.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!selected)
|
||||
{
|
||||
m_SelectedNode = null;
|
||||
}
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
m_StackScrollPosition = GUILayout.BeginScrollView(m_StackScrollPosition, GUILayout.Height(100f));
|
||||
{
|
||||
if (m_SelectedNode != null)
|
||||
{
|
||||
Color32 color = GetLogStringColor(m_SelectedNode.LogType);
|
||||
if (GUILayout.Button(Utility.Text.Format("<color=#{0:x2}{1:x2}{2:x2}{3:x2}><b>{4}</b></color>{6}{6}{5}", color.r, color.g, color.b, color.a, m_SelectedNode.LogMessage, m_SelectedNode.StackTrack, Environment.NewLine), "label"))
|
||||
{
|
||||
CopyToClipboard(Utility.Text.Format("{0}{2}{2}{1}", m_SelectedNode.LogMessage, m_SelectedNode.StackTrack, Environment.NewLine));
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void Clear()
|
||||
{
|
||||
m_LogNodes.Clear();
|
||||
}
|
||||
|
||||
public void RefreshCount()
|
||||
{
|
||||
m_InfoCount = 0;
|
||||
m_WarningCount = 0;
|
||||
m_ErrorCount = 0;
|
||||
m_FatalCount = 0;
|
||||
foreach (LogNode logNode in m_LogNodes)
|
||||
{
|
||||
switch (logNode.LogType)
|
||||
{
|
||||
case LogType.Log:
|
||||
m_InfoCount++;
|
||||
break;
|
||||
|
||||
case LogType.Warning:
|
||||
m_WarningCount++;
|
||||
break;
|
||||
|
||||
case LogType.Error:
|
||||
m_ErrorCount++;
|
||||
break;
|
||||
|
||||
case LogType.Exception:
|
||||
m_FatalCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetRecentLogs(List<LogNode> results)
|
||||
{
|
||||
if (results == null)
|
||||
{
|
||||
Log.Error("Results is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
results.Clear();
|
||||
foreach (LogNode logNode in m_LogNodes)
|
||||
{
|
||||
results.Add(logNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetRecentLogs(List<LogNode> results, int count)
|
||||
{
|
||||
if (results == null)
|
||||
{
|
||||
Log.Error("Results is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
Log.Error("Count is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
int position = m_LogNodes.Count - count;
|
||||
if (position < 0)
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
results.Clear();
|
||||
foreach (LogNode logNode in m_LogNodes)
|
||||
{
|
||||
if (index++ < position)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
results.Add(logNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLogMessageReceived(string logMessage, string stackTrace, LogType logType)
|
||||
{
|
||||
if (logType == LogType.Assert)
|
||||
{
|
||||
logType = LogType.Error;
|
||||
}
|
||||
|
||||
m_LogNodes.Enqueue(LogNode.Create(logType, logMessage, stackTrace));
|
||||
while (m_LogNodes.Count > m_MaxLine)
|
||||
{
|
||||
ReferencePool.Release(m_LogNodes.Dequeue());
|
||||
}
|
||||
}
|
||||
|
||||
private string GetLogString(LogNode logNode)
|
||||
{
|
||||
Color32 color = GetLogStringColor(logNode.LogType);
|
||||
return Utility.Text.Format("<color=#{0:x2}{1:x2}{2:x2}{3:x2}>[{4:HH:mm:ss.fff}][{5}] {6}</color>", color.r, color.g, color.b, color.a, logNode.LogTime.ToLocalTime(), logNode.LogFrameCount, logNode.LogMessage);
|
||||
}
|
||||
|
||||
internal Color32 GetLogStringColor(LogType logType)
|
||||
{
|
||||
Color32 color = Color.white;
|
||||
switch (logType)
|
||||
{
|
||||
case LogType.Log:
|
||||
color = m_InfoColor;
|
||||
break;
|
||||
|
||||
case LogType.Warning:
|
||||
color = m_WarningColor;
|
||||
break;
|
||||
|
||||
case LogType.Error:
|
||||
color = m_ErrorColor;
|
||||
break;
|
||||
|
||||
case LogType.Exception:
|
||||
color = m_FatalColor;
|
||||
break;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a47e2730f999784eb1bbeefab72ef11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
using UnityEngine.Rendering;
|
||||
#endif
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class EnvironmentInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private BaseComponent m_BaseComponent = null;
|
||||
private ResourceComponent m_ResourceComponent = null;
|
||||
|
||||
public override void Initialize(params object[] args)
|
||||
{
|
||||
m_BaseComponent = GameEntry.GetComponent<BaseComponent>();
|
||||
if (m_BaseComponent == null)
|
||||
{
|
||||
Log.Fatal("Base component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_ResourceComponent = GameEntry.GetComponent<ResourceComponent>();
|
||||
if (m_ResourceComponent == null)
|
||||
{
|
||||
Log.Fatal("Resource component is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Environment Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Product Name", Application.productName);
|
||||
DrawItem("Company Name", Application.companyName);
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Game Identifier", Application.identifier);
|
||||
#else
|
||||
DrawItem("Game Identifier", Application.bundleIdentifier);
|
||||
#endif
|
||||
DrawItem("Game Framework Version", Version.GameFrameworkVersion);
|
||||
DrawItem("Game Version", Utility.Text.Format("{0} ({1})", Version.GameVersion, Version.InternalGameVersion));
|
||||
DrawItem("Resource Version", m_BaseComponent.EditorResourceMode ? "Unavailable in editor resource mode" : (string.IsNullOrEmpty(m_ResourceComponent.ApplicableGameVersion) ? "Unknown" : Utility.Text.Format("{0} ({1})", m_ResourceComponent.ApplicableGameVersion, m_ResourceComponent.InternalResourceVersion)));
|
||||
DrawItem("Application Version", Application.version);
|
||||
DrawItem("Unity Version", Application.unityVersion);
|
||||
DrawItem("Platform", Application.platform.ToString());
|
||||
DrawItem("System Language", Application.systemLanguage.ToString());
|
||||
DrawItem("Cloud Project Id", Application.cloudProjectId);
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Build Guid", Application.buildGUID);
|
||||
#endif
|
||||
DrawItem("Target Frame Rate", Application.targetFrameRate.ToString());
|
||||
DrawItem("Internet Reachability", Application.internetReachability.ToString());
|
||||
DrawItem("Background Loading Priority", Application.backgroundLoadingPriority.ToString());
|
||||
DrawItem("Is Playing", Application.isPlaying.ToString());
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Splash Screen Is Finished", SplashScreen.isFinished.ToString());
|
||||
#else
|
||||
DrawItem("Is Showing Splash Screen", Application.isShowingSplashScreen.ToString());
|
||||
#endif
|
||||
DrawItem("Run In Background", Application.runInBackground.ToString());
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Install Name", Application.installerName);
|
||||
#endif
|
||||
DrawItem("Install Mode", Application.installMode.ToString());
|
||||
DrawItem("Sandbox Type", Application.sandboxType.ToString());
|
||||
DrawItem("Is Mobile Platform", Application.isMobilePlatform.ToString());
|
||||
DrawItem("Is Console Platform", Application.isConsolePlatform.ToString());
|
||||
DrawItem("Is Editor", Application.isEditor.ToString());
|
||||
DrawItem("Is Debug Build", Debug.isDebugBuild.ToString());
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Is Focused", Application.isFocused.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_2_OR_NEWER
|
||||
DrawItem("Is Batch Mode", Application.isBatchMode.ToString());
|
||||
#endif
|
||||
#if UNITY_5_3
|
||||
DrawItem("Stack Trace Log Type", Application.stackTraceLogType.ToString());
|
||||
#endif
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c52c8dc8849c5fb429c50b45975a599b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class FpsCounter
|
||||
{
|
||||
private float m_UpdateInterval;
|
||||
private float m_CurrentFps;
|
||||
private int m_Frames;
|
||||
private float m_Accumulator;
|
||||
private float m_TimeLeft;
|
||||
|
||||
public FpsCounter(float updateInterval)
|
||||
{
|
||||
if (updateInterval <= 0f)
|
||||
{
|
||||
Log.Error("Update interval is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_UpdateInterval = updateInterval;
|
||||
Reset();
|
||||
}
|
||||
|
||||
public float UpdateInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UpdateInterval;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= 0f)
|
||||
{
|
||||
Log.Error("Update interval is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_UpdateInterval = value;
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
public float CurrentFps
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_CurrentFps;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
m_Frames++;
|
||||
m_Accumulator += realElapseSeconds;
|
||||
m_TimeLeft -= realElapseSeconds;
|
||||
|
||||
if (m_TimeLeft <= 0f)
|
||||
{
|
||||
m_CurrentFps = m_Accumulator > 0f ? m_Frames / m_Accumulator : 0f;
|
||||
m_Frames = 0;
|
||||
m_Accumulator = 0f;
|
||||
m_TimeLeft += m_UpdateInterval;
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
m_CurrentFps = 0f;
|
||||
m_Frames = 0;
|
||||
m_Accumulator = 0f;
|
||||
m_TimeLeft = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f24c805ead515d4286d3c03cd50f750
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class GraphicsInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Graphics Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Device ID", SystemInfo.graphicsDeviceID.ToString());
|
||||
DrawItem("Device Name", SystemInfo.graphicsDeviceName);
|
||||
DrawItem("Device Vendor ID", SystemInfo.graphicsDeviceVendorID.ToString());
|
||||
DrawItem("Device Vendor", SystemInfo.graphicsDeviceVendor);
|
||||
DrawItem("Device Type", SystemInfo.graphicsDeviceType.ToString());
|
||||
DrawItem("Device Version", SystemInfo.graphicsDeviceVersion);
|
||||
DrawItem("Memory Size", Utility.Text.Format("{0} MB", SystemInfo.graphicsMemorySize));
|
||||
DrawItem("Multi Threaded", SystemInfo.graphicsMultiThreaded.ToString());
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
DrawItem("Rendering Threading Mode", SystemInfo.renderingThreadingMode.ToString());
|
||||
#endif
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
DrawItem("HRD Display Support Flags", SystemInfo.hdrDisplaySupportFlags.ToString());
|
||||
#endif
|
||||
DrawItem("Shader Level", GetShaderLevelString(SystemInfo.graphicsShaderLevel));
|
||||
DrawItem("Global Maximum LOD", Shader.globalMaximumLOD.ToString());
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Global Render Pipeline", Shader.globalRenderPipeline);
|
||||
#endif
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
DrawItem("Min OpenGLES Version", Graphics.minOpenGLESVersion.ToString());
|
||||
#endif
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Active Tier", Graphics.activeTier.ToString());
|
||||
#endif
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
DrawItem("Active Color Gamut", Graphics.activeColorGamut.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_2_OR_NEWER
|
||||
DrawItem("Preserve Frame Buffer Alpha", Graphics.preserveFramebufferAlpha.ToString());
|
||||
#endif
|
||||
DrawItem("NPOT Support", SystemInfo.npotSupport.ToString());
|
||||
DrawItem("Max Texture Size", SystemInfo.maxTextureSize.ToString());
|
||||
DrawItem("Supported Render Target Count", SystemInfo.supportedRenderTargetCount.ToString());
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
DrawItem("Supported Random Write Target Count", SystemInfo.supportedRandomWriteTargetCount.ToString());
|
||||
#endif
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
DrawItem("Copy Texture Support", SystemInfo.copyTextureSupport.ToString());
|
||||
#endif
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Uses Reversed ZBuffer", SystemInfo.usesReversedZBuffer.ToString());
|
||||
#endif
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Max Cubemap Size", SystemInfo.maxCubemapSize.ToString());
|
||||
DrawItem("Graphics UV Starts At Top", SystemInfo.graphicsUVStartsAtTop.ToString());
|
||||
#endif
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
DrawItem("Constant Buffer Offset Alignment", SystemInfo.constantBufferOffsetAlignment.ToString());
|
||||
#elif UNITY_2019_1_OR_NEWER
|
||||
DrawItem("Min Constant Buffer Offset Alignment", SystemInfo.minConstantBufferOffsetAlignment.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Has Hidden Surface Removal On GPU", SystemInfo.hasHiddenSurfaceRemovalOnGPU.ToString());
|
||||
DrawItem("Has Dynamic Uniform Array Indexing In Fragment Shaders", SystemInfo.hasDynamicUniformArrayIndexingInFragmentShaders.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_2_OR_NEWER
|
||||
DrawItem("Has Mip Max Level", SystemInfo.hasMipMaxLevel.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
DrawItem("Uses Load Store Actions", SystemInfo.usesLoadStoreActions.ToString());
|
||||
DrawItem("Max Compute Buffer Inputs Compute", SystemInfo.maxComputeBufferInputsCompute.ToString());
|
||||
DrawItem("Max Compute Buffer Inputs Domain", SystemInfo.maxComputeBufferInputsDomain.ToString());
|
||||
DrawItem("Max Compute Buffer Inputs Fragment", SystemInfo.maxComputeBufferInputsFragment.ToString());
|
||||
DrawItem("Max Compute Buffer Inputs Geometry", SystemInfo.maxComputeBufferInputsGeometry.ToString());
|
||||
DrawItem("Max Compute Buffer Inputs Hull", SystemInfo.maxComputeBufferInputsHull.ToString());
|
||||
DrawItem("Max Compute Buffer Inputs Vertex", SystemInfo.maxComputeBufferInputsVertex.ToString());
|
||||
DrawItem("Max Compute Work Group Size", SystemInfo.maxComputeWorkGroupSize.ToString());
|
||||
DrawItem("Max Compute Work Group Size X", SystemInfo.maxComputeWorkGroupSizeX.ToString());
|
||||
DrawItem("Max Compute Work Group Size Y", SystemInfo.maxComputeWorkGroupSizeY.ToString());
|
||||
DrawItem("Max Compute Work Group Size Z", SystemInfo.maxComputeWorkGroupSizeZ.ToString());
|
||||
#endif
|
||||
#if UNITY_5_3 || UNITY_5_4
|
||||
DrawItem("Supports Stencil", SystemInfo.supportsStencil.ToString());
|
||||
DrawItem("Supports Render Textures", SystemInfo.supportsRenderTextures.ToString());
|
||||
#endif
|
||||
DrawItem("Supports Sparse Textures", SystemInfo.supportsSparseTextures.ToString());
|
||||
DrawItem("Supports 3D Textures", SystemInfo.supports3DTextures.ToString());
|
||||
DrawItem("Supports Shadows", SystemInfo.supportsShadows.ToString());
|
||||
DrawItem("Supports Raw Shadow Depth Sampling", SystemInfo.supportsRawShadowDepthSampling.ToString());
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
DrawItem("Supports Render To Cubemap", SystemInfo.supportsRenderToCubemap.ToString());
|
||||
DrawItem("Supports Image Effects", SystemInfo.supportsImageEffects.ToString());
|
||||
#endif
|
||||
DrawItem("Supports Compute Shader", SystemInfo.supportsComputeShaders.ToString());
|
||||
DrawItem("Supports Instancing", SystemInfo.supportsInstancing.ToString());
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
DrawItem("Supports 2D Array Textures", SystemInfo.supports2DArrayTextures.ToString());
|
||||
DrawItem("Supports Motion Vectors", SystemInfo.supportsMotionVectors.ToString());
|
||||
#endif
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Supports Cubemap Array Textures", SystemInfo.supportsCubemapArrayTextures.ToString());
|
||||
#endif
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Supports 3D Render Textures", SystemInfo.supports3DRenderTextures.ToString());
|
||||
#endif
|
||||
#if UNITY_2017_2_OR_NEWER && !UNITY_2017_2_0 || UNITY_2017_1_4
|
||||
DrawItem("Supports Texture Wrap Mirror Once", SystemInfo.supportsTextureWrapMirrorOnce.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
DrawItem("Supports Graphics Fence", SystemInfo.supportsGraphicsFence.ToString());
|
||||
#elif UNITY_2017_3_OR_NEWER
|
||||
DrawItem("Supports GPU Fence", SystemInfo.supportsGPUFence.ToString());
|
||||
#endif
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
DrawItem("Supports Async Compute", SystemInfo.supportsAsyncCompute.ToString());
|
||||
DrawItem("Supports Multi-sampled Textures", SystemInfo.supportsMultisampledTextures.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
DrawItem("Supports Async GPU Readback", SystemInfo.supportsAsyncGPUReadback.ToString());
|
||||
DrawItem("Supports 32bits Index Buffer", SystemInfo.supports32bitsIndexBuffer.ToString());
|
||||
DrawItem("Supports Hardware Quad Topology", SystemInfo.supportsHardwareQuadTopology.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_2_OR_NEWER
|
||||
DrawItem("Supports Mip Streaming", SystemInfo.supportsMipStreaming.ToString());
|
||||
DrawItem("Supports Multi-sample Auto Resolve", SystemInfo.supportsMultisampleAutoResolve.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Supports Separated Render Targets Blend", SystemInfo.supportsSeparatedRenderTargetsBlend.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
DrawItem("Supports Set Constant Buffer", SystemInfo.supportsSetConstantBuffer.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
DrawItem("Supports Geometry Shaders", SystemInfo.supportsGeometryShaders.ToString());
|
||||
DrawItem("Supports Ray Tracing", SystemInfo.supportsRayTracing.ToString());
|
||||
DrawItem("Supports Tessellation Shaders", SystemInfo.supportsTessellationShaders.ToString());
|
||||
#endif
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
DrawItem("Supports Compressed 3D Textures", SystemInfo.supportsCompressed3DTextures.ToString());
|
||||
DrawItem("Supports Conservative Raster", SystemInfo.supportsConservativeRaster.ToString());
|
||||
DrawItem("Supports GPU Recorder", SystemInfo.supportsGpuRecorder.ToString());
|
||||
#endif
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
DrawItem("Supports Multi-sampled 2D Array Textures", SystemInfo.supportsMultisampled2DArrayTextures.ToString());
|
||||
DrawItem("Supports Multiview", SystemInfo.supportsMultiview.ToString());
|
||||
DrawItem("Supports Render Target Array Index From Vertex Shader", SystemInfo.supportsRenderTargetArrayIndexFromVertexShader.ToString());
|
||||
#endif
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private string GetShaderLevelString(int shaderLevel)
|
||||
{
|
||||
return Utility.Text.Format("Shader Model {0}.{1}", shaderLevel / 10, shaderLevel % 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1342573add002c41b3bb1a8abb8ef3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class InputAccelerationInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Input Acceleration Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Acceleration", Input.acceleration.ToString());
|
||||
DrawItem("Acceleration Event Count", Input.accelerationEventCount.ToString());
|
||||
DrawItem("Acceleration Events", GetAccelerationEventsString(Input.accelerationEvents));
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private string GetAccelerationEventString(AccelerationEvent accelerationEvent)
|
||||
{
|
||||
return Utility.Text.Format("{0}, {1}", accelerationEvent.acceleration, accelerationEvent.deltaTime);
|
||||
}
|
||||
|
||||
private string GetAccelerationEventsString(AccelerationEvent[] accelerationEvents)
|
||||
{
|
||||
string[] accelerationEventStrings = new string[accelerationEvents.Length];
|
||||
for (int i = 0; i < accelerationEvents.Length; i++)
|
||||
{
|
||||
accelerationEventStrings[i] = GetAccelerationEventString(accelerationEvents[i]);
|
||||
}
|
||||
|
||||
return string.Join("; ", accelerationEventStrings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99bd178c0d097a24d9e04fe1522bca60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class InputCompassInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Input Compass Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Enable", GUILayout.Height(30f)))
|
||||
{
|
||||
Input.compass.enabled = true;
|
||||
}
|
||||
if (GUILayout.Button("Disable", GUILayout.Height(30f)))
|
||||
{
|
||||
Input.compass.enabled = false;
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
DrawItem("Enabled", Input.compass.enabled.ToString());
|
||||
if (Input.compass.enabled)
|
||||
{
|
||||
DrawItem("Heading Accuracy", Input.compass.headingAccuracy.ToString());
|
||||
DrawItem("Magnetic Heading", Input.compass.magneticHeading.ToString());
|
||||
DrawItem("Raw Vector", Input.compass.rawVector.ToString());
|
||||
DrawItem("Timestamp", Input.compass.timestamp.ToString());
|
||||
DrawItem("True Heading", Input.compass.trueHeading.ToString());
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8e33bb9948f7f54d988d80a6ae6a24a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class InputGyroscopeInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Input Gyroscope Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Enable", GUILayout.Height(30f)))
|
||||
{
|
||||
Input.gyro.enabled = true;
|
||||
}
|
||||
if (GUILayout.Button("Disable", GUILayout.Height(30f)))
|
||||
{
|
||||
Input.gyro.enabled = false;
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
DrawItem("Enabled", Input.gyro.enabled.ToString());
|
||||
if (Input.gyro.enabled)
|
||||
{
|
||||
DrawItem("Update Interval", Input.gyro.updateInterval.ToString());
|
||||
DrawItem("Attitude", Input.gyro.attitude.eulerAngles.ToString());
|
||||
DrawItem("Gravity", Input.gyro.gravity.ToString());
|
||||
DrawItem("Rotation Rate", Input.gyro.rotationRate.ToString());
|
||||
DrawItem("Rotation Rate Unbiased", Input.gyro.rotationRateUnbiased.ToString());
|
||||
DrawItem("User Acceleration", Input.gyro.userAcceleration.ToString());
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 709450f452a296b44b4aa939cf37f37c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class InputLocationInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Input Location Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Enable", GUILayout.Height(30f)))
|
||||
{
|
||||
Input.location.Start();
|
||||
}
|
||||
if (GUILayout.Button("Disable", GUILayout.Height(30f)))
|
||||
{
|
||||
Input.location.Stop();
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
DrawItem("Is Enabled By User", Input.location.isEnabledByUser.ToString());
|
||||
DrawItem("Status", Input.location.status.ToString());
|
||||
if (Input.location.status == LocationServiceStatus.Running)
|
||||
{
|
||||
DrawItem("Horizontal Accuracy", Input.location.lastData.horizontalAccuracy.ToString());
|
||||
DrawItem("Vertical Accuracy", Input.location.lastData.verticalAccuracy.ToString());
|
||||
DrawItem("Longitude", Input.location.lastData.longitude.ToString());
|
||||
DrawItem("Latitude", Input.location.lastData.latitude.ToString());
|
||||
DrawItem("Altitude", Input.location.lastData.altitude.ToString());
|
||||
DrawItem("Timestamp", Input.location.lastData.timestamp.ToString());
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74c5698b7ee786442b28b64003f564fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class InputSummaryInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Input Summary Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Back Button Leaves App", Input.backButtonLeavesApp.ToString());
|
||||
DrawItem("Device Orientation", Input.deviceOrientation.ToString());
|
||||
DrawItem("Mouse Present", Input.mousePresent.ToString());
|
||||
DrawItem("Mouse Position", Input.mousePosition.ToString());
|
||||
DrawItem("Mouse Scroll Delta", Input.mouseScrollDelta.ToString());
|
||||
DrawItem("Any Key", Input.anyKey.ToString());
|
||||
DrawItem("Any Key Down", Input.anyKeyDown.ToString());
|
||||
DrawItem("Input String", Input.inputString);
|
||||
DrawItem("IME Is Selected", Input.imeIsSelected.ToString());
|
||||
DrawItem("IME Composition Mode", Input.imeCompositionMode.ToString());
|
||||
DrawItem("Compensate Sensors", Input.compensateSensors.ToString());
|
||||
DrawItem("Composition Cursor Position", Input.compositionCursorPos.ToString());
|
||||
DrawItem("Composition String", Input.compositionString);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2756ce9647dc6a49a66c75437edef8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class InputTouchInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Input Touch Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Touch Supported", Input.touchSupported.ToString());
|
||||
DrawItem("Touch Pressure Supported", Input.touchPressureSupported.ToString());
|
||||
DrawItem("Stylus Touch Supported", Input.stylusTouchSupported.ToString());
|
||||
DrawItem("Simulate Mouse With Touches", Input.simulateMouseWithTouches.ToString());
|
||||
DrawItem("Multi Touch Enabled", Input.multiTouchEnabled.ToString());
|
||||
DrawItem("Touch Count", Input.touchCount.ToString());
|
||||
DrawItem("Touches", GetTouchesString(Input.touches));
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private string GetTouchString(Touch touch)
|
||||
{
|
||||
return Utility.Text.Format("{0}, {1}, {2}, {3}, {4}", touch.position, touch.deltaPosition, touch.rawPosition, touch.pressure, touch.phase);
|
||||
}
|
||||
|
||||
private string GetTouchesString(Touch[] touches)
|
||||
{
|
||||
string[] touchStrings = new string[touches.Length];
|
||||
for (int i = 0; i < touches.Length; i++)
|
||||
{
|
||||
touchStrings[i] = GetTouchString(touches[i]);
|
||||
}
|
||||
|
||||
return string.Join("; ", touchStrings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a76aa41d893e994f9630028d5e3001d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,125 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志记录结点。
|
||||
/// </summary>
|
||||
public sealed class LogNode : IReference
|
||||
{
|
||||
private DateTime m_LogTime;
|
||||
private int m_LogFrameCount;
|
||||
private LogType m_LogType;
|
||||
private string m_LogMessage;
|
||||
private string m_StackTrack;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化日志记录结点的新实例。
|
||||
/// </summary>
|
||||
public LogNode()
|
||||
{
|
||||
m_LogTime = default(DateTime);
|
||||
m_LogFrameCount = 0;
|
||||
m_LogType = LogType.Error;
|
||||
m_LogMessage = null;
|
||||
m_StackTrack = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取日志时间。
|
||||
/// </summary>
|
||||
public DateTime LogTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LogTime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取日志帧计数。
|
||||
/// </summary>
|
||||
public int LogFrameCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LogFrameCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取日志类型。
|
||||
/// </summary>
|
||||
public LogType LogType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LogType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取日志内容。
|
||||
/// </summary>
|
||||
public string LogMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_LogMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取日志堆栈信息。
|
||||
/// </summary>
|
||||
public string StackTrack
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_StackTrack;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建日志记录结点。
|
||||
/// </summary>
|
||||
/// <param name="logType">日志类型。</param>
|
||||
/// <param name="logMessage">日志内容。</param>
|
||||
/// <param name="stackTrack">日志堆栈信息。</param>
|
||||
/// <returns>创建的日志记录结点。</returns>
|
||||
public static LogNode Create(LogType logType, string logMessage, string stackTrack)
|
||||
{
|
||||
LogNode logNode = ReferencePool.Acquire<LogNode>();
|
||||
logNode.m_LogTime = DateTime.UtcNow;
|
||||
logNode.m_LogFrameCount = Time.frameCount;
|
||||
logNode.m_LogType = logType;
|
||||
logNode.m_LogMessage = logMessage;
|
||||
logNode.m_StackTrack = stackTrack;
|
||||
return logNode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理日志记录结点。
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
m_LogTime = default(DateTime);
|
||||
m_LogFrameCount = 0;
|
||||
m_LogType = LogType.Error;
|
||||
m_LogMessage = null;
|
||||
m_StackTrack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 168b4dfdd72224e4bbc5fb606eec23dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Network;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class NetworkInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private NetworkComponent m_NetworkComponent = null;
|
||||
|
||||
public override void Initialize(params object[] args)
|
||||
{
|
||||
m_NetworkComponent = GameEntry.GetComponent<NetworkComponent>();
|
||||
if (m_NetworkComponent == null)
|
||||
{
|
||||
Log.Fatal("Network component is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Network Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Network Channel Count", m_NetworkComponent.NetworkChannelCount.ToString());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
INetworkChannel[] networkChannels = m_NetworkComponent.GetAllNetworkChannels();
|
||||
for (int i = 0; i < networkChannels.Length; i++)
|
||||
{
|
||||
DrawNetworkChannel(networkChannels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawNetworkChannel(INetworkChannel networkChannel)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>Network Channel: {0} ({1})</b>", networkChannel.Name, networkChannel.Connected ? "Connected" : "Disconnected"));
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Service Type", networkChannel.ServiceType.ToString());
|
||||
DrawItem("Address Family", networkChannel.AddressFamily.ToString());
|
||||
DrawItem("Local Address", networkChannel.Connected ? networkChannel.Socket.LocalEndPoint.ToString() : "Unavailable");
|
||||
DrawItem("Remote Address", networkChannel.Connected ? networkChannel.Socket.RemoteEndPoint.ToString() : "Unavailable");
|
||||
DrawItem("Send Packet", Utility.Text.Format("{0} / {1}", networkChannel.SendPacketCount, networkChannel.SentPacketCount));
|
||||
DrawItem("Receive Packet", Utility.Text.Format("{0} / {1}", networkChannel.ReceivePacketCount, networkChannel.ReceivedPacketCount));
|
||||
DrawItem("Miss Heart Beat Count", networkChannel.MissHeartBeatCount.ToString());
|
||||
DrawItem("Heart Beat", Utility.Text.Format("{0:F2} / {1:F2}", networkChannel.HeartBeatElapseSeconds, networkChannel.HeartBeatInterval));
|
||||
if (networkChannel.Connected)
|
||||
{
|
||||
if (GUILayout.Button("Disconnect", GUILayout.Height(30f)))
|
||||
{
|
||||
networkChannel.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51d087cb976f4944487629d900a5c057
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+95
@@ -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.ObjectPool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class ObjectPoolInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private ObjectPoolComponent m_ObjectPoolComponent = null;
|
||||
|
||||
public override void Initialize(params object[] args)
|
||||
{
|
||||
m_ObjectPoolComponent = GameEntry.GetComponent<ObjectPoolComponent>();
|
||||
if (m_ObjectPoolComponent == null)
|
||||
{
|
||||
Log.Fatal("Object pool component is invalid.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Object Pool Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Object Pool Count", m_ObjectPoolComponent.Count.ToString());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
ObjectPoolBase[] objectPools = m_ObjectPoolComponent.GetAllObjectPools(true);
|
||||
for (int i = 0; i < objectPools.Length; i++)
|
||||
{
|
||||
DrawObjectPool(objectPools[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjectPool(ObjectPoolBase objectPool)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>Object Pool: {0}</b>", objectPool.FullName));
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Name", objectPool.Name);
|
||||
DrawItem("Type", objectPool.ObjectType.FullName);
|
||||
DrawItem("Auto Release Interval", objectPool.AutoReleaseInterval.ToString());
|
||||
DrawItem("Capacity", objectPool.Capacity.ToString());
|
||||
DrawItem("Used Count", objectPool.Count.ToString());
|
||||
DrawItem("Can Release Count", objectPool.CanReleaseCount.ToString());
|
||||
DrawItem("Expire Time", objectPool.ExpireTime.ToString());
|
||||
DrawItem("Priority", objectPool.Priority.ToString());
|
||||
ObjectInfo[] objectInfos = objectPool.GetAllObjectInfos();
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("<b>Name</b>");
|
||||
GUILayout.Label("<b>Locked</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label(objectPool.AllowMultiSpawn ? "<b>Count</b>" : "<b>In Use</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Flag</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Priority</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Last Use Time</b>", GUILayout.Width(120f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (objectInfos.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < objectInfos.Length; i++)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(string.IsNullOrEmpty(objectInfos[i].Name) ? "<None>" : objectInfos[i].Name);
|
||||
GUILayout.Label(objectInfos[i].Locked.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectPool.AllowMultiSpawn ? objectInfos[i].SpawnCount.ToString() : objectInfos[i].IsInUse.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectInfos[i].CustomCanReleaseFlag.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectInfos[i].Priority.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(objectInfos[i].LastUseTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), GUILayout.Width(120f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("<i>Object Pool is Empty ...</i>");
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5898a6ad35652924590c863ef4bc6341
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class OperationsWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Operations</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
ObjectPoolComponent objectPoolComponent = GameEntry.GetComponent<ObjectPoolComponent>();
|
||||
if (objectPoolComponent != null)
|
||||
{
|
||||
if (GUILayout.Button("Object Pool Release", GUILayout.Height(30f)))
|
||||
{
|
||||
objectPoolComponent.Release();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Object Pool Release All Unused", GUILayout.Height(30f)))
|
||||
{
|
||||
objectPoolComponent.ReleaseAllUnused();
|
||||
}
|
||||
}
|
||||
|
||||
ResourceComponent resourceCompoent = GameEntry.GetComponent<ResourceComponent>();
|
||||
if (resourceCompoent != null)
|
||||
{
|
||||
if (GUILayout.Button("Unload Unused Assets", GUILayout.Height(30f)))
|
||||
{
|
||||
resourceCompoent.ForceUnloadUnusedAssets(false);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Unload Unused Assets and Garbage Collect", GUILayout.Height(30f)))
|
||||
{
|
||||
resourceCompoent.ForceUnloadUnusedAssets(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Shutdown Game Framework (None)", GUILayout.Height(30f)))
|
||||
{
|
||||
GameEntry.Shutdown(ShutdownType.None);
|
||||
}
|
||||
if (GUILayout.Button("Shutdown Game Framework (Restart)", GUILayout.Height(30f)))
|
||||
{
|
||||
GameEntry.Shutdown(ShutdownType.Restart);
|
||||
}
|
||||
if (GUILayout.Button("Shutdown Game Framework (Quit)", GUILayout.Height(30f)))
|
||||
{
|
||||
GameEntry.Shutdown(ShutdownType.Quit);
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a695dd87b92d7374fbe3790f5a25e9d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class PathInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Path Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Current Directory", Utility.Path.GetRegularPath(Environment.CurrentDirectory));
|
||||
DrawItem("Data Path", Utility.Path.GetRegularPath(Application.dataPath));
|
||||
DrawItem("Persistent Data Path", Utility.Path.GetRegularPath(Application.persistentDataPath));
|
||||
DrawItem("Streaming Assets Path", Utility.Path.GetRegularPath(Application.streamingAssetsPath));
|
||||
DrawItem("Temporary Cache Path", Utility.Path.GetRegularPath(Application.temporaryCachePath));
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Console Log Path", Utility.Path.GetRegularPath(Application.consoleLogPath));
|
||||
#endif
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e86b5be349fea7b46bf4c9cff62cf940
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
using UnityEngine.Profiling;
|
||||
#endif
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class ProfilerInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Profiler Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Supported", Profiler.supported.ToString());
|
||||
DrawItem("Enabled", Profiler.enabled.ToString());
|
||||
DrawItem("Enable Binary Log", Profiler.enableBinaryLog ? Utility.Text.Format("True, {0}", Profiler.logFile) : "False");
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
DrawItem("Enable Allocation Callstacks", Profiler.enableAllocationCallstacks.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Area Count", Profiler.areaCount.ToString());
|
||||
#endif
|
||||
#if UNITY_5_3 || UNITY_5_4
|
||||
DrawItem("Max Samples Number Per Frame", Profiler.maxNumberOfSamplesPerFrame.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Max Used Memory", GetByteLengthString(Profiler.maxUsedMemory));
|
||||
#endif
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Mono Used Size", GetByteLengthString(Profiler.GetMonoUsedSizeLong()));
|
||||
DrawItem("Mono Heap Size", GetByteLengthString(Profiler.GetMonoHeapSizeLong()));
|
||||
DrawItem("Used Heap Size", GetByteLengthString(Profiler.usedHeapSizeLong));
|
||||
DrawItem("Total Allocated Memory", GetByteLengthString(Profiler.GetTotalAllocatedMemoryLong()));
|
||||
DrawItem("Total Reserved Memory", GetByteLengthString(Profiler.GetTotalReservedMemoryLong()));
|
||||
DrawItem("Total Unused Reserved Memory", GetByteLengthString(Profiler.GetTotalUnusedReservedMemoryLong()));
|
||||
#else
|
||||
DrawItem("Mono Used Size", GetByteLengthString(Profiler.GetMonoUsedSize()));
|
||||
DrawItem("Mono Heap Size", GetByteLengthString(Profiler.GetMonoHeapSize()));
|
||||
DrawItem("Used Heap Size", GetByteLengthString(Profiler.usedHeapSize));
|
||||
DrawItem("Total Allocated Memory", GetByteLengthString(Profiler.GetTotalAllocatedMemory()));
|
||||
DrawItem("Total Reserved Memory", GetByteLengthString(Profiler.GetTotalReservedMemory()));
|
||||
DrawItem("Total Unused Reserved Memory", GetByteLengthString(Profiler.GetTotalUnusedReservedMemory()));
|
||||
#endif
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
DrawItem("Allocated Memory For Graphics Driver", GetByteLengthString(Profiler.GetAllocatedMemoryForGraphicsDriver()));
|
||||
#endif
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Temp Allocator Size", GetByteLengthString(Profiler.GetTempAllocatorSize()));
|
||||
#endif
|
||||
DrawItem("Marshal Cached HGlobal Size", GetByteLengthString(Utility.Marshal.CachedHGlobalSize));
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73fd64cd790a9564d9e49d13ed0742c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class QualityInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private bool m_ApplyExpensiveChanges = false;
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Quality Level</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
int currentQualityLevel = QualitySettings.GetQualityLevel();
|
||||
|
||||
DrawItem("Current Quality Level", QualitySettings.names[currentQualityLevel]);
|
||||
m_ApplyExpensiveChanges = GUILayout.Toggle(m_ApplyExpensiveChanges, "Apply expensive changes on quality level change.");
|
||||
|
||||
int newQualityLevel = GUILayout.SelectionGrid(currentQualityLevel, QualitySettings.names, 3, "toggle");
|
||||
if (newQualityLevel != currentQualityLevel)
|
||||
{
|
||||
QualitySettings.SetQualityLevel(newQualityLevel, m_ApplyExpensiveChanges);
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Label("<b>Rendering Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Active Color Space", QualitySettings.activeColorSpace.ToString());
|
||||
DrawItem("Desired Color Space", QualitySettings.desiredColorSpace.ToString());
|
||||
DrawItem("Max Queued Frames", QualitySettings.maxQueuedFrames.ToString());
|
||||
DrawItem("Pixel Light Count", QualitySettings.pixelLightCount.ToString());
|
||||
DrawItem("Master Texture Limit", QualitySettings.globalTextureMipmapLimit.ToString());
|
||||
DrawItem("Anisotropic Filtering", QualitySettings.anisotropicFiltering.ToString());
|
||||
DrawItem("Anti Aliasing", QualitySettings.antiAliasing.ToString());
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Soft Particles", QualitySettings.softParticles.ToString());
|
||||
#endif
|
||||
DrawItem("Soft Vegetation", QualitySettings.softVegetation.ToString());
|
||||
DrawItem("Realtime Reflection Probes", QualitySettings.realtimeReflectionProbes.ToString());
|
||||
DrawItem("Billboards Face Camera Position", QualitySettings.billboardsFaceCameraPosition.ToString());
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
DrawItem("Resolution Scaling Fixed DPI Factor", QualitySettings.resolutionScalingFixedDPIFactor.ToString());
|
||||
#endif
|
||||
#if UNITY_2018_2_OR_NEWER
|
||||
DrawItem("Texture Streaming Enabled", QualitySettings.streamingMipmapsActive.ToString());
|
||||
DrawItem("Texture Streaming Add All Cameras", QualitySettings.streamingMipmapsAddAllCameras.ToString());
|
||||
DrawItem("Texture Streaming Memory Budget", QualitySettings.streamingMipmapsMemoryBudget.ToString());
|
||||
DrawItem("Texture Streaming Renderers Per Frame", QualitySettings.streamingMipmapsRenderersPerFrame.ToString());
|
||||
DrawItem("Texture Streaming Max Level Reduction", QualitySettings.streamingMipmapsMaxLevelReduction.ToString());
|
||||
DrawItem("Texture Streaming Max File IO Requests", QualitySettings.streamingMipmapsMaxFileIORequests.ToString());
|
||||
#endif
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Label("<b>Shadows Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
DrawItem("Shadowmask Mode", QualitySettings.shadowmaskMode.ToString());
|
||||
#endif
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Shadow Quality", QualitySettings.shadows.ToString());
|
||||
#endif
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
DrawItem("Shadow Resolution", QualitySettings.shadowResolution.ToString());
|
||||
#endif
|
||||
DrawItem("Shadow Projection", QualitySettings.shadowProjection.ToString());
|
||||
DrawItem("Shadow Distance", QualitySettings.shadowDistance.ToString());
|
||||
DrawItem("Shadow Near Plane Offset", QualitySettings.shadowNearPlaneOffset.ToString());
|
||||
DrawItem("Shadow Cascades", QualitySettings.shadowCascades.ToString());
|
||||
DrawItem("Shadow Cascade 2 Split", QualitySettings.shadowCascade2Split.ToString());
|
||||
DrawItem("Shadow Cascade 4 Split", QualitySettings.shadowCascade4Split.ToString());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Label("<b>Other Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
DrawItem("Skin Weights", QualitySettings.skinWeights.ToString());
|
||||
#else
|
||||
DrawItem("Blend Weights", QualitySettings.blendWeights.ToString());
|
||||
#endif
|
||||
DrawItem("VSync Count", QualitySettings.vSyncCount.ToString());
|
||||
DrawItem("LOD Bias", QualitySettings.lodBias.ToString());
|
||||
DrawItem("Maximum LOD Level", QualitySettings.maximumLODLevel.ToString());
|
||||
DrawItem("Particle Raycast Budget", QualitySettings.particleRaycastBudget.ToString());
|
||||
DrawItem("Async Upload Time Slice", Utility.Text.Format("{0} ms", QualitySettings.asyncUploadTimeSlice));
|
||||
DrawItem("Async Upload Buffer Size", Utility.Text.Format("{0} MB", QualitySettings.asyncUploadBufferSize));
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Async Upload Persistent Buffer", QualitySettings.asyncUploadPersistentBuffer.ToString());
|
||||
#endif
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc21c02fdf159d840a5254513a44c065
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class ReferencePoolInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private readonly Dictionary<string, List<ReferencePoolInfo>> m_ReferencePoolInfos = new Dictionary<string, List<ReferencePoolInfo>>(StringComparer.Ordinal);
|
||||
private readonly Comparison<ReferencePoolInfo> m_NormalClassNameComparer = NormalClassNameComparer;
|
||||
private readonly Comparison<ReferencePoolInfo> m_FullClassNameComparer = FullClassNameComparer;
|
||||
private bool m_ShowFullClassName = false;
|
||||
|
||||
public override void Initialize(params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Reference Pool Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Enable Strict Check", ReferencePool.EnableStrictCheck.ToString());
|
||||
DrawItem("Reference Pool Count", ReferencePool.Count.ToString());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
m_ShowFullClassName = GUILayout.Toggle(m_ShowFullClassName, "Show Full Class Name");
|
||||
m_ReferencePoolInfos.Clear();
|
||||
ReferencePoolInfo[] referencePoolInfos = ReferencePool.GetAllReferencePoolInfos();
|
||||
foreach (ReferencePoolInfo referencePoolInfo in referencePoolInfos)
|
||||
{
|
||||
string assemblyName = referencePoolInfo.Type.Assembly.GetName().Name;
|
||||
List<ReferencePoolInfo> results = null;
|
||||
if (!m_ReferencePoolInfos.TryGetValue(assemblyName, out results))
|
||||
{
|
||||
results = new List<ReferencePoolInfo>();
|
||||
m_ReferencePoolInfos.Add(assemblyName, results);
|
||||
}
|
||||
|
||||
results.Add(referencePoolInfo);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, List<ReferencePoolInfo>> assemblyReferencePoolInfo in m_ReferencePoolInfos)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>Assembly: {0}</b>", assemblyReferencePoolInfo.Key));
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(m_ShowFullClassName ? "<b>Full Class Name</b>" : "<b>Class Name</b>");
|
||||
GUILayout.Label("<b>Unused</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Using</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Acquire</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Release</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Add</b>", GUILayout.Width(60f));
|
||||
GUILayout.Label("<b>Remove</b>", GUILayout.Width(60f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (assemblyReferencePoolInfo.Value.Count > 0)
|
||||
{
|
||||
assemblyReferencePoolInfo.Value.Sort(m_ShowFullClassName ? m_FullClassNameComparer : m_NormalClassNameComparer);
|
||||
foreach (ReferencePoolInfo referencePoolInfo in assemblyReferencePoolInfo.Value)
|
||||
{
|
||||
DrawReferencePoolInfo(referencePoolInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label("<i>Reference Pool is Empty ...</i>");
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawReferencePoolInfo(ReferencePoolInfo referencePoolInfo)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(m_ShowFullClassName ? referencePoolInfo.Type.FullName : referencePoolInfo.Type.Name);
|
||||
GUILayout.Label(referencePoolInfo.UnusedReferenceCount.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(referencePoolInfo.UsingReferenceCount.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(referencePoolInfo.AcquireReferenceCount.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(referencePoolInfo.ReleaseReferenceCount.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(referencePoolInfo.AddReferenceCount.ToString(), GUILayout.Width(60f));
|
||||
GUILayout.Label(referencePoolInfo.RemoveReferenceCount.ToString(), GUILayout.Width(60f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private static int NormalClassNameComparer(ReferencePoolInfo a, ReferencePoolInfo b)
|
||||
{
|
||||
return a.Type.Name.CompareTo(b.Type.Name);
|
||||
}
|
||||
|
||||
private static int FullClassNameComparer(ReferencePoolInfo a, ReferencePoolInfo b)
|
||||
{
|
||||
return a.Type.FullName.CompareTo(b.Type.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33068d0a27ec5684e994545a7995a17c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed partial class RuntimeMemoryInformationWindow<T> : ScrollableDebuggerWindowBase where T : UnityEngine.Object
|
||||
{
|
||||
private sealed class Sample
|
||||
{
|
||||
private readonly string m_Name;
|
||||
private readonly string m_Type;
|
||||
private readonly long m_Size;
|
||||
private bool m_Highlight;
|
||||
|
||||
public Sample(string name, string type, long size)
|
||||
{
|
||||
m_Name = name;
|
||||
m_Type = type;
|
||||
m_Size = size;
|
||||
m_Highlight = false;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Type;
|
||||
}
|
||||
}
|
||||
|
||||
public long Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Highlight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Highlight;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Highlight = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0da72213ab82f43458578c3ce477a57c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
using UnityEngine.Profiling;
|
||||
#endif
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed partial class RuntimeMemoryInformationWindow<T> : ScrollableDebuggerWindowBase where T : UnityEngine.Object
|
||||
{
|
||||
private const int ShowSampleCount = 300;
|
||||
|
||||
private readonly List<Sample> m_Samples = new List<Sample>();
|
||||
private readonly Comparison<Sample> m_SampleComparer = SampleComparer;
|
||||
private DateTime m_SampleTime = DateTime.MinValue;
|
||||
private long m_SampleSize = 0L;
|
||||
private long m_DuplicateSampleSize = 0L;
|
||||
private int m_DuplicateSimpleCount = 0;
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
string typeName = typeof(T).Name;
|
||||
GUILayout.Label(Utility.Text.Format("<b>{0} Runtime Memory Information</b>", typeName));
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
if (GUILayout.Button(Utility.Text.Format("Take Sample for {0}", typeName), GUILayout.Height(30f)))
|
||||
{
|
||||
TakeSample();
|
||||
}
|
||||
|
||||
if (m_SampleTime <= DateTime.MinValue)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>Please take sample for {0} first.</b>", typeName));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_DuplicateSimpleCount > 0)
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>{0} {1}s ({2}) obtained at {3:yyyy-MM-dd HH:mm:ss}, while {4} {1}s ({5}) might be duplicated.</b>", m_Samples.Count, typeName, GetByteLengthString(m_SampleSize), m_SampleTime.ToLocalTime(), m_DuplicateSimpleCount, GetByteLengthString(m_DuplicateSampleSize)));
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>{0} {1}s ({2}) obtained at {3:yyyy-MM-dd HH:mm:ss}.</b>", m_Samples.Count, typeName, GetByteLengthString(m_SampleSize), m_SampleTime.ToLocalTime()));
|
||||
}
|
||||
|
||||
if (m_Samples.Count > 0)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>{0} Name</b>", typeName));
|
||||
GUILayout.Label("<b>Type</b>", GUILayout.Width(240f));
|
||||
GUILayout.Label("<b>Size</b>", GUILayout.Width(80f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_Samples.Count; i++)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(m_Samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", m_Samples[i].Name) : m_Samples[i].Name);
|
||||
GUILayout.Label(m_Samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", m_Samples[i].Type) : m_Samples[i].Type, GUILayout.Width(240f));
|
||||
GUILayout.Label(m_Samples[i].Highlight ? Utility.Text.Format("<color=yellow>{0}</color>", GetByteLengthString(m_Samples[i].Size)) : GetByteLengthString(m_Samples[i].Size), GUILayout.Width(80f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
count++;
|
||||
if (count >= ShowSampleCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void TakeSample()
|
||||
{
|
||||
m_SampleTime = DateTime.UtcNow;
|
||||
m_SampleSize = 0L;
|
||||
m_DuplicateSampleSize = 0L;
|
||||
m_DuplicateSimpleCount = 0;
|
||||
m_Samples.Clear();
|
||||
|
||||
T[] samples = Resources.FindObjectsOfTypeAll<T>();
|
||||
for (int i = 0; i < samples.Length; i++)
|
||||
{
|
||||
long sampleSize = 0L;
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
sampleSize = Profiler.GetRuntimeMemorySizeLong(samples[i]);
|
||||
#else
|
||||
sampleSize = Profiler.GetRuntimeMemorySize(samples[i]);
|
||||
#endif
|
||||
m_SampleSize += sampleSize;
|
||||
m_Samples.Add(new Sample(samples[i].name, samples[i].GetType().Name, sampleSize));
|
||||
}
|
||||
|
||||
m_Samples.Sort(m_SampleComparer);
|
||||
|
||||
for (int i = 1; i < m_Samples.Count; i++)
|
||||
{
|
||||
if (m_Samples[i].Name == m_Samples[i - 1].Name && m_Samples[i].Type == m_Samples[i - 1].Type && m_Samples[i].Size == m_Samples[i - 1].Size)
|
||||
{
|
||||
m_Samples[i].Highlight = true;
|
||||
m_DuplicateSampleSize += m_Samples[i].Size;
|
||||
m_DuplicateSimpleCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int SampleComparer(Sample a, Sample b)
|
||||
{
|
||||
int result = b.Size.CompareTo(a.Size);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = a.Type.CompareTo(b.Type);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21007b3290d97754ea3ab4d9f46900e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed partial class RuntimeMemorySummaryWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private sealed class Record
|
||||
{
|
||||
private readonly string m_Name;
|
||||
private int m_Count;
|
||||
private long m_Size;
|
||||
|
||||
public Record(string name)
|
||||
{
|
||||
m_Name = name;
|
||||
m_Count = 0;
|
||||
m_Size = 0L;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Count;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Count = value;
|
||||
}
|
||||
}
|
||||
|
||||
public long Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Size = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 468bbdd114a04de429a6bd97b202c891
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
using UnityEngine.Profiling;
|
||||
#endif
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed partial class RuntimeMemorySummaryWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private readonly List<Record> m_Records = new List<Record>();
|
||||
private readonly Comparison<Record> m_RecordComparer = RecordComparer;
|
||||
private DateTime m_SampleTime = DateTime.MinValue;
|
||||
private int m_SampleCount = 0;
|
||||
private long m_SampleSize = 0L;
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Runtime Memory Summary</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
if (GUILayout.Button("Take Sample", GUILayout.Height(30f)))
|
||||
{
|
||||
TakeSample();
|
||||
}
|
||||
|
||||
if (m_SampleTime <= DateTime.MinValue)
|
||||
{
|
||||
GUILayout.Label("<b>Please take sample first.</b>");
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(Utility.Text.Format("<b>{0} Objects ({1}) obtained at {2:yyyy-MM-dd HH:mm:ss}.</b>", m_SampleCount, GetByteLengthString(m_SampleSize), m_SampleTime.ToLocalTime()));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("<b>Type</b>");
|
||||
GUILayout.Label("<b>Count</b>", GUILayout.Width(120f));
|
||||
GUILayout.Label("<b>Size</b>", GUILayout.Width(120f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
for (int i = 0; i < m_Records.Count; i++)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(m_Records[i].Name);
|
||||
GUILayout.Label(m_Records[i].Count.ToString(), GUILayout.Width(120f));
|
||||
GUILayout.Label(GetByteLengthString(m_Records[i].Size), GUILayout.Width(120f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void TakeSample()
|
||||
{
|
||||
m_Records.Clear();
|
||||
m_SampleTime = DateTime.UtcNow;
|
||||
m_SampleCount = 0;
|
||||
m_SampleSize = 0L;
|
||||
|
||||
UnityEngine.Object[] samples = Resources.FindObjectsOfTypeAll<UnityEngine.Object>();
|
||||
for (int i = 0; i < samples.Length; i++)
|
||||
{
|
||||
long sampleSize = 0L;
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
sampleSize = Profiler.GetRuntimeMemorySizeLong(samples[i]);
|
||||
#else
|
||||
sampleSize = Profiler.GetRuntimeMemorySize(samples[i]);
|
||||
#endif
|
||||
string name = samples[i].GetType().Name;
|
||||
m_SampleCount++;
|
||||
m_SampleSize += sampleSize;
|
||||
|
||||
Record record = null;
|
||||
foreach (Record r in m_Records)
|
||||
{
|
||||
if (r.Name == name)
|
||||
{
|
||||
record = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
record = new Record(name);
|
||||
m_Records.Add(record);
|
||||
}
|
||||
|
||||
record.Count++;
|
||||
record.Size += sampleSize;
|
||||
}
|
||||
|
||||
m_Records.Sort(m_RecordComparer);
|
||||
}
|
||||
|
||||
private static int RecordComparer(Record a, Record b)
|
||||
{
|
||||
int result = b.Size.CompareTo(a.Size);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = a.Count.CompareTo(b.Count);
|
||||
if (result != 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return a.Name.CompareTo(b.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45a9f76b48e192d44b0de0eac60975b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class SceneInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Scene Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Scene Count", SceneManager.sceneCount.ToString());
|
||||
DrawItem("Scene Count In Build Settings", SceneManager.sceneCountInBuildSettings.ToString());
|
||||
|
||||
Scene activeScene = SceneManager.GetActiveScene();
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
DrawItem("Active Scene Handle", activeScene.handle.ToString());
|
||||
#endif
|
||||
DrawItem("Active Scene Name", activeScene.name);
|
||||
DrawItem("Active Scene Path", activeScene.path);
|
||||
DrawItem("Active Scene Build Index", activeScene.buildIndex.ToString());
|
||||
DrawItem("Active Scene Is Dirty", activeScene.isDirty.ToString());
|
||||
DrawItem("Active Scene Is Loaded", activeScene.isLoaded.ToString());
|
||||
DrawItem("Active Scene Is Valid", activeScene.IsValid().ToString());
|
||||
DrawItem("Active Scene Root Count", activeScene.rootCount.ToString());
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
DrawItem("Active Scene Is Sub Scene", activeScene.isSubScene.ToString());
|
||||
#endif
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c5471e8b14eef444a96f1e1cb4b6987
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+95
@@ -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 UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class ScreenInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Screen Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Current Resolution", GetResolutionString(Screen.currentResolution));
|
||||
DrawItem("Screen Width", Utility.Text.Format("{0} px / {1:F2} in / {2:F2} cm", Screen.width, Utility.Converter.GetInchesFromPixels(Screen.width), Utility.Converter.GetCentimetersFromPixels(Screen.width)));
|
||||
DrawItem("Screen Height", Utility.Text.Format("{0} px / {1:F2} in / {2:F2} cm", Screen.height, Utility.Converter.GetInchesFromPixels(Screen.height), Utility.Converter.GetCentimetersFromPixels(Screen.height)));
|
||||
DrawItem("Screen DPI", Screen.dpi.ToString("F2"));
|
||||
DrawItem("Screen Orientation", Screen.orientation.ToString());
|
||||
DrawItem("Is Full Screen", Screen.fullScreen.ToString());
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
DrawItem("Full Screen Mode", Screen.fullScreenMode.ToString());
|
||||
#endif
|
||||
DrawItem("Sleep Timeout", GetSleepTimeoutDescription(Screen.sleepTimeout));
|
||||
#if UNITY_2019_2_OR_NEWER
|
||||
DrawItem("Brightness", Screen.brightness.ToString("F2"));
|
||||
#endif
|
||||
DrawItem("Cursor Visible", Cursor.visible.ToString());
|
||||
DrawItem("Cursor Lock State", Cursor.lockState.ToString());
|
||||
DrawItem("Auto Landscape Left", Screen.autorotateToLandscapeLeft.ToString());
|
||||
DrawItem("Auto Landscape Right", Screen.autorotateToLandscapeRight.ToString());
|
||||
DrawItem("Auto Portrait", Screen.autorotateToPortrait.ToString());
|
||||
DrawItem("Auto Portrait Upside Down", Screen.autorotateToPortraitUpsideDown.ToString());
|
||||
#if UNITY_2017_2_OR_NEWER && !UNITY_2017_2_0
|
||||
DrawItem("Safe Area", Screen.safeArea.ToString());
|
||||
#endif
|
||||
#if UNITY_2019_2_OR_NEWER
|
||||
DrawItem("Cutouts", GetCutoutsString(Screen.cutouts));
|
||||
#endif
|
||||
DrawItem("Support Resolutions", GetResolutionsString(Screen.resolutions));
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private string GetSleepTimeoutDescription(int sleepTimeout)
|
||||
{
|
||||
if (sleepTimeout == SleepTimeout.NeverSleep)
|
||||
{
|
||||
return "Never Sleep";
|
||||
}
|
||||
|
||||
if (sleepTimeout == SleepTimeout.SystemSetting)
|
||||
{
|
||||
return "System Setting";
|
||||
}
|
||||
|
||||
return sleepTimeout.ToString();
|
||||
}
|
||||
|
||||
private string GetResolutionString(Resolution resolution)
|
||||
{
|
||||
return Utility.Text.Format("{0} x {1} @ {2}Hz", resolution.width, resolution.height, resolution.refreshRate);
|
||||
}
|
||||
|
||||
private string GetCutoutsString(Rect[] cutouts)
|
||||
{
|
||||
string[] cutoutStrings = new string[cutouts.Length];
|
||||
for (int i = 0; i < cutouts.Length; i++)
|
||||
{
|
||||
cutoutStrings[i] = cutouts[i].ToString();
|
||||
}
|
||||
|
||||
return string.Join("; ", cutoutStrings);
|
||||
}
|
||||
|
||||
private string GetResolutionsString(Resolution[] resolutions)
|
||||
{
|
||||
string[] resolutionStrings = new string[resolutions.Length];
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
resolutionStrings[i] = GetResolutionString(resolutions[i]);
|
||||
}
|
||||
|
||||
return string.Join("; ", resolutionStrings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc352756f31513048a46e56ad2900db7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Debugger;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private abstract class ScrollableDebuggerWindowBase : IDebuggerWindow
|
||||
{
|
||||
private const float TitleWidth = 240f;
|
||||
private Vector2 m_ScrollPosition = Vector2.zero;
|
||||
|
||||
public virtual void Initialize(params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnEnter()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnLeave()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnDraw()
|
||||
{
|
||||
m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
|
||||
{
|
||||
OnDrawScrollableWindow();
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
protected abstract void OnDrawScrollableWindow();
|
||||
|
||||
protected static void DrawItem(string title, string content)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label(title, GUILayout.Width(TitleWidth));
|
||||
if (GUILayout.Button(content, "label"))
|
||||
{
|
||||
CopyToClipboard(content);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
protected static string GetByteLengthString(long byteLength)
|
||||
{
|
||||
if (byteLength < 1024L) // 2 ^ 10
|
||||
{
|
||||
return Utility.Text.Format("{0} Bytes", byteLength);
|
||||
}
|
||||
|
||||
if (byteLength < 1048576L) // 2 ^ 20
|
||||
{
|
||||
return Utility.Text.Format("{0:F2} KB", byteLength / 1024f);
|
||||
}
|
||||
|
||||
if (byteLength < 1073741824L) // 2 ^ 30
|
||||
{
|
||||
return Utility.Text.Format("{0:F2} MB", byteLength / 1048576f);
|
||||
}
|
||||
|
||||
if (byteLength < 1099511627776L) // 2 ^ 40
|
||||
{
|
||||
return Utility.Text.Format("{0:F2} GB", byteLength / 1073741824f);
|
||||
}
|
||||
|
||||
if (byteLength < 1125899906842624L) // 2 ^ 50
|
||||
{
|
||||
return Utility.Text.Format("{0:F2} TB", byteLength / 1099511627776f);
|
||||
}
|
||||
|
||||
if (byteLength < 1152921504606846976L) // 2 ^ 60
|
||||
{
|
||||
return Utility.Text.Format("{0:F2} PB", byteLength / 1125899906842624f);
|
||||
}
|
||||
|
||||
return Utility.Text.Format("{0:F2} EB", byteLength / 1152921504606846976f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1af7b258c93df0341a163adfdd378f8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,219 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class SettingsWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
private DebuggerComponent m_DebuggerComponent = null;
|
||||
private SettingComponent m_SettingComponent = null;
|
||||
private float m_LastIconX = 0f;
|
||||
private float m_LastIconY = 0f;
|
||||
private float m_LastWindowX = 0f;
|
||||
private float m_LastWindowY = 0f;
|
||||
private float m_LastWindowWidth = 0f;
|
||||
private float m_LastWindowHeight = 0f;
|
||||
private float m_LastWindowScale = 0f;
|
||||
|
||||
public override void Initialize(params object[] args)
|
||||
{
|
||||
m_DebuggerComponent = GameEntry.GetComponent<DebuggerComponent>();
|
||||
if (m_DebuggerComponent == null)
|
||||
{
|
||||
Log.Fatal("Debugger component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_SettingComponent = GameEntry.GetComponent<SettingComponent>();
|
||||
if (m_SettingComponent == null)
|
||||
{
|
||||
Log.Fatal("Setting component is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_LastIconX = m_SettingComponent.GetFloat("Debugger.Icon.X", DefaultIconRect.x);
|
||||
m_LastIconY = m_SettingComponent.GetFloat("Debugger.Icon.Y", DefaultIconRect.y);
|
||||
m_LastWindowX = m_SettingComponent.GetFloat("Debugger.Window.X", DefaultWindowRect.x);
|
||||
m_LastWindowY = m_SettingComponent.GetFloat("Debugger.Window.Y", DefaultWindowRect.y);
|
||||
m_LastWindowWidth = m_SettingComponent.GetFloat("Debugger.Window.Width", DefaultWindowRect.width);
|
||||
m_LastWindowHeight = m_SettingComponent.GetFloat("Debugger.Window.Height", DefaultWindowRect.height);
|
||||
m_DebuggerComponent.WindowScale = m_LastWindowScale = m_SettingComponent.GetFloat("Debugger.Window.Scale", DefaultWindowScale);
|
||||
m_DebuggerComponent.IconRect = new Rect(m_LastIconX, m_LastIconY, DefaultIconRect.width, DefaultIconRect.height);
|
||||
m_DebuggerComponent.WindowRect = new Rect(m_LastWindowX, m_LastWindowY, m_LastWindowWidth, m_LastWindowHeight);
|
||||
}
|
||||
|
||||
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
if (m_LastIconX != m_DebuggerComponent.IconRect.x)
|
||||
{
|
||||
m_LastIconX = m_DebuggerComponent.IconRect.x;
|
||||
m_SettingComponent.SetFloat("Debugger.Icon.X", m_DebuggerComponent.IconRect.x);
|
||||
}
|
||||
|
||||
if (m_LastIconY != m_DebuggerComponent.IconRect.y)
|
||||
{
|
||||
m_LastIconY = m_DebuggerComponent.IconRect.y;
|
||||
m_SettingComponent.SetFloat("Debugger.Icon.Y", m_DebuggerComponent.IconRect.y);
|
||||
}
|
||||
|
||||
if (m_LastWindowX != m_DebuggerComponent.WindowRect.x)
|
||||
{
|
||||
m_LastWindowX = m_DebuggerComponent.WindowRect.x;
|
||||
m_SettingComponent.SetFloat("Debugger.Window.X", m_DebuggerComponent.WindowRect.x);
|
||||
}
|
||||
|
||||
if (m_LastWindowY != m_DebuggerComponent.WindowRect.y)
|
||||
{
|
||||
m_LastWindowY = m_DebuggerComponent.WindowRect.y;
|
||||
m_SettingComponent.SetFloat("Debugger.Window.Y", m_DebuggerComponent.WindowRect.y);
|
||||
}
|
||||
|
||||
if (m_LastWindowWidth != m_DebuggerComponent.WindowRect.width)
|
||||
{
|
||||
m_LastWindowWidth = m_DebuggerComponent.WindowRect.width;
|
||||
m_SettingComponent.SetFloat("Debugger.Window.Width", m_DebuggerComponent.WindowRect.width);
|
||||
}
|
||||
|
||||
if (m_LastWindowHeight != m_DebuggerComponent.WindowRect.height)
|
||||
{
|
||||
m_LastWindowHeight = m_DebuggerComponent.WindowRect.height;
|
||||
m_SettingComponent.SetFloat("Debugger.Window.Height", m_DebuggerComponent.WindowRect.height);
|
||||
}
|
||||
|
||||
if (m_LastWindowScale != m_DebuggerComponent.WindowScale)
|
||||
{
|
||||
m_LastWindowScale = m_DebuggerComponent.WindowScale;
|
||||
m_SettingComponent.SetFloat("Debugger.Window.Scale", m_DebuggerComponent.WindowScale);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>Window Settings</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Position:", GUILayout.Width(60f));
|
||||
GUILayout.Label("Drag window caption to move position.");
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
float width = m_DebuggerComponent.WindowRect.width;
|
||||
GUILayout.Label("Width:", GUILayout.Width(60f));
|
||||
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
||||
{
|
||||
width--;
|
||||
}
|
||||
width = GUILayout.HorizontalSlider(width, 100f, Screen.width - 20f);
|
||||
if (GUILayout.RepeatButton("+", GUILayout.Width(30f)))
|
||||
{
|
||||
width++;
|
||||
}
|
||||
width = Mathf.Clamp(width, 100f, Screen.width - 20f);
|
||||
if (width != m_DebuggerComponent.WindowRect.width)
|
||||
{
|
||||
m_DebuggerComponent.WindowRect = new Rect(m_DebuggerComponent.WindowRect.x, m_DebuggerComponent.WindowRect.y, width, m_DebuggerComponent.WindowRect.height);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
float height = m_DebuggerComponent.WindowRect.height;
|
||||
GUILayout.Label("Height:", GUILayout.Width(60f));
|
||||
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
||||
{
|
||||
height--;
|
||||
}
|
||||
height = GUILayout.HorizontalSlider(height, 100f, Screen.height - 20f);
|
||||
if (GUILayout.RepeatButton("+", GUILayout.Width(30f)))
|
||||
{
|
||||
height++;
|
||||
}
|
||||
height = Mathf.Clamp(height, 100f, Screen.height - 20f);
|
||||
if (height != m_DebuggerComponent.WindowRect.height)
|
||||
{
|
||||
m_DebuggerComponent.WindowRect = new Rect(m_DebuggerComponent.WindowRect.x, m_DebuggerComponent.WindowRect.y, m_DebuggerComponent.WindowRect.width, height);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
float scale = m_DebuggerComponent.WindowScale;
|
||||
GUILayout.Label("Scale:", GUILayout.Width(60f));
|
||||
if (GUILayout.RepeatButton("-", GUILayout.Width(30f)))
|
||||
{
|
||||
scale -= 0.01f;
|
||||
}
|
||||
scale = GUILayout.HorizontalSlider(scale, 0.5f, 4f);
|
||||
if (GUILayout.RepeatButton("+", GUILayout.Width(30f)))
|
||||
{
|
||||
scale += 0.01f;
|
||||
}
|
||||
scale = Mathf.Clamp(scale, 0.5f, 4f);
|
||||
if (scale != m_DebuggerComponent.WindowScale)
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = scale;
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("0.5x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 0.5f;
|
||||
}
|
||||
if (GUILayout.Button("1.0x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 1f;
|
||||
}
|
||||
if (GUILayout.Button("1.5x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 1.5f;
|
||||
}
|
||||
if (GUILayout.Button("2.0x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 2f;
|
||||
}
|
||||
if (GUILayout.Button("2.5x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 2.5f;
|
||||
}
|
||||
if (GUILayout.Button("3.0x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 3f;
|
||||
}
|
||||
if (GUILayout.Button("3.5x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 3.5f;
|
||||
}
|
||||
if (GUILayout.Button("4.0x", GUILayout.Height(60f)))
|
||||
{
|
||||
m_DebuggerComponent.WindowScale = 4f;
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (GUILayout.Button("Reset Layout", GUILayout.Height(30f)))
|
||||
{
|
||||
m_DebuggerComponent.ResetLayout();
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4a36d102b4e1a648810a983c2101967
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
public sealed partial class DebuggerComponent : GameFrameworkComponent
|
||||
{
|
||||
private sealed class SystemInformationWindow : ScrollableDebuggerWindowBase
|
||||
{
|
||||
protected override void OnDrawScrollableWindow()
|
||||
{
|
||||
GUILayout.Label("<b>System Information</b>");
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
DrawItem("Device Unique ID", SystemInfo.deviceUniqueIdentifier);
|
||||
DrawItem("Device Name", SystemInfo.deviceName);
|
||||
DrawItem("Device Type", SystemInfo.deviceType.ToString());
|
||||
DrawItem("Device Model", SystemInfo.deviceModel);
|
||||
DrawItem("Processor Type", SystemInfo.processorType);
|
||||
DrawItem("Processor Count", SystemInfo.processorCount.ToString());
|
||||
DrawItem("Processor Frequency", Utility.Text.Format("{0} MHz", SystemInfo.processorFrequency));
|
||||
DrawItem("System Memory Size", Utility.Text.Format("{0} MB", SystemInfo.systemMemorySize));
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
DrawItem("Operating System Family", SystemInfo.operatingSystemFamily.ToString());
|
||||
#endif
|
||||
DrawItem("Operating System", SystemInfo.operatingSystem);
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
DrawItem("Battery Status", SystemInfo.batteryStatus.ToString());
|
||||
DrawItem("Battery Level", GetBatteryLevelString(SystemInfo.batteryLevel));
|
||||
#endif
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
DrawItem("Supports Audio", SystemInfo.supportsAudio.ToString());
|
||||
#endif
|
||||
DrawItem("Supports Location Service", SystemInfo.supportsLocationService.ToString());
|
||||
DrawItem("Supports Accelerometer", SystemInfo.supportsAccelerometer.ToString());
|
||||
DrawItem("Supports Gyroscope", SystemInfo.supportsGyroscope.ToString());
|
||||
DrawItem("Supports Vibration", SystemInfo.supportsVibration.ToString());
|
||||
DrawItem("Genuine", Application.genuine.ToString());
|
||||
DrawItem("Genuine Check Available", Application.genuineCheckAvailable.ToString());
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private string GetBatteryLevelString(float batteryLevel)
|
||||
{
|
||||
if (batteryLevel < 0f)
|
||||
{
|
||||
return "Unavailable";
|
||||
}
|
||||
|
||||
return batteryLevel.ToString("P0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user