Skip to content

Instantly share code, notes, and snippets.

@gkagm2
Created April 25, 2019 07:04
Show Gist options
  • Save gkagm2/1479ca7efe452912af023a7bc0e333a7 to your computer and use it in GitHub Desktop.
Save gkagm2/1479ca7efe452912af023a7bc0e333a7 to your computer and use it in GitHub Desktop.
UISprite (NGUI)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpriteManager : MonoBehaviour {
public UISprite icon;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Alpha0))
{
icon.spriteName = "Berry_02"; //문자열로 스프라이트의 아이콘을 바꿀 수 있다.
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
icon.spriteName = "Book_00";
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
icon.spriteName = "Book_03";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment