mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
[opt]
中文:优化设置界面的tab切换,页面数据保存逻辑 English: Optimize tab switching and page data saving logic in the settings interface
This commit is contained in:
@@ -35,18 +35,36 @@ public class TEngineSettingsProvider : SettingsProvider
|
|||||||
public override void OnDeactivate()
|
public override void OnDeactivate()
|
||||||
{
|
{
|
||||||
base.OnDeactivate();
|
base.OnDeactivate();
|
||||||
SaveAssetData(m_SettingsPath);
|
|
||||||
|
// 确保只有在有修改时才保存
|
||||||
|
if (m_CustomSettings != null && m_CustomSettings.hasModifiedProperties)
|
||||||
|
{
|
||||||
|
EditorApplication.delayCall += () => SaveAssetData(k_SettingsPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveAssetData(string path)
|
void SaveAssetData(string path)
|
||||||
{
|
{
|
||||||
TEngineSettings old = AssetDatabase.LoadAssetAtPath<TEngineSettings>(m_SettingsPath);
|
TEngineSettings old = AssetDatabase.LoadAssetAtPath<TEngineSettings>(k_SettingsPath);
|
||||||
|
if (old == null)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Failed to load TEngineSettings from path: {k_SettingsPath}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TEngineSettings data = ScriptableObject.CreateInstance<TEngineSettings>();
|
TEngineSettings data = ScriptableObject.CreateInstance<TEngineSettings>();
|
||||||
data.Set(old.FrameworkGlobalSettings, old.BybridCLRCustomGlobalSettings);
|
data.Set(old.FrameworkGlobalSettings, old.BybridCLRCustomGlobalSettings);
|
||||||
AssetDatabase.DeleteAsset(path);
|
|
||||||
AssetDatabase.CreateAsset(data, path);
|
if (AssetDatabase.DeleteAsset(path))
|
||||||
AssetDatabase.SaveAssets();
|
{
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.CreateAsset(data, path);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError($"Failed to delete existing asset at path: {path}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user