Invalid AABB inAABB怎么解决
答案:2 悬赏:10 手机版
解决时间 2021-02-06 15:16
- 提问者网友:刺鸟
- 2021-02-05 19:38
Invalid AABB inAABB怎么解决
最佳答案
- 五星知识达人网友:孤独入客枕
- 2021-02-05 20:57
解决的办法是使用协程:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Use this for initialization
void Start () {
AddSampleData ();
}
void AddSampleData(){
StartCoroutine(WaitLoadImage("/Users/xxxx/xxx/xxx.jpg", go));
}
IEnumerator WaitLoadImage(string fileName, GameObject targetGameObject)
{
RectTransform rectTransform = targetGameObject.GetComponent ();
WWW www=new WWW("file://"+fileName);
Image img = targetGameObject.GetComponent ();
Debug.Log(www.url);
yield return www;
Rect spriteRect = new Rect (0, 0, www.texture.width, www.texture.height);
Sprite imageSprite = Sprite.Create (www.texture, spriteRect, new Vector2 (0.5f, 0.5f));
img.sprite = imageSprite;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Use this for initialization
void Start () {
AddSampleData ();
}
void AddSampleData(){
StartCoroutine(WaitLoadImage("/Users/xxxx/xxx/xxx.jpg", go));
}
IEnumerator WaitLoadImage(string fileName, GameObject targetGameObject)
{
RectTransform rectTransform = targetGameObject.GetComponent
WWW www=new WWW("file://"+fileName);
Image img = targetGameObject.GetComponent
Debug.Log(www.url);
yield return www;
Rect spriteRect = new Rect (0, 0, www.texture.width, www.texture.height);
Sprite imageSprite = Sprite.Create (www.texture, spriteRect, new Vector2 (0.5f, 0.5f));
img.sprite = imageSprite;
}
全部回答
- 1楼网友:鸽屿
- 2021-02-05 21:44
解决的办法是使用协程:
// use this for initialization
void start () {
addsampledata ();
}
void addsampledata(){
startcoroutine(waitloadimage("/users/xxxx/xxx/xxx.jpg", go));
}
ienumerator waitloadimage(string filename, gameobject targetgameobject)
{
recttransform recttransform = targetgameobject.getcomponent ();
www www=new www("file://"+filename);
image img = targetgameobject.getcomponent ();
debug.log(www.url);
yield return www;
rect spriterect = new rect (0, 0, www.texture.width, www.texture.height);
sprite imagesprite = sprite.create (www.texture, spriterect, new vector2 (0.5f, 0.5f));
img.sprite = imagesprite;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯