当我给 sprite 加上 customMaterial 时会让节点在当前相机中显示不了,让后把相机 far 调大至 1001 才能显示。但是显示的顺序会有问题(原本在前面的物体反而被后面的物体挡住),请问这是什么问题 ?有好的办法解决吗 ?
[assets.zip|attachment](upload://l30GbGcxY65a0VVxbdIsoiPtH72.zip) (1.4 KB)
当我给 sprite 加上 customMaterial 时会让节点在当前相机中显示不了,让后把相机 far 调大至 1001 才能显示。但是显示的顺序会有问题(原本在前面的物体反而被后面的物体挡住),请问这是什么问题 ?有好的办法解决吗 ?
[assets.zip|attachment](upload://l30GbGcxY65a0VVxbdIsoiPtH72.zip) (1.4 KB)
文件上传失败,重新上传下吧,使用引擎版本是?
用的是3.7.2 .最后面我是把深度检测关了,然后再把far调大才能够正常显示
那算了,我这里把far + 1 后也没问题了。谢谢大佬 
使用方式和你一样吗?
我的是2D项目,就是用material 让图片看起来摇摆,多个摇摆的sprite 在不同的节点下,然后我的camera 是放在player 下跟随主角移动。
import { EffectAsset } from “cc”;
import { _decorator, CCFloat, Component, Material, Node, Sprite } from “cc”;
const { ccclass, property } = _decorator;
@ccclass(“Swing”)
export class Swing extends Component {
@property({ type: CCFloat })
private h = 0;
@property({ type: CCFloat })
private spd = 0;
@property({ type: CCFloat })
private swing = 0;
private material: Material;
private time = 0;
protected onLoad(): void {
this.time = 1;
}
start() {
const sprite = this.node.getComponent(Sprite);
this.material = sprite.customMaterial;
this.material.setProperty("h", this.h);
this.material.setProperty("spd", this.spd);
this.node.setPosition(this.node.position.add3f(0, 0, 10));
}
update(deltaTime: number) {
// 让草开始摆动 (Let the grass start to swing)
this.time += deltaTime * this.swing;
this.material.setProperty("time", this.time);
}
}
这个是操作脚本
还是没复现
大佬辛苦了, 可能是系统或者啥环境问题吧,我用的这个WIN11 跑软件经常有些莫名其妙的问题,浏览器硬件加速也经常卡死。
我也遇到了,加了材质以后 预览模式下可以看到,运行时看不见