@@ -470,7 +470,7 @@
|
|
470
470
|
|
471
471
|
|
472
472
|
/** @internal */
|
473
|
-
__internalEnable(): boolean {
|
473
|
+
__internalEnable(isAddingToScene?: boolean): boolean {
|
474
474
|
if (this.__destroyed) {
|
475
475
|
if (isDevEnvironment()) {
|
476
476
|
console.warn("[Needle Engine Dev] Trying to enable destroyed component");
|
@@ -481,7 +481,10 @@
|
|
481
481
|
// But a user can change enable during awake
|
482
482
|
if (!this.__didAwake) return false;
|
483
483
|
if (this.__didEnable) {
|
484
|
-
|
484
|
+
// We dont want to change the enable state if we are adding to scene
|
485
|
+
// But we want to change the state when e.g. a user changes the enable state during awake
|
486
|
+
if (isAddingToScene !== true)
|
487
|
+
this.__isEnabled = true;
|
485
488
|
return false;
|
486
489
|
}
|
487
490
|
// console.trace("INTERNAL ENABLE");
|
@@ -492,12 +495,14 @@
|
|
492
495
|
}
|
493
496
|
|
494
497
|
/** @internal */
|
495
|
-
__internalDisable() {
|
498
|
+
__internalDisable(isRemovingFromScene?: boolean) {
|
496
499
|
// Don't change enable before awake
|
497
500
|
// But a user can change enable during awake
|
498
501
|
if (!this.__didAwake) return;
|
499
502
|
if (!this.__didEnable) {
|
500
|
-
|
503
|
+
// We dont want to change the enable state if we are removing from a scene
|
504
|
+
if (isRemovingFromScene !== true)
|
505
|
+
this.__isEnabled = false;
|
501
506
|
return;
|
502
507
|
}
|
503
508
|
this.__didEnable = false;
|
@@ -34,6 +34,7 @@
|
|
34
34
|
const stats = utils.getParam("stats");
|
35
35
|
const debugActive = utils.getParam("debugactive");
|
36
36
|
const debugframerate = utils.getParam("debugframerate");
|
37
|
+
const debugCoroutine = utils.getParam("debugcoroutine");
|
37
38
|
|
38
39
|
// this is where functions that setup unity scenes will be pushed into
|
39
40
|
// those will be accessed from our custom html element to load them into their context
|
@@ -859,6 +860,7 @@
|
|
859
860
|
// TODO we might want to keep coroutines playing even if the component is disabled or inactive
|
860
861
|
const remove = !evt.comp || evt.comp.destroyed || !evt.main || evt.comp["enabled"] === false;
|
861
862
|
if (remove) {
|
863
|
+
if (debugCoroutine) console.log("Removing coroutine", evt.comp, evt.comp["enabled"])
|
862
864
|
evts.splice(i, 1);
|
863
865
|
--i;
|
864
866
|
continue;
|
@@ -150,7 +150,7 @@
|
|
150
150
|
|
151
151
|
export function processRemoveFromScene(script: IComponent) {
|
152
152
|
if (!script) return;
|
153
|
-
script.__internalDisable();
|
153
|
+
script.__internalDisable(true);
|
154
154
|
removeScriptFromContext(script, script.context);
|
155
155
|
}
|
156
156
|
|
@@ -123,9 +123,9 @@
|
|
123
123
|
/** @internal */
|
124
124
|
__internalStart();
|
125
125
|
/** @internal */
|
126
|
-
__internalEnable();
|
126
|
+
__internalEnable(isAddingOrRemovingFromScene?: boolean);
|
127
127
|
/** @internal */
|
128
|
-
__internalDisable();
|
128
|
+
__internalDisable(isAddingOrRemovingFromScene?: boolean);
|
129
129
|
/** @internal */
|
130
130
|
__internalDestroy();
|
131
131
|
/** @internal */
|