纳金网
标题:
通过代码动态更改SpriteRender的Sprite
[打印本页]
作者:
狂风大尉
时间:
2014-7-31 01:39
标题:
通过代码动态更改SpriteRender的Sprite
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 () {
}
}
复制代码
作者:
hyui
时间:
2014-7-31 19:08
Thanks for sharing !
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5