Search Unity

See Methods Called Through UnityEvents in Performance Tab

Discussion in 'Scripting' started by Koval331, Oct 28, 2019.

  1. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    Hi! So I have this script that has UnityEvent called on FixedUpdate. The idea is that I attach various methods to this OnFixedUpdate through the Editor like this:

    2.PNG

    This is the Brain script where this OnFixedUpdate resides:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Events;
    5. using Sirenix.OdinInspector;
    6.  
    7. public class Brain : MonoBehaviour
    8. {
    9.     [SerializeField, FoldoutGroup("Fixed Update")]
    10.     private UnityEvent OnFixedUpdate = null;
    11.  
    12.     void FixedUpdate()
    13.     {
    14.         OnFixedUpdate.Invoke();
    15.     }
    16. }
    17.  
    But the problem is that in the Performance tab I only see the Brain.OnFixedUpdate method called. I can't see what specific methods were called through this OnFixedUpdate:

    1.PNG

    Is there a simple way to see the methods that are being called through OnFixedUpdate?
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Hello,
    Sounds like you're looking for the Deep Profiling Option. In 2019.3, when Profiling a Player, you'll have to build it as development build with Deep Profiling Support enabled in the build dialog. Previous versions only have Deep Profiling capability for Profiling in the Editor.
    Alternatively you could add ProfilerMarker calls to the methods you registered to the event, or instead of using a C# event, use a List<Action> where you add the events to and add ProfilerMarker calls before and after every call you make on the Actions in that list as you iterate through it.