Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- namespace ProD
- {
- public class RandomSprite : MonoBehaviour
- {
- public List<Sprite> sprites; /* List of sprites to choose from */
- public float[] weights; /* List of 'weight' values to match against sprites. !!!MUST BE SAME SIZE AS SPRITE LIST!!! */
- void Start() /* Init */
- {
- GetComponent<SpriteRenderer>().sprite = RandomUtility.pickWeighted( sprites, weights ); /* Get a sprite from the list using weight values */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement