在运行时更改对象的纹理

时间:2015-09-11 23:04:44

标签: c# android unity3d augmented-reality vuforia

我正在尝试制作一个改变GameObject纹理的GUI按钮......任何想法?

我制作了这段代码,但是球体变白了,它没有显示纹理

using UnityEngine;
using System.Collections;

namespace Vuforia
{
    public class GUI_Button : MonoBehaviour 
    {
        GameObject Pokeball;
        Texture3D texture = (Texture3D) Resources.Load ("Resources/clouds1024");

        private void OnGUI() 
        {
            if (GUI.Button (new Rect (5, 15, 100, 25), "Pokeball")) {
                Pokeball = GameObject.Find("Pokeball");

                Pokeball.GetComponent<Renderer>().material.mainTexture = texture;
            }

        }
    }
}

0 个答案:

没有答案