Unity3D - 如何使纹理变化的静音按钮/切换? [英] Unity3D - How to make a texture changing mute button/toggle?

查看:648
本文介绍了Unity3D - 如何使纹理变化的静音按钮/切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使一个静音按钮在我的Andr​​oid游戏菜单,所以当我preSS按钮,从打喇叭标志纹理变为静音喇叭标志(我已经在已经取得Photoshop中)。

I'm trying to make a mute button for in my android game menu, so when I press the button, the texture changes from a playing speaker symbol to a muted speaker symbol (which I've already made in Photoshop).

因此​​,当音频播放将有一个喇叭符号,但是当我preSS,它会更改为扬声器静音符号(有交叉扬声器)。

So when the audio is playing it will have a 'speaker' symbol, but when I press it, it will change to a 'muted speaker' symbol (a speaker with a cross).

在此先感谢,任何帮助是AP preciated!

Thanks in advance, any help is appreciated!

推荐答案

首先我们做一个maintexture作为一直使用的质地和清醒,我们把我们的texture1(扬声器)分配给它,如果按钮是pressed我们将其更改为纹理2(静音)结果

first we make a maintexture as the texture that is always used and on awake we put our texture1(speaker) assign to it and if button is pressed we change it to texture2(mute)

    public Texture2D Texture1;
    public Texutre2D Texture2;
    public bool textureBool;

    void Awake() {
      textureBool=true;

    void OnGUI(){

    if( GUI.Button( rect , textureBool ? texture1:texture2 ) )
        {
           textureBool = !textureBool;
        }

      }

这篇关于Unity3D - 如何使纹理变化的静音按钮/切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆