Skip to content

Commit

Permalink
* support package mode tengine setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mi1890 committed Aug 8, 2024
1 parent c7c00ea commit 650469a
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ public class TEngineSettingsProvider : SettingsProvider
private const string headerName = "TEngine/TEngineSettings";
private SerializedObject m_CustomSettings;

private static string m_SettingsPath = k_SettingsPath;
internal static SerializedObject GetSerializedSettings()
{
return new SerializedObject(SettingsUtils.GlobalSettings);
}

public static bool IsSettingsAvailable()
{
return File.Exists(k_SettingsPath);
var pathes = AssetDatabase.FindAssets("TEngineGlobalSettings", new string[2] { k_SettingsPath,"Packages/com.tengine/" });
if (pathes.Length > 0)
{
m_SettingsPath = AssetDatabase.GUIDToAssetPath(pathes[0]);
}
return pathes.Length > 0;
}

public override void OnActivate(string searchContext, VisualElement rootElement)
Expand All @@ -29,16 +35,16 @@ public override void OnActivate(string searchContext, VisualElement rootElement)
public override void OnDeactivate()
{
base.OnDeactivate();
SaveAssetData(k_SettingsPath);
SaveAssetData(m_SettingsPath);
}

void SaveAssetData(string path)
{
TEngineSettings old = AssetDatabase.LoadAssetAtPath<TEngineSettings>(k_SettingsPath);
TEngineSettings old = AssetDatabase.LoadAssetAtPath<TEngineSettings>(m_SettingsPath);
TEngineSettings data = ScriptableObject.CreateInstance<TEngineSettings>();
data.Set(old.FrameworkGlobalSettings, old.BybridCLRCustomGlobalSettings);
AssetDatabase.DeleteAsset(path);
AssetDatabase.CreateAsset(data, path);
AssetDatabase.CreateAsset(data, path);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
Expand Down

0 comments on commit 650469a

Please sign in to comment.