/// <summary> /// play button on animator /// </summary> public static void SetPlayButton() { //GetAllEditorWindowTypes(true); //open animator System.Type animatorWindowType = null; EditorWindow animatorWindow = ExtReflexion.ShowAndReturnEditorWindow(ExtReflexion.AllNameAssemblyKnown.AnimatorControllerTool, ref animatorWindowType); //open animation System.Type animationWindowType = null; EditorWindow animationWindowEditor = ExtReflexion.ShowAndReturnEditorWindow(ExtReflexion.AllNameAssemblyKnown.AnimationWindow, ref animationWindowType); //Get animationWindow Type //animationWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.AnimationWindow"); //Get field m_AnimEditor FieldInfo animEditorFI = animationWindowType.GetField("m_AnimEditor", ExtReflexion.GetFullBinding()); /* * object animEditorObject = animEditorFI.GetValue(animationWindowEditor); * MethodInfo playMI = animEditorFI.FieldType.GetMethod("TogglePlayAnimation", ExtReflexion.GetFullBinding()); * Debug.Log(playMI.Name); * * * Type[] types = new Type[1]; * object paramFunction = playMI.GetType().GetConstructor(GetFullBinding(), null, new type) * ConstructorInfo constructorInfoObj = playMI.GetType().GetConstructor(GetFullBinding(), null, * CallingConventions.HasThis, types, null); * * playMI.Invoke(animEditorObject, new object[0]); */ //PlayButtonOnGUI //Get the propertue of animEditorFI PropertyInfo controlInterfacePI = animEditorFI.FieldType.GetProperty("controlInterface", ExtReflexion.GetFullBinding()); //Get property i splaying or not PropertyInfo isPlaying = controlInterfacePI.PropertyType.GetProperty("playing", ExtReflexion.GetFullBinding()); //get object controlInterface object controlInterface = controlInterfacePI.GetValue(animEditorFI.GetValue(animationWindowEditor)); bool playing = (bool)isPlaying.GetValue(controlInterface); if (!playing) { MethodInfo playMI = controlInterfacePI.PropertyType.GetMethod("StartPlayback", ExtReflexion.GetFullBinding()); playMI.Invoke(controlInterface, new object[0]); } else { MethodInfo playMI = controlInterfacePI.PropertyType.GetMethod("StopPlayback", ExtReflexion.GetFullBinding()); playMI.Invoke(controlInterface, new object[0]); } }
private void OnSceneGUI() { animatorGUI = (AnimatorGUI)target; Handles.color = Color.green; if (Handles.Button(animatorGUI.transform.position + Vector3.up * 1 + Vector3.right * 0.3f, Quaternion.identity, 0.2f, 0.2f, Handles.SphereHandleCap)) { ExtReflexion.SetPlayButton(); } }
public static void CreateEmptyParent() { if (!Selection.activeGameObject) { return; } GameObject newParent = new GameObject("Parent of " + Selection.activeGameObject.name); int indexFocused = Selection.activeGameObject.transform.GetSiblingIndex(); newParent.transform.SetParent(Selection.activeGameObject.transform.parent); newParent.transform.position = Selection.activeGameObject.transform.position; Selection.activeGameObject.transform.SetParent(newParent.transform); newParent.transform.SetSiblingIndex(indexFocused); Selection.activeGameObject = newParent; ExtReflexion.SetExpandedRecursive(newParent, true); }