http://www.unitymanual.com/home.php?mod=space&uid=2452&do=blog&id=420

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 () {
    
    }
}

 

相关文章:

  • 2021-07-21
  • 2021-08-28
  • 2021-08-26
  • 2021-11-10
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案