Author Topic: Execute all?  (Read 5164 times)

mathiassoeholm

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 35
    • View Profile
Execute all?
« on: December 10, 2013, 04:27:48 AM »
This is not really a support question, sorry!

I was looking for the old "Run Now", or whatever is was called on my UITable.
I couldn't find it, so I looked through the code and found that you are now using a ContextMenu with the title "Execute" on all of the things that can be updated.

I thought it would be nice if maybe you could update everything, at once! So here's my little contribution to that:

  1. [MenuItem("NGUI/Quick Actions/Execute All")]
  2. private static void ExecuteAll()
  3. {
  4.     foreach (var obj in Object.FindObjectsOfType<MonoBehaviour>())
  5.     {
  6.         var methods = obj.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
  7.         var executeMethod = methods.FirstOrDefault(m => m.GetCustomAttributes(typeof(ContextMenu), false).Any(cm => (cm as ContextMenu).menuItem == "Execute"));
  8.  
  9.         if (executeMethod != null)
  10.         {
  11.             executeMethod.Invoke(obj, null);
  12.         }
  13.     }
  14. }
  15.  

chiuan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 6
  • Posts: 11
    • View Profile
Re: Execute all?
« Reply #1 on: January 05, 2014, 11:13:11 AM »
this is the solution??