纹理扩散

转自:http://www.cnblogs.com/lm3515/archive/2010/09/25/1834531.html

纹理扩散适合与做游戏的背景(卷轴效果),原理就是让材质贴图动起来(循环运动),代码很简单希望对大家有用

01 // Scroll main texture based on time
02 var scrollSpeed = -0.5;
03 // This must be set to override a bug where Render Order
04 // of the tunnel objects is lost when SetTextureOffset is used
05 var queue = 0;
06 private var offset = 0.0;
07  
08 function Update ()
09 {  
10     offset = Time.time * scrollSpeed;
11     renderer.material.SetTextureOffset ("_MainTex", Vector2(offset,0));
12     renderer.material.renderQueue = queue;
13 }
贴图最好用psd格式的,jpg格式实现不了(亲测过)
 

你可能感兴趣的:(纹理扩散)