Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: gyd on September 29, 2015, 05:14:40 AM

Title: about EventDalegate drawer/editor
Post by: gyd on September 29, 2015, 05:14:40 AM
1. Could the EventDalegate support constant input ( intField/floatField/.. ) too?
2. Could the EventDalegate select menu sort when show?
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on September 29, 2015, 04:26:55 PM
1. I haven't added support for that.
2. I am not sure what you mean.
Title: Re: about EventDalegate drawer/editor
Post by: gyd on October 03, 2015, 01:15:16 PM
as image.
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on October 03, 2015, 06:47:21 PM
Sure, open EventDelegateDrawer.cs and add this on line 86:
  1. list.Sort(delegate(Entry a, Entry b) { return a.name.CompareTo(b.name); });
Title: Re: about EventDalegate drawer/editor
Post by: gyd on October 03, 2015, 07:20:19 PM
of course i could add it by myself, but what i post is a suggestion.
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on October 03, 2015, 07:29:18 PM
I've added it to 3.9.4.
Title: Re: about EventDalegate drawer/editor
Post by: gyd on October 03, 2015, 08:02:37 PM
I've added it to 3.9.4.

thanks for the support :)
Title: Re: about EventDalegate drawer/editor
Post by: gyd on August 04, 2016, 06:46:46 AM
sorry to pop this thread up, in the 3.10, the constant support is still not added.

i've posted an example here : http://www.tasharen.com/forum/index.php?topic=12781.msg57959#msg57959 ( but i dont think my code is good to use directly ).
is there a plan to add the constant support of EventDelegate?
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on August 05, 2016, 11:21:41 AM
Hmm... I'm not sure why I never did. I'll look into it, thanks for the reminder.
Title: Re: about EventDalegate drawer/editor
Post by: gyd on August 06, 2016, 07:14:21 AM
thanks!! it is surely a good news!
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on August 06, 2016, 09:36:58 PM
Ok, now I remember why I didn't do it.

I couldn't get the PropertyDrawer to work (EventDelegateDrawer). Unity's SerializableProperty can't serialize "object" type fields. It has to have an explicitly recognized value such as int, float, Vector3, etc.

So in order to get this to work, the EventDelegate.Parameter would need to have fields for all the types Unity understands -- string, int, Color, all of them. One for each. Only then is it possible to get them serialized. Of course doing so also bloats the size of the data dramatically, which is why I didn't do it.

If I'm wrong, and you somehow manage to get it to work with just an "object" field, I'd love to have a look at your implementation.
Title: Re: about EventDalegate drawer/editor
Post by: gyd on August 07, 2016, 04:55:37 AM
edit:
yes you are right, if we want to store params by constant value, we need to list all of the values.

but i tested it, each variable needs 38 bytes to store when meta is in text mode, and 360 bytes in binary mode.
maybe it dont bloat so dramatically, could you consider it? that would make the workflow much simpler.
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on August 08, 2016, 05:49:47 PM
It not only bloats memory usage but also the code. What is your workflow that requires passing static values?
Title: Re: about EventDalegate drawer/editor
Post by: gyd on August 09, 2016, 01:36:20 AM
a simple example is like:

a player selection menu with 4 players button, and when a button is pressed, call a method to set the players in the game.

current :
  1. // we need to add new apis for new settings, like Set5Player
  2. public void Set1Player(){ players = 1; }
  3. public void Set2Player(){ players = 2; }
  4. public void Set3Player(){ players = 3; }
  5. public void Set4Player(){ players = 4; }
  6.  
  7. // or
  8. // add to a script
  9. public int intValue = 0;
  10.  
  11. // and add this to a manager / singleton, then drag and assign the intValue to the control eventDelegate
  12. public void SetPlayers( int i ){ players = i; }
  13.  

after :
  1. // and add this to a manager / singleton, then just set the value is needed directly in inspector
  2. public void SetPlayers( int i ){ players = i; }
  3.  
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on August 09, 2016, 06:05:54 AM
You can simply name your buttons 1, 2, 3 and 4 -- then do
  1. void SetPlayers ()
  2. {
  3.     int.TryParse(UIButton.current.name, out players);
  4. }
Title: Re: about EventDalegate drawer/editor
Post by: gyd on August 09, 2016, 11:44:34 PM
yes but the way limited the naming rule..

consider with this case:
we have to drag an object to assign duration field of a tween, or limit the name of tween's game object.

i feel the same thing when i use the the event delegate with parameters, that's why i suggest the modification since march 2015.
Title: Re: about EventDalegate drawer/editor
Post by: gyd on February 17, 2017, 04:47:07 AM
You can simply name your buttons 1, 2, 3 and 4 -- then do
  1. void SetPlayers ()
  2. {
  3.     int.TryParse(UIButton.current.name, out players);
  4. }

hi ArenMook,
sorry to push this up again,

the Unity 5 ( not sure since which version ) supports UnityEvent to store a EventDelegate,
I think it's a solution to support this issue :)
Title: Re: about EventDalegate drawer/editor
Post by: ArenMook on February 18, 2017, 07:26:22 PM
Not sure what "UnityEvent to store a EventDelegate" means. :P

UnityEvent supports static values, but only if the function has a single parameter. Even if I was to consider switching to it, I can't do it as it will completely break all backwards compatibility, in addition to forcing everyone to set up multiple function calls instead of a single function with multiple parameters.
Title: Re: about EventDalegate drawer/editor
Post by: gyd on February 19, 2017, 07:07:39 AM
Not sure what "UnityEvent to store a EventDelegate" means. :P

UnityEvent supports static values, but only if the function has a single parameter. Even if I was to consider switching to it, I can't do it as it will completely break all backwards compatibility, in addition to forcing everyone to set up multiple function calls instead of a single function with multiple parameters.

that's true,
i think the only way now is list all the variable of types OTZ