fix clear graphics no effect bug (#5496)

This commit is contained in:
JoneLau
2019-10-09 22:46:42 +08:00
committed by pandamicro
parent 2edfab3b82
commit be5a8333bc
4 changed files with 27 additions and 10 deletions
@@ -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;
}
@@ -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(){}
+6 -6
View File
@@ -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();
+3 -2
View File
@@ -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();