unity 给当鼠标按下按钮的时候批量赋值
作者:互联网
IEnumerator GetTextureStop(Transform myTf, List<string> myList) { for (int i = 0; i < myTf.childCount; i++) { UnityWebRequest uwr = UnityWebRequest.Get(myList[i]); DownloadHandlerTexture downloadTexture = new DownloadHandlerTexture(true); uwr.downloadHandler = downloadTexture; yield return uwr.SendWebRequest(); if (uwr.isNetworkError || uwr.isHttpError) { print(uwr.error); } else { Texture2D t = downloadTexture.texture; // myTf.GetChild(i).GetComponent<Image>().sprite = Sprite.Create(t, new Rect(0, 0, t.width, t.height), Vector2.one); // myTf.GetChild(i).name = prefabStr + i; Button button = myTf.GetChild(i).GetComponent<Button>(); SpriteState state = new SpriteState(); state.pressedSprite = Sprite.Create(t, new Rect(0, 0, t.width, t.height), Vector2.one); button.spriteState = state; } } }
标签:GetChild,state,myTf,uwr,unity,当鼠标,按下,downloadTexture,new 来源: https://www.cnblogs.com/zqiang0803/p/16420129.html