Skip to content

Commit

Permalink
Merge pull request Alex-Rachel#91 from mi1890/main
Browse files Browse the repository at this point in the history
* [fix] installed  as a  package ,class not found issue
  • Loading branch information
Alex-Rachel authored Aug 8, 2024
2 parents 5a883bc + 650469a commit c7fad13
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,23 @@ public static void Generate()
EventInterfaceGenerateTag.HadGenerate = true;

// 加载程序集
Assembly assembly = typeof(GameApp).Assembly;
Assembly assembly = null;
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{
foreach(var type in asm.GetTypes())
{
if (type.Name == "GameApp")
{
assembly = asm;
break;
}
}
}
if(assembly == null)
{
Debug.LogError("Game App Class Not Found");
return;
}

// 获取程序集中的所有类型
Type[] types = assembly.GetTypes();
Expand Down
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 c7fad13

Please sign in to comment.