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; } } }
posted on 2022-06-28 16:54 zqiang0803 阅读(107) 评论(0) 编辑 收藏 举报