Euras

TextureScaling

Feb 1st, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.30 KB | None | 0 0
  1. Renderer r;
  2.  
  3. void Awake()
  4. {
  5.     r = transform.GetComponent<Renderer>();
  6.     SetTextureTiles(transform.localScale.x, transform.localScale.y);
  7. }
  8.  
  9. void SetTextureTiles(float x, float y)
  10. {
  11.     float width = x / 0.5F;
  12.     float height = y / 0.5F;
  13.     r.material.mainTextureScale = new Vector2(width, height);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment