Version: 2022.1
言語: 日本語

AnimatorController

class in UnityEditor.Animations

/

継承:RuntimeAnimatorController

マニュアルに切り替える

説明

アニメータコントローラは、State Machine(ステートマシン)でレイヤーを通じてアニメーションを制御します。また、パラメータによって制御されます。

using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
using System.Collections;

// Create a menu item that causes a new controller and statemachine to be created.

public class SM : MonoBehaviour { [MenuItem("MyMenu/Create Controller")] static void CreateController() { // Creates the controller var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath("Assets/Mecanim/StateMachineTransitions.controller");

// Add parameters controller.AddParameter("TransitionNow", AnimatorControllerParameterType.Trigger); controller.AddParameter("Reset", AnimatorControllerParameterType.Trigger); controller.AddParameter("GotoB1", AnimatorControllerParameterType.Trigger); controller.AddParameter("GotoC", AnimatorControllerParameterType.Trigger);

// Add StateMachines var rootStateMachine = controller.layers[0].stateMachine; var stateMachineA = rootStateMachine.AddStateMachine("smA"); var stateMachineB = rootStateMachine.AddStateMachine("smB"); var stateMachineC = stateMachineB.AddStateMachine("smC");

// Add States var stateA1 = stateMachineA.AddState("stateA1"); var stateB1 = stateMachineB.AddState("stateB1"); var stateB2 = stateMachineB.AddState("stateB2"); stateMachineC.AddState("stateC1"); var stateC2 = stateMachineC.AddState("stateC2"); // don’t add an entry transition, should entry to state by default

// Add Transitions var exitTransition = stateA1.AddExitTransition(); exitTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "TransitionNow"); exitTransition.duration = 0;

var resetTransition = rootStateMachine.AddAnyStateTransition(stateA1); resetTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "Reset"); resetTransition.duration = 0;

var transitionB1 = stateMachineB.AddEntryTransition(stateB1); transitionB1.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "GotoB1"); stateMachineB.AddEntryTransition(stateB2); stateMachineC.defaultState = stateC2; var exitTransitionC2 = stateC2.AddExitTransition(); exitTransitionC2.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "TransitionNow"); exitTransitionC2.duration = 0;

var stateMachineTransition = rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineC); stateMachineTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, "GotoC"); rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineB); } }

変数

layersコントローラーのレイヤー
parametersパラメータは、スクリプトとコントローラー間の通信に使われます。例えば、それらはドライブを制御するためやブレンドツリーに使われます。

コンストラクタ

AnimatorControllerコンストラクター

Public 関数

AddEffectiveStateMachineBehaviourAdds a state machine behaviour class of a specific type to the AnimatorState for layer layerIndex. This method should be used when you are dealing with synchronized layer and would like to add a state machine behaviour on a synchronized layer. Note that there is no corresponding "Remove" method. To remove a state machine behaviour, use Object.Destroy.
AddLayerレイヤーをコントローラーに加えるためのユーティリティ関数です。
AddMotionMotion に対する新しいステートを作成するユーティリティ機能です。
AddParameterコントローラーにパラメーターを追加するためのユーティリティ機能です。
CreateBlendTreeInController新しい AnimatorState にブレンドツリー(BlendTree)を作成します。
GetBehaviours T 型にマッチする、または T 型派生のすべての StateMachineBehaviour を返します。
GetStateEffectiveBehavioursアニメーターのステート(AnimatorState)に効果的なステートマシンの振る舞い(Behaviour)リストを取得します。振る舞いは、アニメーターのステートマシン(AnimatorStateMachine )内かアニメーターレイヤーのオーバーライド(ovverride)内のいずれかで格納されます。効果的に使える振る舞い(Behaviour)リストを取得するために、この機能を使用します。
GetStateEffectiveMotionアニメーターのステートのために効果的に Motion(動作)を取得します。Motion(動作)はアニメーターのステートマシン(AnimatorStateMachine)かアニメーターレイヤーのオーバーライド(ovverride)モードで格納されます。効果的に使える Motion(動作)を取得するために、この機能を使用します。
MakeUniqueLayerNameユニークなレイヤー名を作成します。
MakeUniqueParameterNameユニークなパラメータ名を作成します。
RemoveLayerコントローラーからレイヤーを削除するためのユーティリティ機能です。
RemoveParameterコントローラーからパラメーターを削除するためのユーティリティ機能です。
SetStateEffectiveBehavioursアニメーターのステート(AnimatorState)に効果的なステートマシンの振る舞い(Behaviour)リストを設定します。振る舞いリストは、アニメーターのステートマシン(AnimatorStateMachine)内かアニメーターレイヤーのオーバーライド(ovverride)内のいずれかで格納されます。効果的に使える振る舞い(Behaviour)リストを設定するために、この機能を使用します。
SetStateEffectiveMotionアニメーターのステートのために効果的な Motion(動作)を設定します。Motion(動作)はアニメーターのステートマシン(AnimatorStateMachine)かアニメーターレイヤーのオーバーライド(ovverride)モードで格納されます。効果的に使える Motion(動作)を設定するために、この機能を使用します。

Static 関数

CreateAnimatorControllerAtPath与えられたパスを使用してアニメータコントローラ(AnimatorController)を作成します。
CreateAnimatorControllerAtPathWithClip指定されたパスでアニメータコントローラー(AnimatorController)を作成し、アニメーションクリップ(AnimationClip)でステートを加える機能を持つアニメータのステートマシン(AnimatorStateMachine)を使用し自動的にアニメータのレイヤーを作成します。
CreateStateMachineBehaviourこの機能は、スクリプトで定義するクラスに基づいて StateMachineBehaviour のインスタンスを作成します。
FindStateMachineBehaviourContextこの振る舞い(動作)のオーナーを検索するために、この機能を使用します。

継承メンバー

変数

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameオブジェクト名
animationClipsRetrieves all AnimationClip used by the controller.

Public 関数

GetInstanceIDGets the instance ID of the object.
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 のオブジェクトをクローンします

Operator

boolオブジェクトが存在するかどうか
operator !=二つのオブジェクトが異なるオブジェクトを参照しているか比較します
operator ==2つのオブジェクト参照が同じオブジェクトを参照しているか比較します。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961