Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions GDJS/Runtime/InGameEditor/InGameEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3347,6 +3347,15 @@ namespace gdjs {
return !!instanceData && !!instanceData.sealed;
}

/**
* Instances hidden at start stay visible in the editor, but extensions
* can use this to disable what can't be shown as "hidden" (like lights).
*/
isInstanceHiddenAtStart(object: gdjs.RuntimeObject): boolean {
const instanceData = this._getInstanceData(object.persistentUuid);
return !!instanceData && !!instanceData.hidden;
}

private _addInstances(addedInstances: Array<InstanceData>) {
for (const addedInstance of addedInstances) {
this._editedInstanceDataList.push(addedInstance);
Expand Down Expand Up @@ -3804,6 +3813,7 @@ namespace gdjs {
);
}
runtimeObject.extraInitializationFromInitialInstance(instance);
gdjs.RuntimeObject.applyInGameEditorMinimumOpacity(runtimeObject);
}
});
this._updateInstances(instances);
Expand Down
3 changes: 3 additions & 0 deletions GDJS/Runtime/RuntimeInstanceContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ namespace gdjs {
.getVariables()
.initFrom(instanceData.initialVariables, true);
newObject.extraInitializationFromInitialInstance(instanceData);
if (this.getGame().isInGameEdition()) {
gdjs.RuntimeObject.applyInGameEditorMinimumOpacity(newObject);
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions GDJS/Runtime/debugger-client/hot-reloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,9 @@ namespace gdjs {
);
if (numberPropertiesChanged || stringPropertiesChanged || sizeChanged) {
runtimeObject.extraInitializationFromInitialInstance(newInstance);
if (this._runtimeGame.isInGameEdition()) {
gdjs.RuntimeObject.applyInGameEditorMinimumOpacity(runtimeObject);
}
somethingChanged = true;
}
if (somethingChanged) {
Expand Down
16 changes: 16 additions & 0 deletions GDJS/Runtime/runtimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,22 @@ namespace gdjs {

static supportsReinitialization = false;

/**
* Like in the 2D editor, transparent instances stay partially visible in
* the in-game editor so they can't be lost or misplaced.
*/
static applyInGameEditorMinimumOpacity(object: gdjs.RuntimeObject): void {
const objectWithOpacity = object as gdjs.RuntimeObject &
Partial<gdjs.OpacityHandler>;
if (!objectWithOpacity.getOpacity || !objectWithOpacity.setOpacity) {
return;
}
const minimumOpacity = 255 / 2;
if (objectWithOpacity.getOpacity() < minimumOpacity) {
objectWithOpacity.setOpacity(minimumOpacity);
}
}

/**
* Return the time elapsed since the last frame,
* in milliseconds, for the object.
Expand Down
Loading