Scrolling UVs
Unity3D/Effect / 2012. 11. 8. 16:03
Scrolling UVs
Overview
A C# script that smoothly scrolls a material's UVs in an arbitrary direction/speed given by "Uv Animation Rate". Supports changing which material index and texture name, but the defaults will work with single material, single texture renderers.
C#
using UnityEngine; using System.Collections; public class ScrollingUVs : MonoBehaviour { public int materialIndex = 0; public Vector2 uvAnimationRate = new Vector2( 1.0f, 0.0f ); public string textureName = "_MainTex"; Vector2 uvOffset = Vector2.zero; void LateUpdate() { uvOffset += ( uvAnimationRate * Time.deltaTime ); if( renderer.enabled ) { renderer.materials[ materialIndex ].SetTextureOffset( textureName, uvOffset ); } } }
반응형
'Unity3D > Effect' 카테고리의 다른 글
파티클 한 번만 사용하고 종료하기 (0) | 2012.11.08 |
---|---|
MeleeWeaponTrail (0) | 2012.10.11 |