选择网格上的图像统一

时间:2015-07-24 10:29:56

标签: unity3d unityscript

我希望将图像垂直和水平缩放并适合选择网格。我使用数组texture2D在选择网格上显示图像。

enter image description here

这将是结果。 enter image description here

代码在这里:

public Texture2D[] arr_texture2d_image;
private int sel_menu_int = 0;

 void Start(){
            arr_texture2d_image = new Texture2D[sel_menu_strs.Length];
            for(int i = 0; i < sel_menu_strs.Length; i++){
                WWW www = new WWW ("http://192.168.149.60/hmsx/api/" + sel_menu_strs[i]);
                StartCoroutine (WaitForRequest(www,i));
            }

IEnumerator WaitForRequest(WWW www,int i)
    {
        yield return www;
            if (www.isDone == true) {
                arr_texture2d_image[i] = www.texture as Texture2D;
                www.Dispose();
            } 
    }

}

void OnGUI(){
    sel_menu_int = GUILayout.SelectionGrid (sel_menu_int, arr_texture2d_image, no_of_thumbs_x ,gui_skn.button);
}

我用过这个但没什么用。

Texture2D texTmp = new Texture2D(280, 160, TextureFormat.DXT1, false);
                www.LoadImageIntoTexture(texTmp);
                arr_texture2d_image[i] = texTmp;

0 个答案:

没有答案