From 2a068b272081298d1f2d84db43b703da79b95b85 Mon Sep 17 00:00:00 2001 From: JoneLau <32630749+JoneLau@users.noreply.github.com> Date: Tue, 31 Dec 2019 09:59:22 +0800 Subject: [PATCH] update material api in uiModel (#6007) --- cocos/ui/components/ui-model-component.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cocos/ui/components/ui-model-component.ts b/cocos/ui/components/ui-model-component.ts index 4f5a9672b0..d50b210f69 100644 --- a/cocos/ui/components/ui-model-component.ts +++ b/cocos/ui/components/ui-model-component.ts @@ -130,7 +130,7 @@ export class UIModelComponent extends UIComponent { } const matNum = this._modelComponent.sharedMaterials.length; for (let i = 0; i < matNum; i++) { - const material = this._modelComponent.getMaterial(i)! as Material; + const material = this._modelComponent.getMaterialInstance(i); if (material == null) { continue; } @@ -138,22 +138,17 @@ export class UIModelComponent extends UIComponent { const ea = material.effectAsset!; const techIdx = material.technique; const passNum = passes.length; - let needReconstruct = false; for (let j = 0; j < passNum; j++) { if (!passes[j].blendState.targets[0].blend) { - needReconstruct = true; const bs = passes[j].blendState.targets[0]; bs.blend = true; passes[j].overridePipelineStates(ea.techniques[techIdx].passes[j], { blendState: passes[j].blendState }); } } - if (needReconstruct) { - // @ts-ignore - material._onPassesChange(); - } } + for (let i = 0; i < matNum; i++) { - const material = this._modelComponent.getMaterial(i); + const material = this._modelComponent.getMaterialInstance(i); if (material == null) { continue; }