[refactor] 少量代码重构

main
walon 2022-10-18 13:51:38 +08:00
parent be4d220529
commit 093f67296a
2 changed files with 43 additions and 43 deletions

View File

@ -8,18 +8,18 @@ namespace HybridCLR.Editor
{ {
public class HybridCLRSettingsProvider : SettingsProvider public class HybridCLRSettingsProvider : SettingsProvider
{ {
private static SerializedObject m_SerializedObject; private static SerializedObject _serializedObject;
private SerializedProperty m_Enable; private SerializedProperty _enable;
private SerializedProperty m_UseGlobalIl2cpp; private SerializedProperty _useGlobalIl2cpp;
private SerializedProperty m_CloneFromGitee; private SerializedProperty _cloneFromGitee;
private SerializedProperty m_HotUpdateAssemblyDefinitions; private SerializedProperty _hotUpdateAssemblyDefinitions;
private SerializedProperty m_HotUpdateAssemblies; private SerializedProperty _hotUpdateAssemblies;
private SerializedProperty m_preserveHotUpdateAssemblies; private SerializedProperty _preserveHotUpdateAssemblies;
private SerializedProperty m_collectAssetReferenceTypes; private SerializedProperty _collectAssetReferenceTypes;
private SerializedProperty m_OutputLinkFile; private SerializedProperty _outputLinkFile;
private SerializedProperty m_OutputAOTGenericReferenceFile; private SerializedProperty _outputAOTGenericReferenceFile;
private SerializedProperty m_MaxGenericReferenceIteration; private SerializedProperty _maxGenericReferenceIteration;
private SerializedProperty m_MaxMethodBridgeGenericIteration; private SerializedProperty _maxMethodBridgeGenericIteration;
private GUIStyle buttonStyle; private GUIStyle buttonStyle;
public HybridCLRSettingsProvider() : base("Project/HybridCLR Settings", SettingsScope.Project) { } public HybridCLRSettingsProvider() : base("Project/HybridCLR Settings", SettingsScope.Project) { }
public override void OnActivate(string searchContext, VisualElement rootElement) public override void OnActivate(string searchContext, VisualElement rootElement)
@ -27,18 +27,18 @@ namespace HybridCLR.Editor
HybridCLRSettings.Instance.Save(); HybridCLRSettings.Instance.Save();
var setting = HybridCLRSettings.Instance; var setting = HybridCLRSettings.Instance;
setting.hideFlags &= ~HideFlags.NotEditable; setting.hideFlags &= ~HideFlags.NotEditable;
m_SerializedObject = m_SerializedObject ?? new SerializedObject(setting); _serializedObject = _serializedObject ?? new SerializedObject(setting);
m_Enable = m_SerializedObject.FindProperty("enable"); _enable = _serializedObject.FindProperty("enable");
m_UseGlobalIl2cpp = m_SerializedObject.FindProperty("useGlobalIl2cpp"); _useGlobalIl2cpp = _serializedObject.FindProperty("useGlobalIl2cpp");
m_CloneFromGitee = m_SerializedObject.FindProperty("cloneFromGitee"); _cloneFromGitee = _serializedObject.FindProperty("cloneFromGitee");
m_HotUpdateAssemblyDefinitions = m_SerializedObject.FindProperty("hotUpdateAssemblyDefinitions"); _hotUpdateAssemblyDefinitions = _serializedObject.FindProperty("hotUpdateAssemblyDefinitions");
m_HotUpdateAssemblies = m_SerializedObject.FindProperty("hotUpdateAssemblies"); _hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies");
m_preserveHotUpdateAssemblies = m_SerializedObject.FindProperty("preserveHotUpdateAssemblies"); _preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies");
m_collectAssetReferenceTypes = m_SerializedObject.FindProperty("collectAssetReferenceTypes"); _collectAssetReferenceTypes = _serializedObject.FindProperty("collectAssetReferenceTypes");
m_OutputLinkFile = m_SerializedObject.FindProperty("outputLinkFile"); _outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
m_OutputAOTGenericReferenceFile = m_SerializedObject.FindProperty("outputAOTGenericReferenceFile"); _outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
m_MaxGenericReferenceIteration = m_SerializedObject.FindProperty("maxGenericReferenceIteration"); _maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
m_MaxMethodBridgeGenericIteration = m_SerializedObject.FindProperty("maxMethodBridgeGenericIteration"); _maxMethodBridgeGenericIteration = _serializedObject.FindProperty("maxMethodBridgeGenericIteration");
} }
public override void OnTitleBarGUI() public override void OnTitleBarGUI()
{ {
@ -94,27 +94,27 @@ namespace HybridCLR.Editor
{ {
using (CreateSettingsWindowGUIScope()) using (CreateSettingsWindowGUIScope())
{ {
if (m_SerializedObject == null || !m_SerializedObject.targetObject) if (_serializedObject == null || !_serializedObject.targetObject)
{ {
m_SerializedObject = null; _serializedObject = null;
m_SerializedObject = new SerializedObject(HybridCLRSettings.Instance); _serializedObject = new SerializedObject(HybridCLRSettings.Instance);
} }
m_SerializedObject.Update(); _serializedObject.Update();
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_Enable); EditorGUILayout.PropertyField(_enable);
EditorGUILayout.PropertyField(m_CloneFromGitee); EditorGUILayout.PropertyField(_cloneFromGitee);
EditorGUILayout.PropertyField(m_UseGlobalIl2cpp); EditorGUILayout.PropertyField(_useGlobalIl2cpp);
EditorGUILayout.PropertyField(m_HotUpdateAssemblyDefinitions); EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
EditorGUILayout.PropertyField(m_HotUpdateAssemblies); EditorGUILayout.PropertyField(_hotUpdateAssemblies);
EditorGUILayout.PropertyField(m_preserveHotUpdateAssemblies); EditorGUILayout.PropertyField(_preserveHotUpdateAssemblies);
EditorGUILayout.PropertyField(m_collectAssetReferenceTypes); EditorGUILayout.PropertyField(_collectAssetReferenceTypes);
EditorGUILayout.PropertyField(m_OutputLinkFile); EditorGUILayout.PropertyField(_outputLinkFile);
EditorGUILayout.PropertyField(m_OutputAOTGenericReferenceFile); EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
EditorGUILayout.PropertyField(m_MaxGenericReferenceIteration); EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
EditorGUILayout.PropertyField(m_MaxMethodBridgeGenericIteration); EditorGUILayout.PropertyField(_maxMethodBridgeGenericIteration);
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck())
{ {
m_SerializedObject.ApplyModifiedProperties(); _serializedObject.ApplyModifiedProperties();
HybridCLRSettings.Instance.Save(); HybridCLRSettings.Instance.Save();
} }
} }
@ -129,7 +129,7 @@ namespace HybridCLR.Editor
{ {
base.OnDeactivate(); base.OnDeactivate();
HybridCLRSettings.Instance.Save(); HybridCLRSettings.Instance.Save();
m_SerializedObject = null; _serializedObject = null;
} }
[SettingsProvider] [SettingsProvider]
public static SettingsProvider CreateMyCustomSettingsProvider() public static SettingsProvider CreateMyCustomSettingsProvider()
@ -138,7 +138,7 @@ namespace HybridCLR.Editor
{ {
var provider = new HybridCLRSettingsProvider var provider = new HybridCLRSettingsProvider
{ {
keywords = GetSearchKeywordsFromSerializedObject(m_SerializedObject = m_SerializedObject ?? new SerializedObject(HybridCLRSettings.Instance)) keywords = GetSearchKeywordsFromSerializedObject(_serializedObject = _serializedObject ?? new SerializedObject(HybridCLRSettings.Instance))
}; };
return provider; return provider;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "com.focus-creative-games.hybridclr_unity", "name": "com.focus-creative-games.hybridclr_unity",
"version": "0.6.0", "version": "0.6.1",
"displayName": "HybridCLR", "displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime", "category": "Runtime",