Version: 2020.2
言語: 日本語

StateMachineBehaviour

class in UnityEngine

/

継承:ScriptableObject

マニュアルに切り替える

説明

StateMachineBehaviour はステートマシンのステートに追加できるコンポーネントです。ステートのすべてのスクリプトが継承する基底クラスでもあります。

通常、Animator はコントローラーで定義されるそれぞれのビヘイビアの新しいインスタンスをインスタンス化しません。クラス属性である SharedBetweenAnimatorsAttribute は、ビヘイビアがどのようにインスタンス化されるかを管理します。

StateMachineBehaviour has some predefined messages: OnStateEnter, OnStateExit, OnStateIK, OnStateMove, OnStateUpdate.

using UnityEngine;

public class AttackBehaviour : StateMachineBehaviour { public GameObject particle; public float radius; public float power;

protected GameObject clone;

override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { clone = Instantiate(particle, animator.rootPosition, Quaternion.identity) as GameObject; Rigidbody rb = clone.GetComponent<Rigidbody>(); rb.AddExplosionForce(power, animator.rootPosition, radius, 3.0f); }

override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Destroy(clone); }

override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log("On Attack Update "); }

override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log("On Attack Move "); }

override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Debug.Log("On Attack IK "); } }

Public 関数

OnStateMachineEnterCalled on the first Update frame when making a transition to a state machine. This is not called when making a transition into a state machine sub-state.
OnStateMachineExitStateMachine からの移行を行うとき、最後の Update フレームが呼ばれます。StateMachine のサブステートの中へ移行を行うとき、これは呼び出されません。

メッセージ

OnStateEnterCalled on the first Update frame when a state machine evaluate this state.
OnStateExitCalled on the last update frame when a state machine evaluate this state.
OnStateIK MonoBehaviour.OnAnimatorIK の直後に呼び出されます。
OnStateMove MonoBehaviour.OnAnimatorMove の直後に呼び出されます。
OnStateUpdate最初と最後のフレームを除いて Update フレームごとに呼び出されます。

継承メンバー

変数

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名

Public 関数

GetInstanceIDオブジェクトのインスタンス ID を返します
ToStringReturns the name of the object.

Static 関数

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeタイプ type から最初に見つけたアクティブのオブジェクトを返します
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiateoriginal のオブジェクトをクローンします
CreateInstanceScriptableObject のインスタンスを作成します。

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。

メッセージ

Awake ScriptableObject スクリプトを開始するとき、この関数は呼び出されます。
OnDestroyScriptableObject が破棄されるとき、この関数は呼び出されます。
OnDisableScriptableObject クラスのオブジェクトがスコープを外れるとき、この関数は呼び出されます。
OnEnableオブジェクトがロードされたとき、この関数は呼び出されます。
OnValidateThis function is called when the script is loaded or a value is changed in the Inspector (Called in the editor only).
Resetデフォルト値にリセットします
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961