private static void FindDependencies(string methodName)
        {
            var depens       = UnityEventReferenceFinder.FindAllUnityEventsReferences();
            var onlyWithName = new List <EventReferenceInfo>();

            foreach (var d in depens)
            {
                if (d.MethodNames.Where(m => m.ToLower().Contains(methodName.ToLower())).Count() > 0)
                {
                    var indexes = d.MethodNames.Where(n => n.ToLower().Contains(methodName.ToLower())).Select(n => d.MethodNames.IndexOf(n)).ToArray();

                    var info = new EventReferenceInfo();
                    info.Owner = d.Owner;

                    foreach (var i in indexes)
                    {
                        info.Listeners.Add(d.Listeners[i]);
                        info.MethodNames.Add(d.MethodNames[i]);
                    }

                    onlyWithName.Add(info);
                }
            }

            dependencies = onlyWithName.Count > 0 ? onlyWithName : depens;
        }
        private void DrawDependencies(EventReferenceInfo dependency, Vector2 position)
        {
            float width = drawableRect.width * leftColoumnRelativeWidth;

            EditorGUI.ObjectField(new Rect(position, new Vector2(width - tabulation, 16f)), dependency.Owner, typeof(MonoBehaviour), true);

            for (int i = 0; i < dependency.Listeners.Count; i++)
            {
                Vector2 positionRoot = position + Vector2.up * 16 + Vector2.up * 16 * i;
                EditorGUI.ObjectField(new Rect(positionRoot + Vector2.right * tabulation, new Vector2(width - tabulation, 16f)), dependency.Listeners[i], typeof(MonoBehaviour), true);

                Vector2 labelPosition = new Vector2(drawableRect.width * leftColoumnRelativeWidth + tabulation * 1.5f, positionRoot.y);
                EditorGUI.LabelField(new Rect(labelPosition, new Vector2(drawableRect.width * (1 - leftColoumnRelativeWidth) - tabulation / 1.5f, 16f)), dependency.MethodNames[i]);
            }
        }
        public static List <EventReferenceInfo> FindAllUnityEventsReferences()
        {
            var behaviours = Resources.FindObjectsOfTypeAll <MonoBehaviour>();
            var events     = new Dictionary <MonoBehaviour, UnityEventBase>();

            foreach (var b in behaviours)
            {
                var info  = b.GetType().GetTypeInfo();
                var evnts = info.DeclaredFields.Where(f => f.FieldType.IsSubclassOf(typeof(UnityEventBase))).ToList();
                foreach (var e in evnts)
                {
                    events.Add(b, e.GetValue(b) as UnityEventBase);
                }
            }

            var infos = new List <EventReferenceInfo>();

            foreach (var e in events)
            {
                int count = e.Value.GetPersistentEventCount();
                var info  = new EventReferenceInfo();
                info.Owner = e.Key;

                for (int i = 0; i < count; i++)
                {
                    var obj    = e.Value.GetPersistentTarget(i);
                    var method = e.Value.GetPersistentMethodName(i);

                    info.Listeners.Add(obj as MonoBehaviour);
                    info.MethodNames.Add(obj.GetType().Name.ToString() + "." + method);
                }

                infos.Add(info);
            }

            return(infos);
        }