Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unity3D,我如何重复背景图像?_Unity3d - Fatal编程技术网

Unity3D,我如何重复背景图像?

Unity3D,我如何重复背景图像?,unity3d,Unity3d,我尝试在Guillayout上重复背景图像。 在我从网站上搜索后,无法找到如何重复图像 这能告诉我为什么吗?或者如何使windows背景图像能够自动填充 下面是我的代码 Texture2D LzIMGBackground; LzIMGBackground = Resources.LoadAssetAtPath("Assets/Textures/UI/Resources/metal-background-texture.jpg",typeof(Texture2D)) as Texture2

我尝试在Guillayout上重复背景图像。 在我从网站上搜索后,无法找到如何重复图像

这能告诉我为什么吗?或者如何使windows背景图像能够自动填充

下面是我的代码

Texture2D LzIMGBackground;
    LzIMGBackground = Resources.LoadAssetAtPath("Assets/Textures/UI/Resources/metal-background-texture.jpg",typeof(Texture2D)) as Texture2D;
    GUILayout.BeginVertical (LzIMGBackground, "box");
    GUILayout.BeginVertical ("box");
    if(GUILayout.Button("Single Player",GUILayout.Width(200))){
        Application.LoadLevel("testGUITransitions");
    }
    GUILayout.EndVertical ();

    GUILayout.BeginVertical ("box");
    if(GUILayout.Button("Quit",GUILayout.Width(200))){
        Application.Quit();
    }
    GUILayout.EndVertical ();
    GUILayout.EndVertical ();
例如,我已经附上了文件。非常感谢

您需要使用“GUI.DrawTextureWithTexCoords”功能

var panelWidth = ...; 
var panelHeight = ...;
yourTexture.wrapMode = TextureWrapMode.Repeat;

GUI.DrawTextureWithTexCoords(panelPos, yourTexture, 
    new Rect(0, 0, screenBounds.width / yourTexture.width, panelHeight / yourTexture.height));

您可以尝试传递具有固定宽度的GUI样式对象。@AVolpe,谢谢您的回复。这能给我举个例子吗?“我真的不知道如何使它工作。”阿沃尔普,我已经试过了。但它只是缩放图像。有没有可能在没有缩放的情况下重复图像?谢谢检查这个@AVolpe,谢谢!它起作用了!希望你能回答我另一个问题。非常感谢!