Author Topic: about EventDalegate drawer/editor  (Read 41858 times)

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
about EventDalegate drawer/editor
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #1 on: September 29, 2015, 04:26:55 PM »
1. I haven't added support for that.
2. I am not sure what you mean.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #2 on: October 03, 2015, 01:15:16 PM »
as image.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #3 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); });

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #4 on: October 03, 2015, 07:20:19 PM »
of course i could add it by myself, but what i post is a suggestion.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #5 on: October 03, 2015, 07:29:18 PM »
I've added it to 3.9.4.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #6 on: October 03, 2015, 08:02:37 PM »
I've added it to 3.9.4.

thanks for the support :)

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #7 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #8 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.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #9 on: August 06, 2016, 07:14:21 AM »
thanks!! it is surely a good news!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #10 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.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #11 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.
« Last Edit: August 08, 2016, 04:08:30 AM by gyd »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #12 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?

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #13 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.  
« Last Edit: August 09, 2016, 02:11:49 AM by gyd »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: about EventDalegate drawer/editor
« Reply #14 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. }