Author Topic: Getting access to multiple scripts from a button  (Read 3912 times)

arumiat

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Getting access to multiple scripts from a button
« on: June 27, 2015, 11:43:26 AM »
Hi guys,

Whilst I've been 'using' NGUI for a year now my developer has done most of the actual NGUI setup so I've never really had to dive in and learn it myself. It's getting to the point now whereby I need to be able to iterate faster and I really ought to start understanding things myself. I've watched the getting started tutorials, but I'm slightly stumped by a few things.

Initially I was setting up NGUI for each & every scene in my project. My developer pointed out this is idiotic and now we have a single 'UI' scene. This scene then references and loads the other scenes in the project within it. It looks as though my dev wrote a custom script to do this UI Manager

2 current issues:
1)  I'm not sure how to disable and enable certain NGUI elements on a per-scene basis. For instance in scene A I would like a 'Play' button to show, but for this same button to be hidden in Scene B. Can anyone point me to some relevant documentation for this?

2) I've added a new script to my game that causes lots of objects to burst apart when a input is pressed (you define the input in the Editor). In my case I have set this input on the object to be Spacebar.


How can I Notify this script via the NGUI play button? I created a prefab of the object in the scene where the exploding script is and dragged that to the On Notify field, however none of the dropdowns actually make the script work like they do in the actual scene itself.


Do I need to modify this exploding script (I tried making the key a public rather than private variable, but this didnt change the dropdown), or is there something I need to do to NGUI?


Thanks for any advice,
T

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: Getting access to multiple scripts from a button
« Reply #1 on: June 28, 2015, 01:25:08 PM »
1) Pretty sure this is on you. If you want a part of your GUI disabled/enabled, just disable/enable the GameObject that contains it. NGUI doesn't have a component for this because its trivial for the user to do in a way thats better for them.

2) Looks like your connection to the ExplodePartManager (from the button) is fine, but you dont have any useful options showing up for the "Method" because you dont have any public methods available to it. (e.g. you would need "public void Explode()" in the ExplodePartManager class). Static or private methods dont show up in that list. Parameters are okay but are kinda limited for what you can pass into them.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Getting access to multiple scripts from a button
« Reply #2 on: June 29, 2015, 07:17:14 AM »
Why are you dragging a script from the Project view? You need to drag a game object from your Hierarchy window.