/// <summary> /// play button on animator /// </summary> public static void SetPlayButton(out bool isPlayingAnimation) { //open animator EditorWindow animatorWindow = ExtEditorWindow.OpenEditorWindow(ExtEditorWindow.AllNameAssemblyKnown.AnimatorControllerTool, out System.Type animatorWindowType); //open animation EditorWindow animationWindowEditor = ExtEditorWindow.OpenEditorWindow(ExtEditorWindow.AllNameAssemblyKnown.AnimationWindow, out System.Type animationWindowType); //Get field m_AnimEditor FieldInfo animEditorFI = animationWindowType.GetField("m_AnimEditor", ExtReflection.GetFullBinding()); //Get the propertue of animEditorFI PropertyInfo controlInterfacePI = animEditorFI.FieldType.GetProperty("controlInterface", ExtReflection.GetFullBinding()); //Get property i splaying or not PropertyInfo isPlaying = controlInterfacePI.PropertyType.GetProperty("playing", ExtReflection.GetFullBinding()); //get object controlInterface object controlInterface = controlInterfacePI.GetValue(animEditorFI.GetValue(animationWindowEditor)); //get the state of the "play" button isPlayingAnimation = (bool)isPlaying.GetValue(controlInterface); if (!isPlayingAnimation) { MethodInfo playMI = controlInterfacePI.PropertyType.GetMethod("StartPlayback", ExtReflection.GetFullBinding()); playMI.Invoke(controlInterface, new object[0]); } else { MethodInfo playMI = controlInterfacePI.PropertyType.GetMethod("StopPlayback", ExtReflection.GetFullBinding()); playMI.Invoke(controlInterface, new object[0]); } }
/// <summary> /// search for an object in all editro search bar /// use: ExtReflexion.SetSearch("to find", ExtReflexion.AllNameAssemblyKnown.SceneHierarchyWindow); /// use: ExtReflexion.SetSearch("to find", ExtReflexion.AllNameAssemblyKnown.SceneView); /// </summary> /// <param name="search"></param> public static void SetSearch(string search, ExtEditorWindow.AllNameAssemblyKnown nameEditorWindow = ExtEditorWindow.AllNameAssemblyKnown.SceneView) { //open animation window EditorWindow animationWindowEditor = ExtEditorWindow.OpenEditorWindow(nameEditorWindow, out System.Type animationWindowType); //System.Type type = typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow"); //EditorApplication.ExecuteMenuItem("Window/General/Hierarchy"); MethodInfo methodInfo = animationWindowType.GetMethod("SetSearchFilter", GetFullBinding()); if (methodInfo == null) { Debug.Log("null"); return; } var window = EditorWindow.focusedWindow; methodInfo.Invoke(window, new object[] { search, SearchableEditorWindow.SearchMode.All, true, false }); }