IconPreview.cs 573 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class IconPreview : MonoBehaviour {
  6. public Sprite[] icons;
  7. GameObject icon;
  8. // Use this for initialization
  9. void Awake () {
  10. for (int i = 0; i < icons.Length; i++) {
  11. icon = new GameObject ("icon" + i);
  12. icon.transform.SetParent(this.gameObject.transform);
  13. icon.AddComponent<RectTransform> ();
  14. icon.AddComponent<Image> ();
  15. icon.GetComponent<Image> ().sprite = icons [i];
  16. }
  17. }
  18. // Update is called once per frame
  19. void Update () {
  20. }
  21. }