x


Enabling and Disabling GUI Textures

In my game, I have a "Peace Mode" and a "Combat Mode." While in Peace mode, I want to have the combat textures disabled and greyed out. Do I need to make separate "greyed-out" versions? While I have the textures showing on and off when clicked, I can't quite get it working right.

void OnMouseDown() 
{
    if(PeaceButton)
    Mode ();
 
    if(AttackHackButton)
    HackAttack();
    ...etc
} 
void Mode()
{
    if(!CombatMode) //bool
    {
        guiTexture.texture=CombatButton;
        CombatMode=true;
        //AttackHackButton=enabled; (Should this be a bool?)
        Debug.Log("Combat Mode" +CombatMode);
    }
    else
    {
        guiTexture.texture=PeaceButton;
        CombatMode=false;
        Debug.Log("Peace Mode" +CombatMode);
    } 
}

What am I missing?
Thanks!
more ▼

asked Aug 10 '12 at 03:47 PM

Gilead7 gravatar image

Gilead7
117 18 33 42

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

best way at least in performance reason is to have two sets of textures.

on draw controls, just check the Combatode and use texture that shows the activity

I can't quite get it working right. what exactly working wrong?

more ▼

answered Aug 10 '12 at 11:17 PM

ScroodgeM gravatar image

ScroodgeM
7.6k 2 6

I wasn't quite able to wrap my brain around what needed to happen. I've since worked out one thing, but the rest is still elusive. I added this to onMouseDown: if (CombatMode=true) { if(RangedButton) RangedAttackMode();

if(AttackHackButton) HackAttack();

if(AttackSlashButton) SlashAttack();

if(AttackThrustButton) ThrustAttack();

if(AttackUppercutButton) UppercutAttack(); }

But if I try more than one texture in the Mode function(which switches between peace and combat modes) it's blank. Need some way to differentiate the different pieces. Will draw controls work for this?

Aug 11 '12 at 08:14 PM Gilead7

show sources of both textures declaration and implementation.

Aug 13 '12 at 09:51 PM ScroodgeM

Finally got it working!

Aug 16 '12 at 08:34 PM Gilead7
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4374
x495
x370
x40

asked: Aug 10 '12 at 03:47 PM

Seen: 467 times

Last Updated: Aug 16 '12 at 08:34 PM