Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions newIDE/app/src/EventsFunctionsExtensionsLoader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ const loadProjectEventsFunctionsExtension = (
};

/**
* Get the list of mandatory include files when using the
* extension.
* Get include files for extension lifecycle functions (onFirstSceneLoaded,
* onSceneLoaded, etc.) that self-register at load time and are never
* referenced via event sheet instructions. Non-lifecycle free functions
* are included only when actually referenced (transitive deps resolved
* during code generation).
*/
const getExtensionIncludeFiles = (
project: gdProject,
Expand All @@ -119,6 +122,14 @@ const getExtensionIncludeFiles = (
return mapFor(0, freeEventsFunctions.getEventsFunctionsCount(), i => {
const eventsFunction = freeEventsFunctions.getEventsFunctionAt(i);

if (
!gd.MetadataDeclarationHelper.isExtensionLifecycleEventsFunction(
eventsFunction.getName()
)
) {
return null;
}

const functionName = gd.MetadataDeclarationHelper.getFreeFunctionCodeName(
eventsFunctionsExtension,
eventsFunction
Expand Down Expand Up @@ -401,7 +412,7 @@ const generateFreeFunctionMetadata = (
);
instructionOrExpression.addIncludeFile(functionFile);

// Always include the extension include files when using a free function.
// Include lifecycle function files so they self-register when the extension is loaded.
codeGenerationContext.extensionIncludeFiles.forEach(includeFile => {
instructionOrExpression.addIncludeFile(includeFile);
});
Expand Down Expand Up @@ -511,7 +522,7 @@ function generateBehaviorMetadata(

behaviorMetadata.addIncludeFile(includeFile);

// Always include the extension include files when using a behavior.
// Include lifecycle function files so they self-register when the extension is loaded.
codeGenerationContext.extensionIncludeFiles.forEach(includeFile => {
behaviorMetadata.addIncludeFile(includeFile);
});
Expand Down Expand Up @@ -615,7 +626,7 @@ function generateObjectMetadata(
// Objects may already have included files for 3D for instance.
objectMetadata.addIncludeFile(includeFile);

// Always include the extension include files when using an object.
// Include lifecycle function files so they self-register when the extension is loaded.
codeGenerationContext.extensionIncludeFiles.forEach(includeFile => {
objectMetadata.addIncludeFile(includeFile);
});
Expand Down