初始化仓库
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建配置相关的实用函数。
|
||||
/// </summary>
|
||||
internal static class BuildSettings
|
||||
{
|
||||
private static readonly string s_ConfigurationPath = null;
|
||||
private static readonly List<string> s_DefaultSceneNames = new List<string>();
|
||||
private static readonly List<string> s_SearchScenePaths = new List<string>();
|
||||
|
||||
static BuildSettings()
|
||||
{
|
||||
s_ConfigurationPath = Type.GetConfigurationPath<BuildSettingsConfigPathAttribute>() ?? Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameFramework/Configs/BuildSettings.xml"));
|
||||
s_DefaultSceneNames.Clear();
|
||||
s_SearchScenePaths.Clear();
|
||||
|
||||
if (!File.Exists(s_ConfigurationPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(s_ConfigurationPath);
|
||||
XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework");
|
||||
XmlNode xmlBuildSettings = xmlRoot.SelectSingleNode("BuildSettings");
|
||||
XmlNode xmlDefaultScenes = xmlBuildSettings.SelectSingleNode("DefaultScenes");
|
||||
XmlNode xmlSearchScenePaths = xmlBuildSettings.SelectSingleNode("SearchScenePaths");
|
||||
|
||||
XmlNodeList xmlNodeList = null;
|
||||
XmlNode xmlNode = null;
|
||||
|
||||
xmlNodeList = xmlDefaultScenes.ChildNodes;
|
||||
for (int i = 0; i < xmlNodeList.Count; i++)
|
||||
{
|
||||
xmlNode = xmlNodeList.Item(i);
|
||||
if (xmlNode.Name != "DefaultScene")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string defaultSceneName = xmlNode.Attributes.GetNamedItem("Name").Value;
|
||||
s_DefaultSceneNames.Add(defaultSceneName);
|
||||
}
|
||||
|
||||
xmlNodeList = xmlSearchScenePaths.ChildNodes;
|
||||
for (int i = 0; i < xmlNodeList.Count; i++)
|
||||
{
|
||||
xmlNode = xmlNodeList.Item(i);
|
||||
if (xmlNode.Name != "SearchScenePath")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string searchScenePath = xmlNode.Attributes.GetNamedItem("Path").Value;
|
||||
s_SearchScenePaths.Add(searchScenePath);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将构建场景设置为默认。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Scenes in Build Settings/Default Scenes", false, 20)]
|
||||
public static void DefaultScenes()
|
||||
{
|
||||
HashSet<string> sceneNames = new HashSet<string>();
|
||||
foreach (string sceneName in s_DefaultSceneNames)
|
||||
{
|
||||
sceneNames.Add(sceneName);
|
||||
}
|
||||
|
||||
List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>();
|
||||
foreach (string sceneName in sceneNames)
|
||||
{
|
||||
scenes.Add(new EditorBuildSettingsScene(sceneName, true));
|
||||
}
|
||||
|
||||
EditorBuildSettings.scenes = scenes.ToArray();
|
||||
|
||||
Debug.Log("Set scenes of build settings to default scenes.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将构建场景设置为所有。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Scenes in Build Settings/All Scenes", false, 21)]
|
||||
public static void AllScenes()
|
||||
{
|
||||
HashSet<string> sceneNames = new HashSet<string>();
|
||||
foreach (string sceneName in s_DefaultSceneNames)
|
||||
{
|
||||
sceneNames.Add(sceneName);
|
||||
}
|
||||
|
||||
string[] sceneGuids = AssetDatabase.FindAssets("t:Scene", s_SearchScenePaths.ToArray());
|
||||
foreach (string sceneGuid in sceneGuids)
|
||||
{
|
||||
string sceneName = AssetDatabase.GUIDToAssetPath(sceneGuid);
|
||||
sceneNames.Add(sceneName);
|
||||
}
|
||||
|
||||
List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>();
|
||||
foreach (string sceneName in sceneNames)
|
||||
{
|
||||
scenes.Add(new EditorBuildSettingsScene(sceneName, true));
|
||||
}
|
||||
|
||||
EditorBuildSettings.scenes = scenes.ToArray();
|
||||
|
||||
Debug.Log("Set scenes of build settings to all scenes.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b487342e56dd1f649bf6f423bbddd3ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// BuildSettings 配置路径属性。
|
||||
/// </summary>
|
||||
public sealed class BuildSettingsConfigPathAttribute : ConfigPathAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a40d8263d77546c4391f66bcd3865c5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置路径属性。
|
||||
/// </summary>
|
||||
public abstract class ConfigPathAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a44584e09310c440b42613540114652
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 帮助相关的实用函数。
|
||||
/// </summary>
|
||||
public static class Help
|
||||
{
|
||||
[MenuItem("Game Framework/Documentation", false, 90)]
|
||||
public static void ShowDocumentation()
|
||||
{
|
||||
ShowHelp("https://gameframework.cn/document/");
|
||||
}
|
||||
|
||||
[MenuItem("Game Framework/API Reference", false, 91)]
|
||||
public static void ShowApiReference()
|
||||
{
|
||||
ShowHelp("https://gameframework.cn/api/");
|
||||
}
|
||||
|
||||
private static void ShowHelp(string uri)
|
||||
{
|
||||
Application.OpenURL(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a04b26016cce1146887be6cbb81257a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
internal sealed class HelperInfo<T> where T : MonoBehaviour
|
||||
{
|
||||
private const string CustomOptionName = "<Custom>";
|
||||
|
||||
private readonly string m_Name;
|
||||
|
||||
private SerializedProperty m_HelperTypeName;
|
||||
private SerializedProperty m_CustomHelper;
|
||||
private string[] m_HelperTypeNames;
|
||||
private int m_HelperTypeNameIndex;
|
||||
|
||||
public HelperInfo(string name)
|
||||
{
|
||||
m_Name = name;
|
||||
|
||||
m_HelperTypeName = null;
|
||||
m_CustomHelper = null;
|
||||
m_HelperTypeNames = null;
|
||||
m_HelperTypeNameIndex = 0;
|
||||
}
|
||||
|
||||
public void Init(SerializedObject serializedObject)
|
||||
{
|
||||
m_HelperTypeName = serializedObject.FindProperty(Utility.Text.Format("m_{0}HelperTypeName", m_Name));
|
||||
m_CustomHelper = serializedObject.FindProperty(Utility.Text.Format("m_Custom{0}Helper", m_Name));
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
string displayName = FieldNameForDisplay(m_Name);
|
||||
int selectedIndex = EditorGUILayout.Popup(Utility.Text.Format("{0} Helper", displayName), m_HelperTypeNameIndex, m_HelperTypeNames);
|
||||
if (selectedIndex != m_HelperTypeNameIndex)
|
||||
{
|
||||
m_HelperTypeNameIndex = selectedIndex;
|
||||
m_HelperTypeName.stringValue = selectedIndex <= 0 ? null : m_HelperTypeNames[selectedIndex];
|
||||
}
|
||||
|
||||
if (m_HelperTypeNameIndex <= 0)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_CustomHelper);
|
||||
if (m_CustomHelper.objectReferenceValue == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(Utility.Text.Format("You must set Custom {0} Helper.", displayName), MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
List<string> helperTypeNameList = new List<string>
|
||||
{
|
||||
CustomOptionName
|
||||
};
|
||||
|
||||
helperTypeNameList.AddRange(Type.GetRuntimeTypeNames(typeof(T)));
|
||||
m_HelperTypeNames = helperTypeNameList.ToArray();
|
||||
|
||||
m_HelperTypeNameIndex = 0;
|
||||
if (!string.IsNullOrEmpty(m_HelperTypeName.stringValue))
|
||||
{
|
||||
m_HelperTypeNameIndex = helperTypeNameList.IndexOf(m_HelperTypeName.stringValue);
|
||||
if (m_HelperTypeNameIndex <= 0)
|
||||
{
|
||||
m_HelperTypeNameIndex = 0;
|
||||
m_HelperTypeName.stringValue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string FieldNameForDisplay(string fieldName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fieldName))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string str = Regex.Replace(fieldName, @"^m_", string.Empty);
|
||||
str = Regex.Replace(str, @"((?<=[a-z])[A-Z]|[A-Z](?=[a-z]))", @" $1").TrimStart();
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ff85bf9d2c44a14d90f78221024499e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志重定向相关的实用函数。
|
||||
/// </summary>
|
||||
internal static class LogRedirection
|
||||
{
|
||||
private static readonly Regex LogRegex = new Regex(@" \(at (.+)\:(\d+)\)\r?\n");
|
||||
|
||||
[OnOpenAsset(0)]
|
||||
private static bool OnOpenAsset(int instanceId, int line)
|
||||
{
|
||||
string selectedStackTrace = GetSelectedStackTrace();
|
||||
if (string.IsNullOrEmpty(selectedStackTrace))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!selectedStackTrace.Contains("UnityGameFramework.Runtime.DefaultLogHelper:Log"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Match match = LogRegex.Match(selectedStackTrace);
|
||||
if (!match.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!match.Groups[1].Value.Contains("DefaultLogHelper.cs"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
match = match.NextMatch();
|
||||
if (!match.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (match.Groups[1].Value.Contains("GameFrameworkLog.cs"))
|
||||
{
|
||||
match = match.NextMatch();
|
||||
if (!match.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (match.Groups[1].Value.Contains("Log.cs"))
|
||||
{
|
||||
match = match.NextMatch();
|
||||
if (!match.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
InternalEditorUtility.OpenFileAtLineExternal(Path.Combine(Application.dataPath, match.Groups[1].Value.Substring(7)), int.Parse(match.Groups[2].Value));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string GetSelectedStackTrace()
|
||||
{
|
||||
Assembly editorWindowAssembly = typeof(EditorWindow).Assembly;
|
||||
if (editorWindowAssembly == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
System.Type consoleWindowType = editorWindowAssembly.GetType("UnityEditor.ConsoleWindow");
|
||||
if (consoleWindowType == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FieldInfo consoleWindowFieldInfo = consoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
if (consoleWindowFieldInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
EditorWindow consoleWindow = consoleWindowFieldInfo.GetValue(null) as EditorWindow;
|
||||
if (consoleWindow == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (consoleWindow != EditorWindow.focusedWindow)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FieldInfo activeTextFieldInfo = consoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (activeTextFieldInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)activeTextFieldInfo.GetValue(consoleWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb8c486fbd51ec64fab3749895432f7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,179 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志脚本宏定义。
|
||||
/// </summary>
|
||||
public static class LogScriptingDefineSymbols
|
||||
{
|
||||
private const string EnableLogScriptingDefineSymbol = "ENABLE_LOG";
|
||||
private const string EnableDebugAndAboveLogScriptingDefineSymbol = "ENABLE_DEBUG_AND_ABOVE_LOG";
|
||||
private const string EnableInfoAndAboveLogScriptingDefineSymbol = "ENABLE_INFO_AND_ABOVE_LOG";
|
||||
private const string EnableWarningAndAboveLogScriptingDefineSymbol = "ENABLE_WARNING_AND_ABOVE_LOG";
|
||||
private const string EnableErrorAndAboveLogScriptingDefineSymbol = "ENABLE_ERROR_AND_ABOVE_LOG";
|
||||
private const string EnableFatalAndAboveLogScriptingDefineSymbol = "ENABLE_FATAL_AND_ABOVE_LOG";
|
||||
private const string EnableDebugLogScriptingDefineSymbol = "ENABLE_DEBUG_LOG";
|
||||
private const string EnableInfoLogScriptingDefineSymbol = "ENABLE_INFO_LOG";
|
||||
private const string EnableWarningLogScriptingDefineSymbol = "ENABLE_WARNING_LOG";
|
||||
private const string EnableErrorLogScriptingDefineSymbol = "ENABLE_ERROR_LOG";
|
||||
private const string EnableFatalLogScriptingDefineSymbol = "ENABLE_FATAL_LOG";
|
||||
|
||||
private static readonly string[] AboveLogScriptingDefineSymbols = new string[]
|
||||
{
|
||||
EnableDebugAndAboveLogScriptingDefineSymbol,
|
||||
EnableInfoAndAboveLogScriptingDefineSymbol,
|
||||
EnableWarningAndAboveLogScriptingDefineSymbol,
|
||||
EnableErrorAndAboveLogScriptingDefineSymbol,
|
||||
EnableFatalAndAboveLogScriptingDefineSymbol
|
||||
};
|
||||
|
||||
private static readonly string[] SpecifyLogScriptingDefineSymbols = new string[]
|
||||
{
|
||||
EnableDebugLogScriptingDefineSymbol,
|
||||
EnableInfoLogScriptingDefineSymbol,
|
||||
EnableWarningLogScriptingDefineSymbol,
|
||||
EnableErrorLogScriptingDefineSymbol,
|
||||
EnableFatalLogScriptingDefineSymbol
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 禁用所有日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Disable All Logs", false, 30)]
|
||||
public static void DisableAllLogs()
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(EnableLogScriptingDefineSymbol);
|
||||
|
||||
foreach (string specifyLogScriptingDefineSymbol in SpecifyLogScriptingDefineSymbols)
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(specifyLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
foreach (string aboveLogScriptingDefineSymbol in AboveLogScriptingDefineSymbols)
|
||||
{
|
||||
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(aboveLogScriptingDefineSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启所有日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Enable All Logs", false, 31)]
|
||||
public static void EnableAllLogs()
|
||||
{
|
||||
DisableAllLogs();
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(EnableLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启调试及以上级别的日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Enable Debug And Above Logs", false, 32)]
|
||||
public static void EnableDebugAndAboveLogs()
|
||||
{
|
||||
SetAboveLogScriptingDefineSymbol(EnableDebugAndAboveLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启信息及以上级别的日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Enable Info And Above Logs", false, 33)]
|
||||
public static void EnableInfoAndAboveLogs()
|
||||
{
|
||||
SetAboveLogScriptingDefineSymbol(EnableInfoAndAboveLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启警告及以上级别的日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Enable Warning And Above Logs", false, 34)]
|
||||
public static void EnableWarningAndAboveLogs()
|
||||
{
|
||||
SetAboveLogScriptingDefineSymbol(EnableWarningAndAboveLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启错误及以上级别的日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Enable Error And Above Logs", false, 35)]
|
||||
public static void EnableErrorAndAboveLogs()
|
||||
{
|
||||
SetAboveLogScriptingDefineSymbol(EnableErrorAndAboveLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启严重错误及以上级别的日志脚本宏定义。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Log Scripting Define Symbols/Enable Fatal And Above Logs", false, 36)]
|
||||
public static void EnableFatalAndAboveLogs()
|
||||
{
|
||||
SetAboveLogScriptingDefineSymbol(EnableFatalAndAboveLogScriptingDefineSymbol);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置日志脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="aboveLogScriptingDefineSymbol">要设置的日志脚本宏定义。</param>
|
||||
public static void SetAboveLogScriptingDefineSymbol(string aboveLogScriptingDefineSymbol)
|
||||
{
|
||||
if (string.IsNullOrEmpty(aboveLogScriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string i in AboveLogScriptingDefineSymbols)
|
||||
{
|
||||
if (i == aboveLogScriptingDefineSymbol)
|
||||
{
|
||||
DisableAllLogs();
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(aboveLogScriptingDefineSymbol);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置日志脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="specifyLogScriptingDefineSymbols">要设置的日志脚本宏定义。</param>
|
||||
public static void SetSpecifyLogScriptingDefineSymbols(string[] specifyLogScriptingDefineSymbols)
|
||||
{
|
||||
if (specifyLogScriptingDefineSymbols == null || specifyLogScriptingDefineSymbols.Length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool removed = false;
|
||||
foreach (string specifyLogScriptingDefineSymbol in specifyLogScriptingDefineSymbols)
|
||||
{
|
||||
if (string.IsNullOrEmpty(specifyLogScriptingDefineSymbol))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (string i in SpecifyLogScriptingDefineSymbols)
|
||||
{
|
||||
if (i == specifyLogScriptingDefineSymbol)
|
||||
{
|
||||
if (!removed)
|
||||
{
|
||||
removed = true;
|
||||
DisableAllLogs();
|
||||
}
|
||||
|
||||
ScriptingDefineSymbols.AddScriptingDefineSymbol(specifyLogScriptingDefineSymbol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b5eed5f56efa7e4cb245bee9b064c21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System.Diagnostics;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开文件夹相关的实用函数。
|
||||
/// </summary>
|
||||
public static class OpenFolder
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开 Data Path 文件夹。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Open Folder/Data Path", false, 10)]
|
||||
public static void OpenFolderDataPath()
|
||||
{
|
||||
Execute(Application.dataPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开 Persistent Data Path 文件夹。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Open Folder/Persistent Data Path", false, 11)]
|
||||
public static void OpenFolderPersistentDataPath()
|
||||
{
|
||||
Execute(Application.persistentDataPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开 Streaming Assets Path 文件夹。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Open Folder/Streaming Assets Path", false, 12)]
|
||||
public static void OpenFolderStreamingAssetsPath()
|
||||
{
|
||||
Execute(Application.streamingAssetsPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开 Temporary Cache Path 文件夹。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Open Folder/Temporary Cache Path", false, 13)]
|
||||
public static void OpenFolderTemporaryCachePath()
|
||||
{
|
||||
Execute(Application.temporaryCachePath);
|
||||
}
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
|
||||
/// <summary>
|
||||
/// 打开 Console Log Path 文件夹。
|
||||
/// </summary>
|
||||
[MenuItem("Game Framework/Open Folder/Console Log Path", false, 14)]
|
||||
public static void OpenFolderConsoleLogPath()
|
||||
{
|
||||
Execute(System.IO.Path.GetDirectoryName(Application.consoleLogPath));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 打开指定路径的文件夹。
|
||||
/// </summary>
|
||||
/// <param name="folder">要打开的文件夹的路径。</param>
|
||||
public static void Execute(string folder)
|
||||
{
|
||||
folder = Utility.Text.Format("\"{0}\"", folder);
|
||||
switch (Application.platform)
|
||||
{
|
||||
case RuntimePlatform.WindowsEditor:
|
||||
Process.Start("Explorer.exe", folder.Replace('/', '\\'));
|
||||
break;
|
||||
|
||||
case RuntimePlatform.OSXEditor:
|
||||
Process.Start("open", folder);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new GameFrameworkException(Utility.Text.Format("Not support open folder on '{0}' platform.", Application.platform));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62e84f6e8237ea540b348d07a13891c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 脚本宏定义。
|
||||
/// </summary>
|
||||
public static class ScriptingDefineSymbols
|
||||
{
|
||||
private static readonly BuildTargetGroup[] BuildTargetGroups = new BuildTargetGroup[]
|
||||
{
|
||||
BuildTargetGroup.Standalone,
|
||||
BuildTargetGroup.iOS,
|
||||
BuildTargetGroup.Android,
|
||||
BuildTargetGroup.WSA,
|
||||
BuildTargetGroup.WebGL
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 检查指定平台是否存在指定的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="buildTargetGroup">要检查脚本宏定义的平台。</param>
|
||||
/// <param name="scriptingDefineSymbol">要检查的脚本宏定义。</param>
|
||||
/// <returns>指定平台是否存在指定的脚本宏定义。</returns>
|
||||
public static bool HasScriptingDefineSymbol(BuildTargetGroup buildTargetGroup, string scriptingDefineSymbol)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scriptingDefineSymbol))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string[] scriptingDefineSymbols = GetScriptingDefineSymbols(buildTargetGroup);
|
||||
foreach (string i in scriptingDefineSymbols)
|
||||
{
|
||||
if (i == scriptingDefineSymbol)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为指定平台增加指定的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="buildTargetGroup">要增加脚本宏定义的平台。</param>
|
||||
/// <param name="scriptingDefineSymbol">要增加的脚本宏定义。</param>
|
||||
public static void AddScriptingDefineSymbol(BuildTargetGroup buildTargetGroup, string scriptingDefineSymbol)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> scriptingDefineSymbols = new List<string>(GetScriptingDefineSymbols(buildTargetGroup))
|
||||
{
|
||||
scriptingDefineSymbol
|
||||
};
|
||||
|
||||
SetScriptingDefineSymbols(buildTargetGroup, scriptingDefineSymbols.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为指定平台移除指定的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="buildTargetGroup">要移除脚本宏定义的平台。</param>
|
||||
/// <param name="scriptingDefineSymbol">要移除的脚本宏定义。</param>
|
||||
public static void RemoveScriptingDefineSymbol(BuildTargetGroup buildTargetGroup, string scriptingDefineSymbol)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> scriptingDefineSymbols = new List<string>(GetScriptingDefineSymbols(buildTargetGroup));
|
||||
while (scriptingDefineSymbols.Contains(scriptingDefineSymbol))
|
||||
{
|
||||
scriptingDefineSymbols.Remove(scriptingDefineSymbol);
|
||||
}
|
||||
|
||||
SetScriptingDefineSymbols(buildTargetGroup, scriptingDefineSymbols.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为所有平台增加指定的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="scriptingDefineSymbol">要增加的脚本宏定义。</param>
|
||||
public static void AddScriptingDefineSymbol(string scriptingDefineSymbol)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (BuildTargetGroup buildTargetGroup in BuildTargetGroups)
|
||||
{
|
||||
AddScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为所有平台移除指定的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="scriptingDefineSymbol">要移除的脚本宏定义。</param>
|
||||
public static void RemoveScriptingDefineSymbol(string scriptingDefineSymbol)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scriptingDefineSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (BuildTargetGroup buildTargetGroup in BuildTargetGroups)
|
||||
{
|
||||
RemoveScriptingDefineSymbol(buildTargetGroup, scriptingDefineSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定平台的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="buildTargetGroup">要获取脚本宏定义的平台。</param>
|
||||
/// <returns>平台的脚本宏定义。</returns>
|
||||
public static string[] GetScriptingDefineSymbols(BuildTargetGroup buildTargetGroup)
|
||||
{
|
||||
return PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup).Split(';');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定平台的脚本宏定义。
|
||||
/// </summary>
|
||||
/// <param name="buildTargetGroup">要设置脚本宏定义的平台。</param>
|
||||
/// <param name="scriptingDefineSymbols">要设置的脚本宏定义。</param>
|
||||
public static void SetScriptingDefineSymbols(BuildTargetGroup buildTargetGroup, string[] scriptingDefineSymbols)
|
||||
{
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", scriptingDefineSymbols));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99eaa7f830bac2c469f9aab52406b8ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityGameFramework.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型相关的实用函数。
|
||||
/// </summary>
|
||||
internal static class Type
|
||||
{
|
||||
private static readonly string[] RuntimeAssemblyNames =
|
||||
{
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
"UnityGameFramework.Runtime",
|
||||
#endif
|
||||
"Assembly-CSharp",
|
||||
};
|
||||
|
||||
private static readonly string[] RuntimeOrEditorAssemblyNames =
|
||||
{
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
"UnityGameFramework.Runtime",
|
||||
#endif
|
||||
"Assembly-CSharp",
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
"UnityGameFramework.Editor",
|
||||
#endif
|
||||
"Assembly-CSharp-Editor",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 获取配置路径。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">配置类型。</typeparam>
|
||||
/// <returns>配置路径。</returns>
|
||||
internal static string GetConfigurationPath<T>() where T : ConfigPathAttribute
|
||||
{
|
||||
foreach (System.Type type in Utility.Assembly.GetTypes())
|
||||
{
|
||||
if (!type.IsAbstract || !type.IsSealed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
|
||||
{
|
||||
if (fieldInfo.FieldType == typeof(string) && fieldInfo.IsDefined(typeof(T), false))
|
||||
{
|
||||
return (string)fieldInfo.GetValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
|
||||
{
|
||||
if (propertyInfo.PropertyType == typeof(string) && propertyInfo.IsDefined(typeof(T), false))
|
||||
{
|
||||
return (string)propertyInfo.GetValue(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在运行时程序集中获取指定基类的所有子类的名称。
|
||||
/// </summary>
|
||||
/// <param name="typeBase">基类类型。</param>
|
||||
/// <returns>指定基类的所有子类的名称。</returns>
|
||||
internal static string[] GetRuntimeTypeNames(System.Type typeBase)
|
||||
{
|
||||
return GetTypeNames(typeBase, RuntimeAssemblyNames);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在运行时或编辑器程序集中获取指定基类的所有子类的名称。
|
||||
/// </summary>
|
||||
/// <param name="typeBase">基类类型。</param>
|
||||
/// <returns>指定基类的所有子类的名称。</returns>
|
||||
internal static string[] GetRuntimeOrEditorTypeNames(System.Type typeBase)
|
||||
{
|
||||
return GetTypeNames(typeBase, RuntimeOrEditorAssemblyNames);
|
||||
}
|
||||
|
||||
private static string[] GetTypeNames(System.Type typeBase, string[] assemblyNames)
|
||||
{
|
||||
List<string> typeNames = new List<string>();
|
||||
foreach (string assemblyName in assemblyNames)
|
||||
{
|
||||
Assembly assembly = null;
|
||||
try
|
||||
{
|
||||
assembly = Assembly.Load(assemblyName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (assembly == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
System.Type[] types = assembly.GetTypes();
|
||||
foreach (System.Type type in types)
|
||||
{
|
||||
if (type.IsClass && !type.IsAbstract && typeBase.IsAssignableFrom(type))
|
||||
{
|
||||
typeNames.Add(type.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typeNames.Sort();
|
||||
return typeNames.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82f73088e6e538649abbb7e35e3d6bf5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user