お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeアニメーションをブレンドせずに再生します。
Play() は /animation/ の名前からアニメーションを再生するか、デフォルトアニメーションを再生します。 アニメーションはブレンドをせずに急に再生を行います。 PlayMode.StopSameLayerの場合、同じレイヤーのアニメーション全てが停止します。 PlayMode.StopAllの場合、現在再生中の全てのアニメーションを停止します。 アニメーションが既に再生中の場合、他のアニメーションは停止しますが 再生中のアニメーションは巻き戻されることはありません。 アニメーションがループ設定になっていない場合、アニメーションを再生した後は再生位置は初期位置に戻り停止します。 Play() はもしアニメーションが再生できなかった場合(アニメーションクリップが無い、またはデフォルトアニメーションがない)、falseを返します。
// Plays the default animation animation.Play();
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Example() { animation.Play(); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Example() as void: animation.Play()
具体的なアニメーションとするために、こうすることでうまくアニメーションを呼び出すことが出来ます。
// Plays the walk animation - stops all other animations in the same layer animation.Play("walk"); // Plays the walk animation - stops all other animations animation.Play("walk", PlayMode.StopAll);
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Example() { animation.Play("walk"); animation.Play("walk", PlayMode.StopAll); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Example() as void: animation.Play('walk') animation.Play('walk', PlayMode.StopAll)