Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
		/// <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() );
		}