From 3e2d55b01d812be62b5239fc8f2d4c3b3edd2a2b Mon Sep 17 00:00:00 2001 From: mika Date: Tue, 22 Oct 2024 21:46:37 +0300 Subject: [PATCH 01/29] Create FindWhatButtonCallsMyMethod.cs --- .../Tools/FindWhatButtonCallsMyMethod.cs | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Assets/Scripts/Editor/Tools/FindWhatButtonCallsMyMethod.cs diff --git a/Assets/Scripts/Editor/Tools/FindWhatButtonCallsMyMethod.cs b/Assets/Scripts/Editor/Tools/FindWhatButtonCallsMyMethod.cs new file mode 100644 index 0000000..e67f45b --- /dev/null +++ b/Assets/Scripts/Editor/Tools/FindWhatButtonCallsMyMethod.cs @@ -0,0 +1,69 @@ +// prints out which buttons in current scene are referencing your given method + +using UnityEngine; +using UnityEngine.UI; +using UnityEditor; +using UnityEngine.Events; +using System.Reflection; + +namespace UnityLibrary +{ + public class FindWhatButtonCallsMyMethod : EditorWindow + { + private string methodName = "MyMethodHere"; + + [MenuItem("Tools/Find Buttons with Method")] + public static void ShowWindow() + { + GetWindow("FindWhatButtonCallsMyMethod"); + } + + private void OnGUI() + { + GUILayout.Label("Find Buttons that call Method", EditorStyles.boldLabel); + methodName = EditorGUILayout.TextField("Method Name:", methodName); + + if (GUILayout.Button("Find Buttons")) + { + FindButtonsWithMethod(); + } + } + + private void FindButtonsWithMethod() + { + Button[] allButtons = FindObjectsOfType