Author Topic: EventDelegateEditor change request  (Read 2345 times)

Fireball14

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 23
    • View Profile
EventDelegateEditor change request
« on: December 02, 2014, 05:39:17 AM »
Hello, im using Field method of EventDelegateEditor draw EventDelegate field for my costume editor, and im getting Null refrence on multi-select of list variable. Adding
  1. if (list != null && list.Any())
fixes problem, so please add it to NGUI. Thx =)

  1. static public void Field (Object undoObject, List<EventDelegate> list, string noTarget, string notValid, bool minimalistic)
  2.         {
  3.                 bool targetPresent = false;
  4.                 bool isValid = false;
  5.  
  6.             if (list != null && list.Any())  //<------ this check
  7.             {
  8.                 // Draw existing delegates
  9.                 for (int i = 0; i < list.Count;)
  10.                 {
  11.                     EventDelegate del = list[i];
  12.  
  13.                     if (del == null || (del.target == null && !del.isValid))
  14.                     {
  15.                         list.RemoveAt(i);
  16.                         continue;
  17.                     }
  18.  
  19.                     Field(undoObject, del, true, minimalistic);
  20.                     EditorGUILayout.Space();
  21.  
  22.                     if (del.target == null && !del.isValid)
  23.                     {
  24.                         list.RemoveAt(i);
  25.                         continue;
  26.                     }
  27.                     if (del.target != null) targetPresent = true;
  28.                     isValid = true;
  29.                     ++i;
  30.                 }
  31.             }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EventDelegateEditor change request
« Reply #1 on: December 02, 2014, 12:25:55 PM »
What's list.Any()?

Fireball14

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 23
    • View Profile
Re: EventDelegateEditor change request
« Reply #2 on: December 03, 2014, 06:43:34 AM »
Determines whether a sequence contains any elements.

http://msdn.microsoft.com/en-us/library/vstudio/bb910253(v=vs.90).aspx

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EventDelegateEditor change request
« Reply #3 on: December 04, 2014, 03:43:38 AM »
It's not recognized by my Visual Studio 2010 at all.

Fireball14

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 23
    • View Profile
Re: EventDelegateEditor change request
« Reply #4 on: December 05, 2014, 09:51:04 AM »
Don't know, ben useing it for ages =)
You can always instead use
  1. list.Count > 0

PS i think Any() is using System.Linq;