unity 实时重复纹理

unity 实时重复纹理_第1张图片



在编辑器模式下

update里加上gameObject.GetComponent<MeshRenderer>().sharedMaterial.mainTextureScale = new Vector2(transform.localScale.x,transform.localScale.y);

就可以了,但是有缺点就是复制该物体时会产生新的材质从而有泄露,报错

Instantiating material due to calling renderer.material during edit mode. This will leak materials into the scene. You most likely want to use renderer.sharedMaterial instead.

不过不是大问题,因为只存在场景内,场景关闭或者切换的时候会自动释放

你可能感兴趣的:(unity,repeat,重复,纹理,循环纹理)