Unity3D - 如何制作纹理更改静音按钮/切换? [英] Unity3D - How to make a texture changing mute button/toggle?

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

问题描述

我正在尝试在我的 android 游戏菜单中制作一个静音按钮,所以当我按下按钮时,纹理从播放扬声器符号变为静音扬声器符号(我已经在 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).

所以当音频正在播放时,它会有一个扬声器"符号,但是当我按下它时,它会变成一个静音扬声器"符号(一个带叉号的扬声器).

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).

提前致谢,感谢您的帮助!

Thanks in advance, any help is appreciated!

推荐答案

首先我们制作一个 maintexture 作为始终使用的纹理,在唤醒时我们将我们的 texture1(speaker) 分配给它,如果按下按钮我们改变它到纹理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天全站免登陆