Advertisement
Guest User

RandomSprite.cs

a guest
Oct 9th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. namespace ProD
  6. {
  7.     public class RandomSprite : MonoBehaviour
  8.     {
  9.         public List<Sprite> sprites; /* List of sprites to choose from */
  10.         public float[] weights; /* List of 'weight' values to match against sprites. !!!MUST BE SAME SIZE AS SPRITE LIST!!! */
  11.        
  12.         void Start() /* Init */
  13.         {
  14.             GetComponent<SpriteRenderer>().sprite = RandomUtility.pickWeighted( sprites, weights ); /* Get a sprite from the list using weight values */
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement