Needle Engine

Changes between version 3.2.10-alpha and 3.2.11-alpha
Files changed (2) hide show
  1. src/engine/engine_mainloop_utils.ts +9 -6
  2. src/engine/extensions/NEEDLE_lighting_settings.ts +2 -2
src/engine/engine_mainloop_utils.ts CHANGED
@@ -167,11 +167,14 @@
167
167
  // keep them in queue until script has started
168
168
  // call awake if the script was inactive before
169
169
  utils.safeInvoke(script.__internalAwake.bind(script));
170
- utils.safeInvoke(script.__internalEnable.bind(script));
171
- // now call start
172
- utils.safeInvoke(script.__internalStart.bind(script));
173
- context.new_script_start.splice(i, 1);
174
- i--;
170
+ if(script.enabled)
171
+ {
172
+ utils.safeInvoke(script.__internalEnable.bind(script));
173
+ // now call start
174
+ utils.safeInvoke(script.__internalStart.bind(script));
175
+ context.new_script_start.splice(i, 1);
176
+ i--;
177
+ }
175
178
  }
176
179
  catch (err) {
177
180
  console.error(err);
@@ -274,7 +277,7 @@
274
277
  }
275
278
  }
276
279
  else {
277
- if (comp["__didAwake"]) {
280
+ if (comp["__didAwake"] && comp.enabled) {
278
281
  comp["__didEnable"] = false;
279
282
  comp.onDisable();
280
283
  }
src/engine/extensions/NEEDLE_lighting_settings.ts CHANGED
@@ -75,7 +75,7 @@
75
75
  ContextRegistry.registerCallback(ContextEvent.ContextCreated, e => {
76
76
  const ctx = e.context as Context;
77
77
  const lightingSettings = GameObject.findObjectOfType(SceneLightSettings, ctx as Context);
78
- if (lightingSettings?.sourceId) ctx.sceneLighting.enable(lightingSettings.sourceId);
78
+ if (lightingSettings?.sourceId) lightingSettings.enabled = true;
79
79
  })
80
80
 
81
81
  // exists once per gltf scene root (if it contains reflection)
@@ -130,7 +130,7 @@
130
130
  }
131
131
 
132
132
  onEnable(): void {
133
- if (debug) console.warn("💡🟡 >>> Enable lighting", this.sourceId, this);
133
+ if (debug) console.warn("💡🟡 >>> Enable lighting", this.sourceId, this.enabled, this);
134
134
 
135
135
  if (this.ambientMode == AmbientMode.Flat) {
136
136
  if (this.ambientLight && !this._ambientLightObj) {