Last active
September 15, 2017 10:49
-
-
Save andanteyk/0bdaad2f7fb91248ab2951e5f241910d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
// 5.6.0f3 で確認 | |
// Image がついているオブジェクトにつける | |
public class NewBehaviourScript : MonoBehaviour { | |
// インスペクタで適宜設定する | |
public Sprite[] sprites; | |
private Image _img; | |
// Use this for initialization | |
void Start () { | |
_img = GetComponent<Image>(); | |
} | |
// Update is called once per frame | |
void Update () { | |
int i = Random.Range(0, sprites.Length); // (適当に選ぶ) | |
_img.sprite = sprites[i]; // これで書き変わる | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment