本文共 974 字,大约阅读时间需要 3 分钟。
不涉及Paint in 3D使用说明书中的内容,比如:给预要绘制图形的物体添加碰撞体,添加可绘制脚本,添加画笔管理器。
本文内容包括: Paint in 3D的目标物体的绘画内容更新,清除参数Texture模板参数等
首先的需求:你想要清除画笔内容,清除Paint in 3D 默认生成的Texture内容,更新Texture
首先获取挂载P3D_Paintable脚本的组件,并把以前的物体MeshRenderer中材质上的Shader Texture清空,例如:
gb.GetComponent< MeshRenderer >().material.SetTexture( "_MainTex" , null ); 接着,清除P3D_Paintable脚本上的Texture,并添加新的Texture: gb.GetComponent< P3D_Paintable >().Textures.Clear(); gb.GetComponent< P3D_Paintable >().AddTexture(); gb.GetComponent< P3D_Paintable >().Textures[0].CreateOnAwake = true ; gb.GetComponent< P3D_Paintable >().Textures[0].DuplicateOnAwake = true ; 再然后,设置绘制地图的基本颜色,颜色可调,包括透明通道(这一步和生成的Texture底板有关):
gb.GetComponent< P3D_Paintable >().Textures[0].CreateColor= new Color (1,1,1,0); 最后唤醒函数即可(Awake函数里面包含有初始化生成底图的内容):
gb.GetComponent< P3D_Paintable >().Textures[0].Awake(gb); CreateColor 参数赋值中,设置Alpha值为0,保证底图是透明的,这样不会遮挡绘制物体的原本颜色,再把Painter里的
绘制颜色值得Alpha设置为1,即可正常进行绘制。
转载地址:http://xkuubk.baihongyu.com/