diff --git a/cocos/core/components/ui-base/ui-component.ts b/cocos/core/components/ui-base/ui-component.ts index f6503e7109..8644a53f53 100644 --- a/cocos/core/components/ui-base/ui-component.ts +++ b/cocos/core/components/ui-base/ui-component.ts @@ -84,18 +84,26 @@ export class UIComponent extends Component { protected _followScreen: CanvasComponent | null = null; private _lastParent: INode | null = null; + + public __preload () { + this.node._uiComp = this; + } + public onEnable () { this._lastParent = this.node.parent; this._updateVisibility(); + if (this._lastParent) { this.node.on(SystemEventType.CHILD_REMOVED, this._parentChanged, this); } - this.node._uiComp = this; this._sortSiblings(); } public onDisable () { this._cancelEventFromParent(); + } + + public onDestroy () { if (this.node._uiComp === this) { this.node._uiComp = null; } diff --git a/cocos/core/components/ui-base/ui-render-component.ts b/cocos/core/components/ui-base/ui-render-component.ts index 7d9ca8b51d..49f2f5fa24 100644 --- a/cocos/core/components/ui-base/ui-render-component.ts +++ b/cocos/core/components/ui-base/ui-render-component.ts @@ -196,6 +196,11 @@ export class UIRenderComponent extends UIComponent { return this._renderData; } + // Render data can be submitted even if it is not on the node tree + set simulate (value) { + this._simulate = value; + } + public static BlendState = GFXBlendFactor; public static Assembler: IAssemblerManager | null = null; public static PostAssembler: IAssemblerManager | null = null; @@ -230,8 +235,10 @@ export class UIRenderComponent extends UIComponent { depthStencilState: {}, rasterizerState: {}, }; + protected _simulate = false; public __preload (){ + super.__preload(); this._instanceMaterial(); if (this._flushAssembler){ this._flushAssembler(); @@ -253,6 +260,7 @@ export class UIRenderComponent extends UIComponent { } public onDestroy () { + super.onDestroy(); this.destroyRenderData(); if (this._material){ this._material.destroy(); @@ -337,7 +345,7 @@ export class UIRenderComponent extends UIComponent { } protected _canRender () { - return this.material !== null && this.enabled && this.enabledInHierarchy; + return this.material !== null && this.enabled && (this._simulate? true: this.enabledInHierarchy); } protected _postCanRender(){} diff --git a/cocos/ui/components/graphics-component.ts b/cocos/ui/components/graphics-component.ts index 38fb38f060..81d7ff1e86 100644 --- a/cocos/ui/components/graphics-component.ts +++ b/cocos/ui/components/graphics-component.ts @@ -172,17 +172,17 @@ export class GraphicsComponent extends UIRenderComponent { public impl: Impl | null = null; public model: Model | null = null; @property - private _lineWidth = 1; + protected _lineWidth = 1; @property - private _strokeColor = Color.BLACK.clone(); + protected _strokeColor = Color.BLACK.clone(); @property - private _lineJoin = LineJoin.MITER; + protected _lineJoin = LineJoin.MITER; @property - private _lineCap = LineCap.BUTT; + protected _lineCap = LineCap.BUTT; @property - private _fillColor = Color.WHITE.clone(); + protected _fillColor = Color.WHITE.clone(); @property - private _miterLimit = 10; + protected _miterLimit = 10; constructor (){ super(); diff --git a/cocos/ui/components/mask-component.ts b/cocos/ui/components/mask-component.ts index 0c88f07a26..b7b04f7fcd 100644 --- a/cocos/ui/components/mask-component.ts +++ b/cocos/ui/components/mask-component.ts @@ -480,7 +480,8 @@ export class MaskComponent extends UIRenderComponent { clearGraphics.lineWidth = 0; const color = Color.WHITE.clone(); color.a = 0; - this._clearGraphics.fillColor = color; + clearGraphics.fillColor = color; + clearGraphics.simulate = true; this._updateClearGraphics(); } @@ -500,7 +501,7 @@ export class MaskComponent extends UIRenderComponent { if (!this._clearGraphics) { return; } - console.log('resolution changed'); + const size = visibleRect; this._clearGraphics.node.setWorldPosition(size.width / 2, size.height / 2, 0); this._clearGraphics.clear();