Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Editor/BuildHotfix/BuildHotfixHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void CopyHotfixCode()
continue;
}

File.Copy(srcPath, Path.Combine(CodeDir, hotfix + Utility.Const.FileNameSuffix.Binary), true);
File.Copy(srcPath, Path.Combine(CodeDir, hotfix + FileNameSuffix.Binary), true);
}

Debug.Log($"复制Hotfix DLL到{CodeDir}完成");
Expand All @@ -78,7 +78,7 @@ public static void CopyAOTCode()
Directory.CreateDirectory(AOTCodeDir);
}

FileHelper.CleanDirectory(AOTCodeDir);
FileUtility.CleanDirectory(AOTCodeDir);

DirectoryInfo directoryInfo = new DirectoryInfo(Application.dataPath);
string path = Path.Combine(directoryInfo.Parent.FullName, "HybridCLRData", "AssembliesPostIl2CppStrip", EditorUserBuildSettings.activeBuildTarget.ToString());
Expand All @@ -95,7 +95,7 @@ public static void CopyAOTCode()
foreach (var fileInfo in files)
{
stringBuilder.AppendLine(fileInfo.Name);
fileInfo.CopyTo(AOTCodeDir + "/" + fileInfo.Name + Utility.Const.FileNameSuffix.Binary, true);
fileInfo.CopyTo(AOTCodeDir + "/" + fileInfo.Name + FileNameSuffix.Binary, true);
}

Debug.Log(stringBuilder);
Expand Down
30 changes: 15 additions & 15 deletions Editor/BuildProduct/BuildProductHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ namespace GameFrameX.Editor
public static class BuildProductHelper
{
private static string _buildPath;
private const int ScreenWidth = 1080;
private const int ScreenHeight = 1920;

private static List<System.Type> RunHook(System.Type hookType)
{
List<System.Type> result = new List<System.Type>();
var types = Utility.Assembly.GetTypes();
var types = AssemblyUtility.GetTypes();
foreach (var type in types)
{
if (type.IsAbstract)
Expand Down Expand Up @@ -87,8 +89,8 @@ public static void BuildPlayerToActiveBuildTarget()
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneOSX)
{
PlayerSettings.fullScreenMode = FullScreenMode.Windowed;
PlayerSettings.defaultScreenHeight = 720;
PlayerSettings.defaultScreenWidth = 1280;
PlayerSettings.defaultScreenHeight = ScreenHeight;
PlayerSettings.defaultScreenWidth = ScreenWidth;
}

AssetDatabase.SaveAssets();
Expand All @@ -113,8 +115,8 @@ public static void BuildPlayerToWindows64BuildTarget()
{
HotFixEditorCompilerHelper.AddEditor();
PlayerSettings.fullScreenMode = FullScreenMode.Windowed;
PlayerSettings.defaultScreenHeight = 720;
PlayerSettings.defaultScreenWidth = 1280;
PlayerSettings.defaultScreenHeight = ScreenHeight;
PlayerSettings.defaultScreenWidth = ScreenWidth;
EditorUserBuildSettings.selectedStandaloneTarget = BuildTarget.StandaloneWindows64;
UpdateBuildTime();
AssetDatabase.SaveAssets();
Expand Down Expand Up @@ -142,7 +144,7 @@ public static void BuildPlayerToWindows64BuildTarget()

var pathName = Path.GetDirectoryName(resultDirectory);
Debug.Log("Build Output Path:" + resultDirectory);
// ZipHelper.CompressDirectory(resultDirectory, pathName + ".zip");
// ZipUtility.CompressDirectory(resultDirectory, pathName + ".zip");
}
finally
{
Expand All @@ -166,8 +168,8 @@ public static void BuildPlayerToWindows32BuildTarget()
{
HotFixEditorCompilerHelper.AddEditor();
PlayerSettings.fullScreenMode = FullScreenMode.Windowed;
PlayerSettings.defaultScreenHeight = 720;
PlayerSettings.defaultScreenWidth = 1280;
PlayerSettings.defaultScreenHeight = ScreenHeight;
PlayerSettings.defaultScreenWidth = ScreenWidth;
EditorUserBuildSettings.selectedStandaloneTarget = BuildTarget.StandaloneWindows;
UpdateBuildTime();
AssetDatabase.SaveAssets();
Expand Down Expand Up @@ -196,7 +198,7 @@ public static void BuildPlayerToWindows32BuildTarget()

var pathName = Path.GetDirectoryName(resultDirectory);
Debug.Log("Build Output Path:" + resultDirectory);
// ZipHelper.CompressDirectory(resultDirectory, pathName + ".zip");
// ZipUtility.CompressDirectory(resultDirectory, pathName + ".zip");
}
finally
{
Expand All @@ -219,8 +221,8 @@ public static void BuildPlayerToMacBuildTarget()
HotFixEditorCompilerHelper.AddEditor();
// PlayerSettings.SplashScreen.show = false;
PlayerSettings.fullScreenMode = FullScreenMode.Windowed;
PlayerSettings.defaultScreenHeight = 720;
PlayerSettings.defaultScreenWidth = 1280;
PlayerSettings.defaultScreenHeight = ScreenHeight;
PlayerSettings.defaultScreenWidth = ScreenWidth;
UpdateBuildTime();

AssetDatabase.SaveAssets();
Expand All @@ -247,7 +249,7 @@ public static void BuildPlayerToMacBuildTarget()

var pathName = Path.GetDirectoryName(resultDirectory);
Debug.Log("Build Output Path:" + resultDirectory);
// ZipHelper.CompressDirectory(resultDirectory, pathName + ".zip");
// ZipUtility.CompressDirectory(resultDirectory, pathName + ".zip");
}
finally
{
Expand Down Expand Up @@ -439,7 +441,7 @@ private static void BuildAppBundleForAndroid()

EditorUserBuildSettings.buildAppBundle = true;
// 开启符号表的输出
EditorUserBuildSettings.androidCreateSymbolsZip = true;
EditorUserBuildSettings.androidCreateSymbols = AndroidCreateSymbols.Debugging;
AssetDatabase.SaveAssets();
_buildPath = aabFilePath;
RunPreHookBuild();
Expand Down Expand Up @@ -725,9 +727,7 @@ private static string BuildOutputPath()
switch (EditorUserBuildSettings.activeBuildTarget)
{
case BuildTarget.StandaloneOSX:
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneLinux:
case BuildTarget.StandaloneWindows64:
case BuildTarget.WebGL:
case BuildTarget.StandaloneLinux64:
Expand Down
4 changes: 2 additions & 2 deletions Editor/Cropping/CroppingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void OnGUI()
else
{
string searchText = _searchText.ToLower();
var types = Utility.Assembly.GetTypes();
var types = AssemblyUtility.GetTypes();
var result = new List<string>();
foreach (var type in types)
{
Expand Down Expand Up @@ -138,7 +138,7 @@ private void OnGUI()
private void Generate(string targetTypeName)
{
_generatedText = string.Empty;
var targetType = Utility.Assembly.GetType(targetTypeName);
var targetType = AssemblyUtility.GetType(targetTypeName);
if (targetType != null)
{
var types = targetType.Assembly.GetTypes();
Expand Down
8 changes: 8 additions & 0 deletions Editor/Extension.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions Editor/Extension/ObjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace GameFrameX.Editor
{
public static class ObjectExtensions
{
public static string GetAssetPath(this Object obj)
{
return AssetDatabase.GetAssetPath(obj);
}

public static string GetAssetGUID(this Object obj)
{
return AssetDatabase.AssetPathToGUID(GetAssetPath(obj));
}

public static Texture2D[] GetMaterialTextures(this Material material)
{
var result = new List<Texture2D>();

var dependencies = EditorUtility.CollectDependencies(new Object[] {material});
foreach (var item in dependencies)
{
if (!(item is Texture2D texture))
{
continue;
}

result.Add(texture);
}

return result.ToArray();
}
}
}
3 changes: 3 additions & 0 deletions Editor/Extension/ObjectExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Editor/Helper.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 45 additions & 9 deletions Runtime/Utility/Utility.cs → Editor/Helper/EditorHelper.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// ==========================================================================================
// ==========================================================================================
// GameFrameX 组织及其衍生项目的版权、商标、专利及其他相关权利
// GameFrameX organization and its derivative projects' copyrights, trademarks, patents, and related rights
// 均受中华人民共和国及相关国际法律法规保护。
// are protected by the laws of the People's Republic of China and relevant international regulations.
//
//
// 使用本项目须严格遵守相应法律法规及开源许可证之规定。
// Usage of this project must strictly comply with applicable laws, regulations, and open-source licenses.
//
//
// 本项目采用 Apache License 2.0 许可证分发,
// This project is licensed under the Apache License 2.0,
// 完整许可证文本请参见源代码根目录下的 LICENSE 文件。
// please refer to the LICENSE file in the root directory of the source code for the full license text.
//
//
// 禁止利用本项目实施任何危害国家安全、破坏社会秩序、
// It is prohibited to use this project to engage in any activities that endanger national security, disrupt social order,
// 侵犯他人合法权益等法律法规所禁止的行为!
Expand All @@ -20,7 +20,7 @@
// Any legal disputes and liabilities arising from secondary development based on this project
// 本项目组织与贡献者概不承担。
// shall be borne solely by the developer; the project organization and contributors assume no responsibility.
//
//
// GitHub 仓库:https://github.com/GameFrameX
// GitHub Repository: https://github.com/GameFrameX
// Gitee 仓库:https://gitee.com/GameFrameX
Expand All @@ -31,15 +31,51 @@
// Official Documentation: https://gameframex.doc.alianblank.com/
// ==========================================================================================

namespace GameFrameX.Runtime
using UnityEditor;
using UnityEngine;

namespace GameFrameX.Editor
{
/// <summary>
/// 实用函数集
/// 编辑器帮助类
/// </summary>
/// <remarks>
/// Utility functions collection.
/// Editor helper class.
/// </remarks>
public static partial class Utility
public static class EditorHelper
{
public static bool DeveloperMode
{
get => EditorPrefs.GetBool("DeveloperMode");
set => EditorPrefs.SetBool("DeveloperMode", value);
}

private static string _projectRoot;
public static string ProjectRoot
{
get
{
if (string.IsNullOrEmpty(_projectRoot))
{
_projectRoot = Application.dataPath.Replace("/Assets", "");
}

return _projectRoot;
}
}

private static string _projectRootWithSplit;
public static string ProjectRootWithSplit
{
get
{
if (string.IsNullOrEmpty(_projectRootWithSplit))
{
_projectRootWithSplit = ProjectRoot + "/";
}

return _projectRootWithSplit;
}
}
}
}
3 changes: 3 additions & 0 deletions Editor/Helper/EditorHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Editor/Inspector/BaseComponentInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void RefreshTypeNames()
NoneOptionName
};

textHelperTypeNames.AddRange(TypeHelper.GetRuntimeTypeNames(typeof(Utility.Text.ITextHelper)));
textHelperTypeNames.AddRange(TypeHelper.GetRuntimeTypeNames(typeof(GameFrameworkText.ITextHelper)));
m_TextHelperTypeNames = textHelperTypeNames.ToArray();
m_TextHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(m_TextHelperTypeName.stringValue))
Expand Down Expand Up @@ -278,7 +278,7 @@ private void RefreshTypeNames()
NoneOptionName
};

compressionHelperTypeNames.AddRange(TypeHelper.GetRuntimeTypeNames(typeof(Utility.Compression.ICompressionHelper)));
compressionHelperTypeNames.AddRange(TypeHelper.GetRuntimeTypeNames(typeof(GameFrameworkCompression.ICompressionHelper)));
m_CompressionHelperTypeNames = compressionHelperTypeNames.ToArray();
m_CompressionHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(m_CompressionHelperTypeName.stringValue))
Expand All @@ -296,7 +296,7 @@ private void RefreshTypeNames()
NoneOptionName
};

jsonHelperTypeNames.AddRange(TypeHelper.GetRuntimeTypeNames(typeof(Utility.Json.IJsonHelper)));
jsonHelperTypeNames.AddRange(TypeHelper.GetRuntimeTypeNames(typeof(GameFrameworkJson.IJsonHelper)));
m_JsonHelperTypeNames = jsonHelperTypeNames.ToArray();
m_JsonHelperTypeNameIndex = 0;
if (!string.IsNullOrEmpty(m_JsonHelperTypeName.stringValue))
Expand Down
2 changes: 1 addition & 1 deletion Editor/Inspector/ComponentTypeComponentInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void RefreshComponentTypeNames(System.Type type)
NoneOptionName
};

managerTypeNames.AddRange(Utility.Assembly.GetRuntimeTypeNames(type));
managerTypeNames.AddRange(AssemblyUtility.GetRuntimeTypeNames(type));
ComponentTypeNames = managerTypeNames.ToArray();
ComponentTypeNameIndex = 0;
if (!ComponentType.stringValue.IsNullOrEmpty())
Expand Down
16 changes: 8 additions & 8 deletions Editor/Inspector/ObjectPoolComponentInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ private void DrawObjectPool(ObjectPoolBase objectPool)
{
EditorGUILayout.LabelField(string.IsNullOrEmpty(objectInfo.Name) ? "<None>" : objectInfo.Name,
objectPool.AllowMultiSpawn
? Utility.Text.Format("{0}\t{1}\t{2}\t{3}\t{4:yyyy-MM-dd HH:mm:ss}", objectInfo.Locked, objectInfo.SpawnCount, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime())
: Utility.Text.Format("{0}\t{1}\t{2}\t{3}\t{4:yyyy-MM-dd HH:mm:ss}", objectInfo.Locked, objectInfo.IsInUse, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime()));
? GameFrameworkText.Format("{0}\t{1}\t{2}\t{3}\t{4:yyyy-MM-dd HH:mm:ss}", objectInfo.Locked, objectInfo.SpawnCount, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime())
: GameFrameworkText.Format("{0}\t{1}\t{2}\t{3}\t{4:yyyy-MM-dd HH:mm:ss}", objectInfo.Locked, objectInfo.IsInUse, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime()));
}

if (GUILayout.Button("Release"))
Expand All @@ -130,27 +130,27 @@ private void DrawObjectPool(ObjectPoolBase objectPool)

if (GUILayout.Button("Export CSV Data"))
{
string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, Utility.Text.Format("Object Pool Data - {0}.csv", objectPool.Name), string.Empty);
string exportFileName = EditorUtility.SaveFilePanel("Export CSV Data", string.Empty, GameFrameworkText.Format("Object Pool Data - {0}.csv", objectPool.Name), string.Empty);
if (!string.IsNullOrEmpty(exportFileName))
{
try
{
int index = 0;
string[] data = new string[objectInfos.Length + 1];
data[index++] = Utility.Text.Format("Name,Locked,{0},Custom Can Release Flag,Priority,Last Use Time", objectPool.AllowMultiSpawn ? "Count" : "In Use");
data[index++] = GameFrameworkText.Format("Name,Locked,{0},Custom Can Release Flag,Priority,Last Use Time", objectPool.AllowMultiSpawn ? "Count" : "In Use");
foreach (ObjectInfo objectInfo in objectInfos)
{
data[index++] = objectPool.AllowMultiSpawn
? Utility.Text.Format("{0},{1},{2},{3},{4},{5:yyyy-MM-dd HH:mm:ss}", objectInfo.Name, objectInfo.Locked, objectInfo.SpawnCount, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime())
: Utility.Text.Format("{0},{1},{2},{3},{4},{5:yyyy-MM-dd HH:mm:ss}", objectInfo.Name, objectInfo.Locked, objectInfo.IsInUse, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime());
? GameFrameworkText.Format("{0},{1},{2},{3},{4},{5:yyyy-MM-dd HH:mm:ss}", objectInfo.Name, objectInfo.Locked, objectInfo.SpawnCount, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime())
: GameFrameworkText.Format("{0},{1},{2},{3},{4},{5:yyyy-MM-dd HH:mm:ss}", objectInfo.Name, objectInfo.Locked, objectInfo.IsInUse, objectInfo.CustomCanReleaseFlag, objectInfo.Priority, objectInfo.LastUseTime.ToLocalTime());
}

File.WriteAllLines(exportFileName, data, Encoding.UTF8);
Debug.Log(Utility.Text.Format("Export object pool CSV data to '{0}' success.", exportFileName));
Debug.Log(GameFrameworkText.Format("Export object pool CSV data to '{0}' success.", exportFileName));
}
catch (Exception exception)
{
Debug.LogError(Utility.Text.Format("Export object pool CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception));
Debug.LogError(GameFrameworkText.Format("Export object pool CSV data to '{0}' failure, exception is '{1}'.", exportFileName, exception));
}
}
}
Expand Down
Loading