- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- using UnityEngine;
- using System.Collections;
- public class TestSprite : MonoBehaviour {
- public Sprite spriteA;
- public Texture2D Tex;
- // Use this for initialization
- void Start () {
- Tex = Resources.Load("Enter") as Texture2D;
- //Create(源资源,对应sprite的矩形,对应sprite的中心点坐标)
- spriteA = Sprite.Create(Tex, new Rect(171, 0, 171, 95), new Vector2(0.5f, 0.5f));
- gameObject.GetComponent<SpriteRenderer>().sprite = spriteA;
-
- }
-
- // Update is called once per frame
- void Update () {
-
- }
- }
复制代码 |
|