Author Topic: NGUI 3.0 "Notify" inspector field doesn't list extension methods.  (Read 6006 times)

franktinsley

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 17
    • View Profile
NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« on: September 30, 2013, 01:02:52 PM »
I absolutely LOVE NGUI's new abilities to reveal methods to call in the inspector from various components! It's changed my life! But I just noticed it can't seem to show extension methods. I use those to add things like Pause() or Stop() functions to UITweener for instance. Be great to get those working. THANKS FOR THE AWESOME WORK!

Edit: ACTUALLY, if NGUI could list every method on everything attached to a given GameObject as seen here in the asset "Visual Actions" https://vimeo.com/73517544 That would be PERFECTION! I often need to do things like disable this thing, or enable that thing, that right now I'm finding I'm making little generic scripts just to expose those simple properties. If they were all exposed in the inspector, like Visual Actions makes them, then I would be TOTALLY SETUP!
« Last Edit: September 30, 2013, 04:11:33 PM by franktinsley »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« Reply #1 on: September 30, 2013, 06:46:40 PM »
What do you mean by "extension methods"? NGUI lists all functions that match the signature of "public void Func (void)". Derived functions as well, but they all need to be public.

franktinsley

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 17
    • View Profile
Re: NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« Reply #2 on: September 30, 2013, 07:00:03 PM »
http://msdn.microsoft.com/en-us/library/vstudio/bb383977.aspx

Those guys. They show up in autocomplete and everything. Great way to add functionality to other people's classes while keeping it encapsulated. Otherwise you're changing their classes and your changes have to be merged when they update and stuff, etc.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« Reply #3 on: September 30, 2013, 08:22:09 PM »
They don't show up because they're static, meaning they are not associated with a MonoBehaviour instance, which is needed for the delegate system. Remove the 'static' flag, and they will show up, assuming they are of "void Func (void)" type.

franktinsley

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 17
    • View Profile
Re: NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« Reply #4 on: October 01, 2013, 12:17:25 PM »
Really appreciate you taking the time to reply here. I tried making them not static but it seems C# can't make extension methods without them being static. Maybe this is just kind of a thing reflection doesn't work with?

Anywho, I actually want functionality like that of Visual Actions I linked above a lot more than the extension methods. Especially since right now NGUI can't list specific methods for multiple MonoBehaviors of the same type attached to a single GameObject. That(1), being able to edit the order of method calls in the inspector list(2), and maybe an extra component that does nothing but contain a list of method calls fired by a single public method(3), are the 3 things I'm lusting for HARD. XD

Essentially I'm trying to write scripts inside a component! haha (Not really… well sort of XD)
« Last Edit: October 01, 2013, 12:42:01 PM by franktinsley »

Bloompix

  • Guest
Re: NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« Reply #5 on: October 07, 2013, 06:31:56 AM »
Hi,

I'm new to NGUI and I'm experiencing the same problem when coding with c#. I'm trying to make a popup menu work.To do so I attach a new script to the popup menu with the public function:
     
public void OnSelectionChange(string selectedItem){}

But when I try to select this function from the 'On Value Change' Field available in the UIPopup List Script, there isn't any function listed.

Any suggestion would be appreacited!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI 3.0 "Notify" inspector field doesn't list extension methods.
« Reply #6 on: October 08, 2013, 02:18:14 AM »
Remove "string selectedItem" from that statement, and it will show up.