Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Rafe

Pages: 1 ... 4 5 [6]
76
NGUI 3 Support / Re: eventReceiver For All Controls?
« on: July 18, 2012, 01:05:10 AM »
I realized I could add the component via script and get much the same functionality. I don't think there is anything wrong with just doing this...

This example is for a button that starts a level. It is a script on the GUI root that needs to handle the button click. I already have a reference to the UIButton "playButton".

        var messenger = this.playButton.gameObject.AddComponent<UIButtonMessage>();
        messenger.target = this.gameObject;
        messenger.trigger = UIButtonMessage.Trigger.OnClick;
        messenger.functionName = "PlayButtonOnClick";


The only thing I don't like about this is having to pass the name of the function instead of a reference. I'd have to try it but I believe you can store a reference and call it even with JavaScript. It isn't a true C# event delegate, but I believe it can be done. Perhaps a new component UIConnectFunction or some such thing... I'm just brainstorming.

77
NGUI 3 Support / New User Install Notes
« on: July 18, 2012, 12:51:52 AM »
Hi,

I wanted to post this while it is still fresh.

1) Is there a reason why you don't use the Plugins and Editor folders? All of our plugins are distributed to do this and it works great! This is pretty standard and it keeps things clean and works for JavaScript users, since these assemblies run first. You can also use the internal modifier in your code which can be handy. Folder structure example...
    Assets
        Plugins
            nGUI
                ...
        Editor
            nGUI
                ...

2) You use a lot of the same component names as EZGUI, which we also have. I had to refactor some code and reinstall to get nGUI to work. I am generally a fan of generic naming, but it would be nice to add use "nGUI" instead of "UI" as a prefix. I know changing this would require all users to update their code, but I wanted to point it out, even if just to warn others before import.


Awesome, awesome job!

78
NGUI 3 Support / eventReceiver For All Controls?
« on: July 18, 2012, 12:40:24 AM »
Note: This message is awaiting approval by a moderator.
Hi,

I've been using nGUI for about a day. I am very impressed by how fast I can take my GUI from another sprite system and recreate it. More importantly, I feel like I have a lot of control. The tools are great!

I am missing delegates, but messages are fine for UI-level performance, so no issue there. However, in my first script, I found the slider had eventReceiver, which allows for delegate-like ease-of-use. It looks like if I want something similar for a button, I need to add a ButtonMessage component for each message. Is that right?

What I would love to have is eventReceiver for everything.

In my script that handles the logic for a panel of buttons, I can set it in Awake making it very fast and easy to control in my script without having to worry about the inspector set up at this level.

Would this break a paradigm? It should be quite easy to implement. Thoughts?

Pages: 1 ... 4 5 [6]