纳金网

标题: [unity3d程序] 纹理扩散 [打印本页]

作者: star-小虎    时间: 2013-10-15 15:08
标题: [unity3d程序] 纹理扩散
纹理扩散适合与做游戏的背景(卷轴效果),原理就是让材质贴图动起来(循环运动),代码很简单希望对大家有用

// Scroll main texture based on time
var scrollSpeed = -0.5;
// This must be set to override a bug where Render Order
// of the tunnel objects is lost when SetTextureOffset is used
var queue = 0;
private var offset = 0.0;

function Update ()
{   
    offset = Time.time * scrollSpeed;
    renderer.material.SetTextureOffset ("_MainTex", Vector2(offset,0));
    renderer.material.renderQueue = queue;
}
贴图最好用psd格式的,jpg格式实现不了(亲测过)



作者: run0006    时间: 2014-5-7 04:21
感謝分享!




欢迎光临 纳金网 (http://wwww.narkii.com/club/) Powered by Discuz! X2.5