mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
SettingsMenu
SettingsMenu
This commit is contained in:
8
Assets/TEngine/Editor/GameSettings.meta
Normal file
8
Assets/TEngine/Editor/GameSettings.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1292f46836a1a2d4e980cc0817de46c1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
7
Assets/TEngine/Editor/GameSettings/SettingsMenu.cs
Normal file
7
Assets/TEngine/Editor/GameSettings/SettingsMenu.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using UnityEditor;
|
||||
|
||||
public static class SettingsMenu
|
||||
{
|
||||
[MenuItem("TEngine/Settings/TEngineSettings", priority = -1)]
|
||||
public static void OpenSettings() => SettingsService.OpenProjectSettings("TEngine/TEngineSettings");
|
||||
}
|
11
Assets/TEngine/Editor/GameSettings/SettingsMenu.cs.meta
Normal file
11
Assets/TEngine/Editor/GameSettings/SettingsMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1afcc6b01c286a54d84a1c6a27deceb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,59 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TEngineSettingsProvider : SettingsProvider
|
||||
{
|
||||
const string k_SettingsPath = "Assets/TEngine/ResRaw/Resources/TEngineGlobalSettings.asset";
|
||||
private const string headerName = "TEngine/TEngineSettings";
|
||||
private SerializedObject m_CustomSettings;
|
||||
|
||||
internal static SerializedObject GetSerializedSettings()
|
||||
{
|
||||
return new SerializedObject(SettingsUtils.GlobalSettings);
|
||||
}
|
||||
|
||||
public static bool IsSettingsAvailable()
|
||||
{
|
||||
return File.Exists(k_SettingsPath);
|
||||
}
|
||||
|
||||
public override void OnActivate(string searchContext, VisualElement rootElement)
|
||||
{
|
||||
base.OnActivate(searchContext, rootElement);
|
||||
m_CustomSettings = GetSerializedSettings();
|
||||
}
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
base.OnGUI(searchContext);
|
||||
using var changeCheckScope = new EditorGUI.ChangeCheckScope();
|
||||
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_FrameworkGlobalSettings"));
|
||||
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_BybridCLRCustomGlobalSettings"));
|
||||
EditorGUILayout.Space(20);
|
||||
if (!changeCheckScope.changed) return;
|
||||
m_CustomSettings.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
public TEngineSettingsProvider(string path, SettingsScope scopes, IEnumerable<string> keywords = null) : base(path, scopes, keywords)
|
||||
{
|
||||
}
|
||||
|
||||
[SettingsProvider]
|
||||
private static SettingsProvider CreateSettingProvider()
|
||||
{
|
||||
if (IsSettingsAvailable())
|
||||
{
|
||||
var provider = new TEngineSettingsProvider(headerName, SettingsScope.Project);
|
||||
provider.keywords = GetSearchKeywordsFromGUIContentProperties<TEngineSettings>();
|
||||
return provider;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Open GameFramework Settings error,Please Create Game Framework/GameFrameworkSettings.assets File in Path GameMain/Resources/Settings");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09fb422339ad47ec86205963c369718b
|
||||
timeCreated: 1678946531
|
8
Assets/TEngine/Editor/HybridCLR.meta
Normal file
8
Assets/TEngine/Editor/HybridCLR.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68636450bb18ad54fa7896ae5b6297fa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
64
Assets/TEngine/Editor/HybridCLR/BuildAssetsCommand.cs
Normal file
64
Assets/TEngine/Editor/HybridCLR/BuildAssetsCommand.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using HybridCLR.Editor;
|
||||
using HybridCLR.Editor.Commands;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
public static class BuildAssetsCommand
|
||||
{
|
||||
[MenuItem("HybridCLR/Build/BuildAssets And CopyTo AssemblyTextAssetPath")]
|
||||
public static void BuildAndCopyDlls()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
CopyAOTHotUpdateDlls(target);
|
||||
}
|
||||
|
||||
public static void CopyAOTHotUpdateDlls(BuildTarget target)
|
||||
{
|
||||
CopyAOTAssembliesToAssetPath();
|
||||
CopyHotUpdateAssembliesToAssetPath();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
public static void CopyAOTAssembliesToAssetPath()
|
||||
{
|
||||
var target = EditorUserBuildSettings.activeBuildTarget;
|
||||
string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
string aotAssembliesDstDir = Application.dataPath +"/"+ SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath;
|
||||
|
||||
foreach (var dll in SettingsUtils.HybridCLRCustomGlobalSettings.AOTMetaAssemblies)
|
||||
{
|
||||
string srcDllPath = $"{aotAssembliesSrcDir}/{dll}";
|
||||
if (!System.IO.File.Exists(srcDllPath))
|
||||
{
|
||||
Debug.LogError($"ab中添加AOT补充元数据dll:{srcDllPath} 时发生错误,文件不存在。裁剪后的AOT dll在BuildPlayer时才能生成,因此需要你先构建一次游戏App后再打包。");
|
||||
continue;
|
||||
}
|
||||
string dllBytesPath = $"{aotAssembliesDstDir}/{dll}.bytes";
|
||||
System.IO.File.Copy(srcDllPath, dllBytesPath, true);
|
||||
Debug.Log($"[CopyAOTAssembliesToStreamingAssets] copy AOT dll {srcDllPath} -> {dllBytesPath}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void CopyHotUpdateAssembliesToAssetPath()
|
||||
{
|
||||
var target = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
||||
string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);
|
||||
string hotfixAssembliesDstDir = Application.dataPath +"/"+ SettingsUtils.HybridCLRCustomGlobalSettings.AssemblyTextAssetPath;
|
||||
foreach (var dll in SettingsUtil.HotUpdateAssemblyFilesExcludePreserved)
|
||||
{
|
||||
string dllPath = $"{hotfixDllSrcDir}/{dll}";
|
||||
string dllBytesPath = $"{hotfixAssembliesDstDir}/{dll}.bytes";
|
||||
System.IO.File.Copy(dllPath, dllBytesPath, true);
|
||||
Debug.Log($"[CopyHotUpdateAssembliesToStreamingAssets] copy hotfix dll {dllPath} -> {dllBytesPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
11
Assets/TEngine/Editor/HybridCLR/BuildAssetsCommand.cs.meta
Normal file
11
Assets/TEngine/Editor/HybridCLR/BuildAssetsCommand.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b43c8d69a58c066469f4f28e310d8181
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
47
Assets/TEngine/ResRaw/Resources/TEngineGlobalSettings.asset
Normal file
47
Assets/TEngine/ResRaw/Resources/TEngineGlobalSettings.asset
Normal file
@@ -0,0 +1,47 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 577471f3ecd1ec94b8a0d67218386f4a, type: 3}
|
||||
m_Name: TEngineGlobalSettings
|
||||
m_EditorClassIdentifier:
|
||||
m_FrameworkGlobalSettings:
|
||||
m_ScriptAuthor: Default
|
||||
m_ScriptVersion: 0.1
|
||||
m_AppStage: 1
|
||||
m_DefaultFont: Arial
|
||||
m_ResourcesArea:
|
||||
m_ResAdminType: Default
|
||||
m_ResAdminCode: 0
|
||||
m_ServerType: 1
|
||||
m_CleanCommitPathRes: 1
|
||||
m_InnerResourceSourceUrl: http://127.0.0.1:8088
|
||||
m_ExtraResourceSourceUrl: http://127.0.0.1:8088
|
||||
m_FormalResourceSourceUrl: http://127.0.0.1:8088
|
||||
m_AtlasFolder: Assets/AssetRaw/Atlas
|
||||
m_ResourceVersionFileName: ResourceVersion.txt
|
||||
CheckVersionUrl: http://127.0.0.1/Resources/{0}Version.txt
|
||||
WindowsAppUrl: http://127.0.0.1
|
||||
MacOSAppUrl: http://127.0.0.1
|
||||
IOSAppUrl: http://127.0.0.1
|
||||
AndroidAppUrl: http://127.0.0.1
|
||||
m_CurUseServerChannel:
|
||||
m_ServerChannelInfos: []
|
||||
m_IsReadLocalConfigInEditor: 1
|
||||
m_ConfigFolderName: Assets/AssetRaw/Configs/
|
||||
m_BybridCLRCustomGlobalSettings:
|
||||
m_Enable: 0
|
||||
m_Gitee: 1
|
||||
HotUpdateAssemblies: []
|
||||
AOTMetaAssemblies: []
|
||||
LogicMainDllName: xxx.dll
|
||||
AssemblyTextAssetExtension: .bytes
|
||||
AssemblyTextAssetPath: Assets/AssetRaw/DLL
|
||||
HybridCLRGlobalSettings: Settings/HybridCLRGlobalSettings
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4ca975e526dcaf4b9b9de906997f52b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TEngine/Runtime/GameSettings.meta
Normal file
8
Assets/TEngine/Runtime/GameSettings.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f7fd704edb046f49ad714c1c1c82af5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/TEngine/Runtime/GameSettings/Enum.meta
Normal file
3
Assets/TEngine/Runtime/GameSettings/Enum.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 267688fe79c44595ab7169379b4dd8be
|
||||
timeCreated: 1678945994
|
23
Assets/TEngine/Runtime/GameSettings/Enum/AppStageEnum.cs
Normal file
23
Assets/TEngine/Runtime/GameSettings/Enum/AppStageEnum.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
public enum AppStageEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试版本
|
||||
/// </summary>
|
||||
Debug = 1,
|
||||
/// <summary>
|
||||
/// 前期版本
|
||||
/// </summary>
|
||||
Alpha = 2,
|
||||
/// <summary>
|
||||
/// 中期版本
|
||||
/// </summary>
|
||||
Beta = 3,
|
||||
/// <summary>
|
||||
/// 后期版本 与发布版本没多大差别
|
||||
/// </summary>
|
||||
Rc = 4,
|
||||
/// <summary>
|
||||
/// 发布版本
|
||||
/// </summary>
|
||||
Release = 5
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02f6e676930b49429c55884c7540d94c
|
||||
timeCreated: 1678945994
|
@@ -0,0 +1,9 @@
|
||||
/// <summary>
|
||||
/// 资源类型 游戏内资源 和 配置表资源
|
||||
/// </summary>
|
||||
public enum ResourcesType
|
||||
{
|
||||
None = 0,
|
||||
Resources = 1,
|
||||
Config = 2
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33cc579af96f43cfb384bdea5aafa3b7
|
||||
timeCreated: 1678945994
|
19
Assets/TEngine/Runtime/GameSettings/Enum/ServerTypeEnum.cs
Normal file
19
Assets/TEngine/Runtime/GameSettings/Enum/ServerTypeEnum.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
public enum ServerTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 无
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 内网
|
||||
/// </summary>
|
||||
Intranet = 1,
|
||||
/// <summary>
|
||||
/// 外网
|
||||
/// </summary>
|
||||
Extranet = 2,
|
||||
/// <summary>
|
||||
/// 正式服
|
||||
/// </summary>
|
||||
Formal = 3
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4e936a6b106467db84d9e043d174926
|
||||
timeCreated: 1678945994
|
3
Assets/TEngine/Runtime/GameSettings/Framework.meta
Normal file
3
Assets/TEngine/Runtime/GameSettings/Framework.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef80ca1c867d4deaa8d0dbe9d3cbabff
|
||||
timeCreated: 1678945935
|
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum UpdateType
|
||||
{
|
||||
None = 0,
|
||||
//底包更新
|
||||
PackageUpdate = 1,
|
||||
//资源更新
|
||||
ResourceUpdate = 2,
|
||||
}
|
||||
|
||||
public enum UpdateStyle
|
||||
{
|
||||
None = 0,
|
||||
Froce = 1, //强制
|
||||
Optional = 2,//非强制
|
||||
}
|
||||
|
||||
public enum UpdateNotice
|
||||
{
|
||||
None = 0,
|
||||
Notice = 1, //提示
|
||||
NoNotice = 2,//非提示
|
||||
}
|
||||
|
||||
public enum GameStatus
|
||||
{
|
||||
First = 0,
|
||||
AssetLoad = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源存放地
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ResourcesArea
|
||||
{
|
||||
[Tooltip("资源管理类型")] [SerializeField] private string m_ResAdminType = "Default";
|
||||
|
||||
public string ResAdminType
|
||||
{
|
||||
get { return m_ResAdminType; }
|
||||
}
|
||||
|
||||
[Tooltip("资源管理编号")] [SerializeField] private string m_ResAdminCode = "0";
|
||||
|
||||
public string ResAdminCode
|
||||
{
|
||||
get { return m_ResAdminCode; }
|
||||
}
|
||||
|
||||
[SerializeField] private ServerTypeEnum m_ServerType = ServerTypeEnum.Intranet;
|
||||
|
||||
public ServerTypeEnum ServerType
|
||||
{
|
||||
get { return m_ServerType; }
|
||||
}
|
||||
|
||||
[Tooltip("是否在构建资源的时候清理上传到服务端目录的老资源")] [SerializeField]
|
||||
private bool m_CleanCommitPathRes = true;
|
||||
|
||||
public bool CleanCommitPathRes
|
||||
{
|
||||
get { return m_CleanCommitPathRes; }
|
||||
}
|
||||
|
||||
[Tooltip("内网地址")] [SerializeField] private string m_InnerResourceSourceUrl = "http://127.0.0.1:8088";
|
||||
|
||||
public string InnerResourceSourceUrl
|
||||
{
|
||||
get { return m_InnerResourceSourceUrl; }
|
||||
}
|
||||
|
||||
[Tooltip("外网地址")] [SerializeField] private string m_ExtraResourceSourceUrl = "http://127.0.0.1:8088";
|
||||
|
||||
public string ExtraResourceSourceUrl
|
||||
{
|
||||
get { return m_ExtraResourceSourceUrl; }
|
||||
}
|
||||
|
||||
[Tooltip("正式地址")] [SerializeField] private string m_FormalResourceSourceUrl = "http://127.0.0.1:8088";
|
||||
|
||||
public string FormalResourceSourceUrl
|
||||
{
|
||||
get { return m_FormalResourceSourceUrl; }
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ServerIpAndPort
|
||||
{
|
||||
public string ServerName;
|
||||
public string Ip;
|
||||
public int Port;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ServerChannelInfo
|
||||
{
|
||||
public string ChannelName;
|
||||
public string CurUseServerName;
|
||||
public List<ServerIpAndPort> ServerIpAndPorts;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class FrameworkGlobalSettings
|
||||
{
|
||||
[SerializeField] [Tooltip("脚本作者名")] private string m_ScriptAuthor = "Default";
|
||||
|
||||
public string ScriptAuthor
|
||||
{
|
||||
get { return m_ScriptAuthor; }
|
||||
}
|
||||
|
||||
[SerializeField] [Tooltip("版本")] private string m_ScriptVersion = "0.1";
|
||||
|
||||
public string ScriptVersion
|
||||
{
|
||||
get { return m_ScriptVersion; }
|
||||
}
|
||||
|
||||
[SerializeField] private AppStageEnum m_AppStage = AppStageEnum.Debug;
|
||||
|
||||
public AppStageEnum AppStage
|
||||
{
|
||||
get { return m_AppStage; }
|
||||
}
|
||||
|
||||
// // 资源更新类型
|
||||
// public UpdateType UpdateType = UpdateType.PackageUpdate;
|
||||
//
|
||||
// // 更新是否强制
|
||||
// public UpdateStyle UpdateStyle = UpdateStyle.Froce;
|
||||
//
|
||||
// // 更新提示类型
|
||||
// public UpdateNotice UpdateNotice = UpdateNotice.Notice;
|
||||
|
||||
[Header("Font")] [SerializeField] private string m_DefaultFont = "Arial";
|
||||
public string DefaultFont => m_DefaultFont;
|
||||
|
||||
[Header("Resources")] [Tooltip("资源存放地")] [SerializeField]
|
||||
private ResourcesArea m_ResourcesArea;
|
||||
|
||||
public ResourcesArea ResourcesArea
|
||||
{
|
||||
get { return m_ResourcesArea; }
|
||||
}
|
||||
|
||||
[Header("SpriteCollection")] [SerializeField]
|
||||
private string m_AtlasFolder = "Assets/AssetRaw/Atlas";
|
||||
|
||||
public string AtlasFolder
|
||||
{
|
||||
get { return m_AtlasFolder; }
|
||||
}
|
||||
|
||||
[Header("Hotfix")] [SerializeField]
|
||||
private string m_ResourceVersionFileName = "ResourceVersion.txt";
|
||||
|
||||
public string ResourceVersionFileName
|
||||
{
|
||||
get { return m_ResourceVersionFileName; }
|
||||
}
|
||||
|
||||
public string CheckVersionUrl = "http://127.0.0.1/Resources/{0}Version.txt";
|
||||
public string WindowsAppUrl = "http://127.0.0.1";
|
||||
public string MacOSAppUrl = "http://127.0.0.1";
|
||||
public string IOSAppUrl = "http://127.0.0.1";
|
||||
public string AndroidAppUrl = "http://127.0.0.1";
|
||||
[Header("Server")] [SerializeField] private string m_CurUseServerChannel;
|
||||
|
||||
public string CurUseServerChannel
|
||||
{
|
||||
get => m_CurUseServerChannel;
|
||||
}
|
||||
|
||||
[SerializeField] private List<ServerChannelInfo> m_ServerChannelInfos;
|
||||
|
||||
public List<ServerChannelInfo> ServerChannelInfos
|
||||
{
|
||||
get => m_ServerChannelInfos;
|
||||
}
|
||||
|
||||
[Header("Config")] [Tooltip("是否读取本地表 UnityEditor 下起作用")] [SerializeField]
|
||||
private bool m_IsReadLocalConfigInEditor = true;
|
||||
|
||||
public bool ReadLocalConfigInEditor
|
||||
{
|
||||
get { return m_IsReadLocalConfigInEditor; }
|
||||
}
|
||||
|
||||
[SerializeField] private string m_ConfigFolderName = "Assets/AssetRaw/Configs/";
|
||||
|
||||
public string ConfigFolderName
|
||||
{
|
||||
get { return m_ConfigFolderName; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3eb9df088d254feaa49d19bad18cec8b
|
||||
timeCreated: 1678945935
|
3
Assets/TEngine/Runtime/GameSettings/HybridCLR.meta
Normal file
3
Assets/TEngine/Runtime/GameSettings/HybridCLR.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 692f2f21aeac40feb1bbddd81fbc84b5
|
||||
timeCreated: 1678945935
|
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// HybridCLRCustomGlobalSettings.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class HybridCLRCustomGlobalSettings
|
||||
{
|
||||
[Header("Auto sync with [HybridCLRGlobalSettings]")]
|
||||
[Tooltip("You should modify the file form file path [Assets/CustomHybridCLR/Settings/HybridCLRGlobalSettings.asset]")]
|
||||
[SerializeField]
|
||||
private bool m_Enable = false;
|
||||
|
||||
public bool Enable
|
||||
{
|
||||
get { return m_Enable; }
|
||||
set { m_Enable = value; }
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Gitee = true;
|
||||
|
||||
public bool Gitee
|
||||
{
|
||||
get { return m_Gitee; }
|
||||
set { m_Gitee = value; }
|
||||
}
|
||||
|
||||
[Header("Auto sync with [HybridCLRGlobalSettings]")] [Tooltip("You should modify the file form file path [Assets/CustomHybridCLR/Settings/HybridCLRGlobalSettings.asset]")]
|
||||
public List<string> HotUpdateAssemblies;
|
||||
|
||||
[Header("Need manual setting!")] public List<string> AOTMetaAssemblies;
|
||||
|
||||
/// <summary>
|
||||
/// Dll of main business logic assembly
|
||||
/// </summary>
|
||||
public string LogicMainDllName = "xxx.dll";
|
||||
|
||||
/// <summary>
|
||||
/// 程序集文本资产打包Asset后缀名
|
||||
/// </summary>
|
||||
public string AssemblyTextAssetExtension = ".bytes";
|
||||
|
||||
/// <summary>
|
||||
/// 程序集文本资产资源目录
|
||||
/// </summary>
|
||||
public string AssemblyTextAssetPath = "Assets/AssetRaw/DLL";
|
||||
|
||||
/// <summary>
|
||||
/// Resources HybridCLRGlobalSettings Dir
|
||||
/// </summary>
|
||||
public string HybridCLRGlobalSettings = "Settings/HybridCLRGlobalSettings";
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88b6465202d847c08f39cf6200f0777b
|
||||
timeCreated: 1678945935
|
200
Assets/TEngine/Runtime/GameSettings/SettingsUtils.cs
Normal file
200
Assets/TEngine/Runtime/GameSettings/SettingsUtils.cs
Normal file
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using TEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SettingsUtils
|
||||
{
|
||||
private static readonly string GlobalSettingsPath = $"TEngineGlobalSettings";
|
||||
private static TEngineSettings _globalSettings;
|
||||
|
||||
public static TEngineSettings GlobalSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_globalSettings == null)
|
||||
{
|
||||
_globalSettings = GetSingletonAssetsByResources<TEngineSettings>(GlobalSettingsPath);
|
||||
}
|
||||
|
||||
return _globalSettings;
|
||||
}
|
||||
}
|
||||
|
||||
public static FrameworkGlobalSettings FrameworkGlobalSettings => GlobalSettings.FrameworkGlobalSettings;
|
||||
|
||||
public static HybridCLRCustomGlobalSettings HybridCLRCustomGlobalSettings => GlobalSettings.BybridCLRCustomGlobalSettings;
|
||||
|
||||
public static ResourcesArea ResourcesArea => GlobalSettings.FrameworkGlobalSettings.ResourcesArea;
|
||||
|
||||
public static void SetHybridCLRHotUpdateAssemblies(List<string> hotUpdateAssemblies)
|
||||
{
|
||||
HybridCLRCustomGlobalSettings.HotUpdateAssemblies = hotUpdateAssemblies;
|
||||
}
|
||||
|
||||
public static void SetHybridCLRAOTMetaAssemblies(List<string> aOTMetaAssemblies)
|
||||
{
|
||||
HybridCLRCustomGlobalSettings.AOTMetaAssemblies = aOTMetaAssemblies;
|
||||
}
|
||||
|
||||
|
||||
public static string GetAppUpdateUrl()
|
||||
{
|
||||
string url = null;
|
||||
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
||||
url = FrameworkGlobalSettings.WindowsAppUrl;
|
||||
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
|
||||
url = FrameworkGlobalSettings.MacOSAppUrl;
|
||||
#elif UNITY_IOS
|
||||
url = FrameworkGlobalSettings.IOSAppUrl;
|
||||
#elif UNITY_ANDROID
|
||||
url = FrameworkGlobalSettings.AndroidAppUrl;
|
||||
#endif
|
||||
return url;
|
||||
}
|
||||
|
||||
public static string GetResDownLoadPath(string fileName = "")
|
||||
{
|
||||
return Path.Combine(CompleteDownLoadPath, $"{ResourcesArea.ResAdminType}_{ResourcesArea.ResAdminCode}", GetPlatformName(), fileName).Replace("\\", "/");
|
||||
}
|
||||
|
||||
public static string CompleteDownLoadPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string url = "";
|
||||
if (ResourcesArea.ServerType == ServerTypeEnum.Extranet)
|
||||
{
|
||||
url = ResourcesArea.ExtraResourceSourceUrl;
|
||||
}
|
||||
else if (ResourcesArea.ServerType == ServerTypeEnum.Formal)
|
||||
{
|
||||
url = ResourcesArea.FormalResourceSourceUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
url = ResourcesArea.InnerResourceSourceUrl;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private static ServerIpAndPort FindServerIpAndPort(string channelName = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(channelName))
|
||||
{
|
||||
channelName = FrameworkGlobalSettings.CurUseServerChannel;
|
||||
}
|
||||
|
||||
foreach (var serverChannelInfo in FrameworkGlobalSettings.ServerChannelInfos)
|
||||
{
|
||||
if (serverChannelInfo.ChannelName.Equals(channelName))
|
||||
{
|
||||
foreach (var serverIpAndPort in serverChannelInfo.ServerIpAndPorts)
|
||||
{
|
||||
if (serverIpAndPort.ServerName.Equals(serverChannelInfo.CurUseServerName))
|
||||
{
|
||||
return serverIpAndPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetServerIp(string channelName = "")
|
||||
{
|
||||
ServerIpAndPort serverIpAndPort = FindServerIpAndPort(channelName);
|
||||
if (serverIpAndPort != null)
|
||||
{
|
||||
return serverIpAndPort.Ip;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static int GetServerPort(string channelName = "")
|
||||
{
|
||||
ServerIpAndPort serverIpAndPort = FindServerIpAndPort(channelName);
|
||||
if (serverIpAndPort != null)
|
||||
{
|
||||
return serverIpAndPort.Port;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static T GetSingletonAssetsByResources<T>(string assetsPath) where T : ScriptableObject, new()
|
||||
{
|
||||
string assetType = typeof(T).Name;
|
||||
#if UNITY_EDITOR
|
||||
string[] globalAssetPaths = UnityEditor.AssetDatabase.FindAssets($"t:{assetType}");
|
||||
if (globalAssetPaths.Length > 1)
|
||||
{
|
||||
foreach (var assetPath in globalAssetPaths)
|
||||
{
|
||||
Debug.LogError($"Could not had Multiple {assetType}. Repeated Path: {UnityEditor.AssetDatabase.GUIDToAssetPath(assetPath)}");
|
||||
}
|
||||
|
||||
throw new Exception($"Could not had Multiple {assetType}");
|
||||
}
|
||||
#endif
|
||||
T customGlobalSettings = Resources.Load<T>(assetsPath);
|
||||
if (customGlobalSettings == null)
|
||||
{
|
||||
Log.Error($"Could not found {assetType} asset,so auto create:{assetsPath}.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return customGlobalSettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 平台名字
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetPlatformName()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
return "Android";
|
||||
#elif UNITY_IOS
|
||||
return "IOS";
|
||||
#else
|
||||
switch (Application.platform)
|
||||
{
|
||||
case RuntimePlatform.WindowsEditor:
|
||||
return "Windows64";
|
||||
case RuntimePlatform.WindowsPlayer:
|
||||
return "Windows64";
|
||||
|
||||
case RuntimePlatform.OSXEditor:
|
||||
case RuntimePlatform.OSXPlayer:
|
||||
return "MacOS";
|
||||
|
||||
case RuntimePlatform.IPhonePlayer:
|
||||
return "IOS";
|
||||
|
||||
case RuntimePlatform.Android:
|
||||
return "Android";
|
||||
default:
|
||||
throw new System.NotSupportedException(string.Format("Platform '{0}' is not supported.",
|
||||
Application.platform.ToString()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string GetConfigAsset(string assetName)
|
||||
{
|
||||
return GlobalSettings.FrameworkGlobalSettings.ConfigFolderName + assetName;
|
||||
}
|
||||
|
||||
public static string GetDictionaryAsset(string assetName, bool fromBytes)
|
||||
{
|
||||
// return Utility.Text.Format("Assets/GameMain/Localization/{0}/Dictionaries/{1}.{2}",
|
||||
// GameEntry.GetModule<LocalizationComponent>().Language.ToString(), assetName, fromBytes ? "bytes" : "xml");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/GameSettings/SettingsUtils.cs.meta
Normal file
11
Assets/TEngine/Runtime/GameSettings/SettingsUtils.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 921c67d24bf14d74099388b877f3d3a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Assets/TEngine/Runtime/GameSettings/TEngineSettings.cs
Normal file
19
Assets/TEngine/Runtime/GameSettings/TEngineSettings.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "TEngineGlobalSettings", menuName = "TEngine/TEngineSettings")]
|
||||
public class TEngineSettings : ScriptableObject
|
||||
{
|
||||
[Header("Framework")] [SerializeField] private FrameworkGlobalSettings m_FrameworkGlobalSettings;
|
||||
|
||||
public FrameworkGlobalSettings FrameworkGlobalSettings
|
||||
{
|
||||
get { return m_FrameworkGlobalSettings; }
|
||||
}
|
||||
|
||||
[Header("HybridCLR")] [SerializeField] private HybridCLRCustomGlobalSettings m_BybridCLRCustomGlobalSettings;
|
||||
|
||||
public HybridCLRCustomGlobalSettings BybridCLRCustomGlobalSettings
|
||||
{
|
||||
get { return m_BybridCLRCustomGlobalSettings; }
|
||||
}
|
||||
}
|
11
Assets/TEngine/Runtime/GameSettings/TEngineSettings.cs.meta
Normal file
11
Assets/TEngine/Runtime/GameSettings/TEngineSettings.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 577471f3ecd1ec94b8a0d67218386f4a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user