mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fixed render issues (#2798)
This commit is contained in:
@@ -43,7 +43,8 @@ let RenderComponent = cc.Class({
|
||||
extends: Component,
|
||||
|
||||
editor: CC_EDITOR && {
|
||||
executeInEditMode: true
|
||||
executeInEditMode: true,
|
||||
disallowMultiple: true
|
||||
},
|
||||
|
||||
ctor () {
|
||||
@@ -57,13 +58,16 @@ let RenderComponent = cc.Class({
|
||||
},
|
||||
|
||||
onEnable () {
|
||||
if (this.node._renderComponent) {
|
||||
this.node._renderComponent.enabled = false;
|
||||
}
|
||||
this.node._renderComponent = this;
|
||||
this.node._renderFlag |= RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA | RenderFlow.FLAG_COLOR;
|
||||
},
|
||||
|
||||
onDisable () {
|
||||
this.node._renderComponent = null;
|
||||
this.node._renderFlag &= ~(RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA | RenderFlow.FLAG_COLOR);
|
||||
this.disableRender();
|
||||
},
|
||||
|
||||
onDestroy () {
|
||||
@@ -103,7 +107,7 @@ let RenderComponent = cc.Class({
|
||||
},
|
||||
|
||||
disableRender () {
|
||||
this.node._renderFlag &= ~(RenderFlow.FLAG_RENDER | cc.RenderFlow.FLAG_CUSTOM_IA_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA);
|
||||
this.node._renderFlag &= ~(RenderFlow.FLAG_RENDER | cc.RenderFlow.FLAG_CUSTOM_IA_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA | RenderFlow.FLAG_COLOR);
|
||||
},
|
||||
|
||||
requestRenderData () {
|
||||
|
||||
@@ -862,10 +862,8 @@ var ParticleSystem = cc.Class({
|
||||
|
||||
onEnable () {
|
||||
this._super();
|
||||
// should add render flag after particle loaded
|
||||
this.disableRender();
|
||||
|
||||
this._updateMaterial();
|
||||
this.node._renderFlag &= ~RenderFlow.FLAG_RENDER;
|
||||
this._activateMaterial();
|
||||
},
|
||||
|
||||
onDestroy () {
|
||||
@@ -918,7 +916,7 @@ var ParticleSystem = cc.Class({
|
||||
this._stopped = false;
|
||||
this._simulator.reset();
|
||||
if (!this._material) {
|
||||
this._updateMaterial();
|
||||
this._activateMaterial();
|
||||
}
|
||||
else {
|
||||
this.markForCustomIARender(true);
|
||||
@@ -1144,7 +1142,7 @@ var ParticleSystem = cc.Class({
|
||||
this._renderData.uvDirty = true;
|
||||
}
|
||||
// Reactivate material
|
||||
this._updateMaterial();
|
||||
this._activateMaterial();
|
||||
},
|
||||
|
||||
_applySpriteFrame: function (oldFrame) {
|
||||
@@ -1164,29 +1162,27 @@ var ParticleSystem = cc.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_updateMaterial: function () {
|
||||
// cannot be activated if texture not loaded yet
|
||||
if (!this._texture || !this._texture.loaded) {
|
||||
this.markForCustomIARender(false);
|
||||
if (this._spriteFrame) {
|
||||
this._applySpriteFrame();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material
|
||||
_activateMaterial: function () {
|
||||
if (!this._material) {
|
||||
this._material = new renderEngine.SpriteMaterial();
|
||||
this._material.useTexture = true;
|
||||
this._material.useModel = true;
|
||||
this._material.useColor = false;
|
||||
}
|
||||
|
||||
if (!this._texture || !this._texture.loaded) {
|
||||
this.markForCustomIARender(false);
|
||||
if (this._spriteFrame) {
|
||||
this._applySpriteFrame();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.markForUpdateRenderData(true);
|
||||
this.markForCustomIARender(true);
|
||||
this._material.texture = this._texture;
|
||||
}
|
||||
|
||||
this._updateBlendFunc();
|
||||
|
||||
this.markForUpdateRenderData(true);
|
||||
this.markForCustomIARender(true);
|
||||
},
|
||||
|
||||
_updateBlendFunc: function () {
|
||||
|
||||
@@ -304,19 +304,25 @@ let ArmatureDisplay = cc.Class({
|
||||
|
||||
onEnable () {
|
||||
this._super();
|
||||
dragonBones.CCFactory.getInstance()._dragonBones.clock.add(this._armature);
|
||||
if (this._armature) {
|
||||
dragonBones.CCFactory.getInstance()._dragonBones.clock.add(this._armature);
|
||||
}
|
||||
},
|
||||
|
||||
onDisable () {
|
||||
this._super();
|
||||
dragonBones.CCFactory.getInstance()._dragonBones.clock.remove(this._armature);
|
||||
if (this._armature) {
|
||||
dragonBones.CCFactory.getInstance()._dragonBones.clock.remove(this._armature);
|
||||
}
|
||||
},
|
||||
|
||||
onDestroy () {
|
||||
this._super();
|
||||
this._inited = false;
|
||||
this._armature.dispose();
|
||||
this._armature = null;
|
||||
if (this._armature) {
|
||||
this._armature.dispose();
|
||||
this._armature = null;
|
||||
}
|
||||
},
|
||||
|
||||
_initDebugDraw () {
|
||||
@@ -339,15 +345,22 @@ let ArmatureDisplay = cc.Class({
|
||||
},
|
||||
|
||||
_activateMaterial () {
|
||||
let texture = this.dragonAtlasAsset.texture;
|
||||
if (this._material || !texture)
|
||||
return;
|
||||
let texture = this.dragonAtlasAsset && this.dragonAtlasAsset.texture;
|
||||
|
||||
|
||||
// Get material
|
||||
let material = new SpriteMaterial();
|
||||
material.texture = texture;
|
||||
let material = this._material || new SpriteMaterial();
|
||||
material.useColor = false;
|
||||
|
||||
if (texture) {
|
||||
material.texture = texture;
|
||||
this.markForUpdateRenderData(true);
|
||||
this.markForRender(true);
|
||||
}
|
||||
else {
|
||||
this.disableRender();
|
||||
}
|
||||
|
||||
this.setMaterial(material);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user