C#: Allow exporting games without C#
When exporting a game that contains a C# solution, a feature is added so the exported game can check if it should initialize the .NET module. Otherwise, the module initialization is skipped so games without C# won't check for the assemblies and won't show alerts when they're missing.
This commit is contained in:
parent
a574c0296b
commit
be1dfd3b3a
|
@ -121,16 +121,16 @@ void CSharpLanguage::init() {
|
||||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "dotnet/project/assembly_reload_attempts", PROPERTY_HINT_RANGE, "1,16,1,or_greater"), 3);
|
GLOBAL_DEF(PropertyInfo(Variant::INT, "dotnet/project/assembly_reload_attempts", PROPERTY_HINT_RANGE, "1,16,1,or_greater"), 3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gdmono = memnew(GDMono);
|
|
||||||
gdmono->initialize();
|
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
if (gdmono->is_runtime_initialized()) {
|
|
||||||
gdmono->initialize_load_assemblies();
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorNode::add_init_callback(&_editor_init_callback);
|
EditorNode::add_init_callback(&_editor_init_callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gdmono = memnew(GDMono);
|
||||||
|
|
||||||
|
// Initialize only if the project uses C#.
|
||||||
|
if (gdmono->should_initialize()) {
|
||||||
|
gdmono->initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSharpLanguage::finish() {
|
void CSharpLanguage::finish() {
|
||||||
|
|
|
@ -20,6 +20,19 @@ namespace GodotTools.Export
|
||||||
|
|
||||||
private List<string> _tempFolders = new List<string>();
|
private List<string> _tempFolders = new List<string>();
|
||||||
|
|
||||||
|
private static bool ProjectContainsDotNet()
|
||||||
|
{
|
||||||
|
return File.Exists(GodotSharpDirs.ProjectSlnPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string[] _GetExportFeatures(EditorExportPlatform platform, bool debug)
|
||||||
|
{
|
||||||
|
if (!ProjectContainsDotNet())
|
||||||
|
return Array.Empty<string>();
|
||||||
|
|
||||||
|
return new string[] { "dotnet" };
|
||||||
|
}
|
||||||
|
|
||||||
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetExportOptions(EditorExportPlatform platform)
|
public override Godot.Collections.Array<Godot.Collections.Dictionary> _GetExportOptions(EditorExportPlatform platform)
|
||||||
{
|
{
|
||||||
return new Godot.Collections.Array<Godot.Collections.Dictionary>()
|
return new Godot.Collections.Array<Godot.Collections.Dictionary>()
|
||||||
|
@ -119,7 +132,7 @@ namespace GodotTools.Export
|
||||||
{
|
{
|
||||||
_ = flags; // Unused.
|
_ = flags; // Unused.
|
||||||
|
|
||||||
if (!File.Exists(GodotSharpDirs.ProjectSlnPath))
|
if (!ProjectContainsDotNet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!DeterminePlatformFromFeatures(features, out string platform))
|
if (!DeterminePlatformFromFeatures(features, out string platform))
|
||||||
|
|
|
@ -348,6 +348,15 @@ godot_plugins_initialize_fn try_load_native_aot_library(void *&r_aot_dll_handle)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
bool GDMono::should_initialize() {
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
// The editor always needs to initialize the .NET module for now.
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return OS::get_singleton()->has_feature("dotnet");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static bool _on_core_api_assembly_loaded() {
|
static bool _on_core_api_assembly_loaded() {
|
||||||
if (!GDMonoCache::godot_api_cache_updated) {
|
if (!GDMonoCache::godot_api_cache_updated) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -435,11 +444,15 @@ void GDMono::initialize() {
|
||||||
|
|
||||||
_on_core_api_assembly_loaded();
|
_on_core_api_assembly_loaded();
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
_try_load_project_assembly();
|
||||||
|
#endif
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
void GDMono::initialize_load_assemblies() {
|
void GDMono::_try_load_project_assembly() {
|
||||||
if (Engine::get_singleton()->is_project_manager_hint()) {
|
if (Engine::get_singleton()->is_project_manager_hint()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ class GDMono {
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
bool _load_project_assembly();
|
bool _load_project_assembly();
|
||||||
|
void _try_load_project_assembly();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint64_t api_core_hash = 0;
|
uint64_t api_core_hash = 0;
|
||||||
|
@ -149,10 +150,9 @@ public:
|
||||||
Error reload_project_assemblies();
|
Error reload_project_assemblies();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool should_initialize();
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
void initialize_load_assemblies();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GDMono();
|
GDMono();
|
||||||
~GDMono();
|
~GDMono();
|
||||||
|
|
Loading…
Reference in New Issue