void MenuAddMotion( object userData ) { string path = (string) userData; AnimationControllerHelper.AddFolder( anmCtr, Path.GetDirectoryName( path ) + "/Animations" ); makeClipList(); Repaint(); }
/// <summary> /// </summary> public void OnEnable() { try { m_states = self.layers[0].stateMachine.states; } catch (System.Exception e) { Debug.Log(e.ToString()); return; } AnimationControllerHelper.DefaultStatePosition(self); }
public static void RemoveAll(AnimatorController controller) { var states = controller.layers[0].stateMachine.states; float fval = 0.00f; float fadd = 1.00f / states.Length; for (int i = states.Length - 1; 0 <= i; i--) { fval += fadd; var c = states[i]; EditorUtility.DisplayProgressBar("クリップ削除中", string.Format("{0} : {1}", controller.name, c.state.name), fval); AnimationControllerHelper.Remove(controller, c.state); } EditorUtility.ClearProgressBar(); }
void MenuSort() { AnimationControllerHelper.DefaultStatePosition( anmCtr ); var states = anmCtr.layers[ 0 ].stateMachine.states; System.Array.Sort( states, ( x, y ) => string.Compare( x.state.name, y.state.name ) ); Vector2 def = new Vector2( -204.0f, 72.0f ); //float posY = 0; for( int i = 0; i < states.Length; ++i ) { string name = states[ i ].state.name; //int j; //for( j = 0; j < m_matchPattern.Count; ++j ) { // var s = m_matchPattern[ j ]; // if( s == "##-" ) { // m_states[ i ].position = def; // def.y += 24; // break; // } // if( s[ 0 ] == '#' ) continue; // var mm = Regex.Matches( name, s ); // if( 0 < mm.Count ) { // m_states[ i ].position = new Vector3( m_position[ j ].x, m_position[ j ].y, 0.00f ); // break; // } //} //if( m_matchPattern.Count <= j ) { states[ i ].position = def; def.y += 36; //} } anmCtr.layers[ 0 ].stateMachine.states = states; makeClipList(); Repaint(); }
/// <summary> /// /// </summary> void DrawPreviewButton() { using( new EditorGUI.DisabledGroupScope( !hasClipName() ) ) { using( new EditorGUILayout.HorizontalScope() ) { //if( GUILayout.Button( new GUIContent( "Cr" ), (GUIStyle) "Button", GUILayout.Width( 24f ), GUILayout.Height( 18f ) ) ) { // self.CrossFadeInFixedTime( m_clipName[ m_motionSelect ], 0.1f, 0, 0.0f ); //} if( m_clipPlay ) { if( GUILayout.Button( EditorGUIUtility.IconContent( "PauseButton" ), (GUIStyle) "Button", GUILayout.Width( 24f ), GUILayout.Height( 18f ) ) ) { m_clipPlay = !m_clipPlay; EditorApplication.update -= updateMotion; } } else { if( GUILayout.Button( EditorGUIUtility.IconContent( "PlayButton" ), (GUIStyle) "Button", GUILayout.Width( 24f ), GUILayout.Height( 18f ) ) ) { m_clipPlay = !m_clipPlay; EditorApplication.update += updateMotion; } } if( hasClipName() ) { var actClip = m_clipState[ m_motionSelect ].motion as AnimationClip; if( actClip != null ) { if( m_clipPlay ) { using( new EditorGUI.DisabledGroupScope( m_clipPlay ) ) { EditorGUILayout.Slider( m_framePos, 0.00f, actClip.toRealTime() ); } } else { EditorGUI.BeginChangeCheck(); m_framePos = EditorGUILayout.Slider( m_framePos, 0.00f, actClip.toRealTime() ); if( EditorGUI.EndChangeCheck() ) { self.Play( actClip.name, 0, m_framePos / ( actClip.toRealTime() ) ); self.Update( 0 ); //AnimatorClipInfo[] ai = self.GetCurrentAnimatorClipInfo( 0 ); //foreach( var a in ai ) { // //Debug.Log( a.clip.length ); // Debug.Log( ( a.clip.frameRate * a.clip.length ) * m_framePos ); //} SceneView.RepaintAll(); } } } } } } if( !hasClipName() ) { EditorGUILayout.LabelField( "アニメーションがありません", (GUIStyle) "HelpBox" ); DragDrop( GUILayoutUtility.GetLastRect() ); return; } //GUIStyle styleListTitle = "OL Title"; //GUIStyle styleListBox = "HelpBox"; if( ( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete ) ) { Debug.Log( "Delete: " + m_clipState[ m_motionSelect ] ); AnimationControllerHelper.Remove( anmCtr, m_clipState[ m_motionSelect ] ); makeClipList(); if( m_clipState.Length <= m_motionSelect ) { m_motionSelect = m_clipState.Length - 1; } this.Repaint(); return; } GUIStyle styleListElement = "PreferencesKeysElement"; using( new GUILayout.VerticalScope( GUILayout.ExpandWidth( true ), GUILayout.ExpandHeight( true ) ) ) { using( var scr = new GUILayout.ScrollViewScope( this.m_KeyScrollPos, m_Styles.HelpBox ) ) { m_KeyScrollPos = scr.scrollPosition; for( int i = 0; i < m_clipState.Length; ++i ) { var a = m_clipState[ i ].name; GUI.changed = false; GUILayout.Toggle( i == m_motionSelect, a, styleListElement ); if( GUI.changed ) { m_motionSelect = i; GUI.FocusControl( "" ); } } } } DragDrop( GUILayoutUtility.GetLastRect() ); }
void MenuClear() { AnimationControllerHelper.RemoveAll( anmCtr ); makeClipList(); Repaint(); }