Author Topic: NGUI Button to activate/deactivate some other buttons?  (Read 3811 times)

puneetk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
NGUI Button to activate/deactivate some other buttons?
« on: November 05, 2014, 12:37:03 PM »
Hi I'm trying to make a "settings" button which on click shows two other buttons that is a sound and music button. When you click settings again, the sound and music button should disappear.

Any way to do this using the preprovided ngui toolset?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Button to activate/deactivate some other buttons?
« Reply #1 on: November 06, 2014, 01:58:10 AM »
  1. using UnityEngine;
  2.  
  3. public class Toggle : MonoBehaviour
  4. {
  5.     public GameObject activate;
  6.     void OnClick () { activate.SetActive(!activate.activeSelf); }
  7. }

puneetk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: NGUI Button to activate/deactivate some other buttons?
« Reply #2 on: November 06, 2014, 04:09:34 PM »
Thanks, is there also a way to set UIToggle script to work onPress or onHover?

Basically, I have another button, that shows another sprite when you press it (using UItoggle and selecting the other sprite), and I want another Panel to show, once the button is released.

How do I get this to work?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Button to activate/deactivate some other buttons?
« Reply #3 on: November 07, 2014, 02:05:22 PM »
No, toggle works with OnClick. If you want it to be something else, write your own simple script. Take the script I created in the previous reply and change OnClick to OnPress (bool isPressed) for example.