高动态光渲染 低端手机不支持
camera._enableHDR = false
摄像机自动裁剪 默认为 True
camera.useOcclusionCulling = true;
静态物体合批
Laya.StaticBatchManager.combine(this.owner);
物体半透明效果
let wallMaterial = this.hitResult.collider.owner.meshRenderer && this.hitResult.collider.owner.meshRenderer.sharedMaterial;
if (wallMaterial == this.wallMaterial) return;
this.resetWallMaterial();
this.wallMaterial = wallMaterial;
if (!this.wallMaterial) return;
this.wallMaterial.albedoColorA = 0.3; //透明度
//混合方式
this.wallMater.push(this.wallMaterial.blend);
this.wallMaterial.blend = Laya.RenderState.BLEND_ENABLE_ALL;
//混合源
this.wallMater.push(this.wallMaterial.blendSrc);
this.wallMaterial.blendSrc = Laya.RenderState.BLENDPARAM_SRC_ALPHA;
//混合目标
this.wallMater.push(this.wallMaterial.blendDst);
this.wallMaterial.blendDst = Laya.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA;
//所属渲染队列
this.wallMater.push(this.wallMaterial.renderQueue);
// this.wallMaterial.renderQueue = Laya.BaseMaterial.RENDERQUEUE_TRANSPARENT;
this.wallMaterial.renderQueue = Laya.BaseMaterial.RENDERQUEUE_ALPHATEST;
/**
* 重置墙透明度
*/
resetWallMaterial() {
if (this.wallMaterial) {
this.wallMaterial.blend = this.wallMater[0];
this.wallMaterial.blendSrc = this.wallMater[1];
this.wallMaterial.blendDst = this.wallMater[2];
this.wallMaterial.renderQueue = this.wallMater[3];
this.wallMaterial.albedoColorA = 1; //透明度
this.wallMater = [];
this.wallMaterial.albedoColorA = 1; //透明度
this.wallMaterial = null;
}
}
PBR材质
// this.wallMaterial.renderMode = Laya.PBRRenderMode.Transparent;
// this.wallMaterial.renderMode = Laya.PBRRenderMode.Fade;
this.wallMaterial.renderQueue = Laya.BaseMaterial.RENDERQUEUE_ALPHATEST;
_initUiImage() {
if (!this.data) {
return
}
if (!this.contentView) return;
if (!this.itemBg) {
this.itemBg = this.contentView.getChildAt(0);
this.item = this.itemBg.getChildAt(0);
this.rewadLable = this.itemBg.getChildAt(1);
this.descLable = this.contentView.getChildAt(1);
this.progressBg = this.contentView.getChildAt(2);
this.progressBar = this.progressBg.getChildAt(0);
this.progressLable = this.progressBg.getChildAt(1);
this.clickBtn = this.contentView.getChildAt(3);
}
this.pro = this.data.curCount / this.data.totalCount;
this.itemBg.skin = this.data.rewardType == 1 ? "taskView/coin_bg.png" : "taskView/item_bg.png";
this.item.skin = this.data.imageUrl + ".png";
this.rewadLable.text = this.data.rewardType == 1 ? this.data.reward : "X" + this.data.reward;
this.descLable.text = this.data.desc;
this.progressBar.width = this.progressBg.width * this.pro;
this.progressLable.text = this.data.curCount + "/" + this.data.totalCount;
if (this.pro == 1) {
this.clickBtn.skin = "taskView/getBtn.png";
} else {
this.clickBtn.skin = "taskView/gotoBtn.png";
}
this._isLoadImage = true;
}
// _initUiImage() {
// // 弃用 手写UI
// // return
// if (!this.data) {
// return
// }
// this.pro = this.data.curCount / this.data.totalCount;
// let itemBg = new Laya.Image();
// itemBg.skin = this.data.rewardType == 1 ? "taskView/coin_bg.png" : "taskView/item_bg.png";
// itemBg.centerY = -3;
// itemBg.left = 5;
// this.imageItemBg.addChild(itemBg);
// //奖励图片
// let item = new Laya.Image();
// item.size(74, 68);
// item.skin = this.data.imageUrl + ".png";
// item.centerY = 0;
// item.centerX = 0;
// itemBg.addChild(item);
// //奖励数量
// let rewadLable = new Laya.Label();
// rewadLable.color = "#ffffff";
// rewadLable.fontSize = 24;
// rewadLable.strokeColor = "#000000";
// rewadLable.stroke = 3;
// rewadLable.valign = "center";
// rewadLable.align = "right";
// rewadLable.right = 0;
// rewadLable.bottom = 0;
// rewadLable.text = this.data.rewardType == 1 ? this.data.reward : "X" + this.data.reward;
// itemBg.addChild(rewadLable);
// //描述Lable
// let descLable = new Laya.Label();
// descLable.color = "#000000";
// descLable.fontSize = 22;
// // descLable.strokeColor = "#000000";
// // descLable.stroke = 3;
// descLable.valign = "center";
// descLable.align = "center";
// descLable.centerX = 0;
// descLable.top = 20;
// descLable.text = this.data.desc;
// this.imageItemBg.addChild(descLable);
// //当前任务进度
// this.progressBg = new Laya.Image();
// this.progressBg.skin = "taskView/taskBarBg.png";
// this.progressBg.centerX = 0;
// this.progressBg.bottom = 20;
// this.progressBar = new Laya.Image();
// this.progressBar.skin = "taskView/taskBar.png";
// this.progressBar.centerY = 0;
// this.progressBar.width = this.progressBg.width*this.pro;
// this.progressBg.addChild(this.progressBar);
// this.progressLable = new Laya.Label();
// this.progressLable.color = "#000000";
// this.progressLable.fontSize = 22;
// this.progressLable.valign = "center";
// this.progressLable.align = "center";
// this.progressLable.centerX = 0;
// this.progressLable.centerY = 0;
// this.progressLable.text = this.data.curCount + "/" + this.data.totalCount;
// this.progressBg.addChild(this.progressLable);
// this.imageItemBg.addChild(this.progressBg);
// //状态按钮
// this.clickBtn = new Laya.Image();
// this.clickBtn.centerY = 0;
// this.clickBtn.right = 10;
// if (this.pro == 1) {
// this.clickBtn.skin = "taskView/getBtn.png";
// } else {
// this.clickBtn.skin = "taskView/gotoBtn.png";
// }
// this.imageItemBg.addChild(this.clickBtn);
// this._isLoadImage = true;
// }
```