class in UnityEngine
/
Inherits from:Object
/
Implemented in:UnityEngine.AnimationModule
Suggest a change Success!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 Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close Your name Your email Suggestion* DescriptionA representation of the Animator Controller, optimized for runtime.
At runtime, Unity replaces the AnimatorController class with this optimized runtime class. Access to Editor functions, such as modifying the structure of an Animator Controller, are restricted.
This optimized class provides the following different ways to access and modify an Animator Controller at runtime:
The following example demonstrates how to spawn GameObjects at runtime. Each GameObject is animated with different Animator Controllers.
// This script spawns random zombie prefabs at runtime. The Animator component for // each zombie is assigned a different Animator Controller based on the zombie type. using UnityEngine; public class RandomZombieSpawner : MonoBehaviour { // The prefab of the zombie Game Object containing an Animator component. public GameObject zombiePrefab; // Store the references to the Animator Controllers for the different zombie types that can be spawned public RuntimeAnimatorController standardZombieAnimator; public RuntimeAnimatorController bigZombieAnimator; public RuntimeAnimatorController smallZombieAnimator; void Start() { for (var i = 0; i < 10; i++) { SpawnZombie(); } } public void SpawnZombie() { // Instantiate a new zombie Game Object at a random position GameObject zombie = Instantiate(zombiePrefab, new Vector3(Random.Range(0f, 10f), 0, Random.Range(0f, 10f)), Quaternion.identity); Animator animator = zombie.GetComponent<Animator>(); // Randomly determine the type of zombie and assign its Animator with its corresponding Animator Controller. var randomValue = Random.Range(0f, 1f); if (randomValue <= 0.3f) { animator.runtimeAnimatorController = bigZombieAnimator; zombie.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } else if (randomValue <= 0.6f) { animator.runtimeAnimatorController = smallZombieAnimator; zombie.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); } else { animator.runtimeAnimatorController = standardZombieAnimator; } } }Properties Property Description animationClips Retrieves all AnimationClip used by the controller. Inherited Members Properties Property Description hideFlags Should the object be hidden, saved with the Scene or modifiable by the user? name The name of the object. Public Methods Method Description GetInstanceID Gets the instance ID of the object. ToString Returns the name of the object. Static Methods Method Description Destroy Removes a GameObject, component or asset. DestroyImmediate Destroys the object obj immediately. You are strongly recommended to use Destroy instead. DontDestroyOnLoad Do not destroy the target Object when loading a new Scene. FindAnyObjectByType Retrieves any active loaded object of Type type. FindFirstObjectByType Retrieves the first active loaded object of Type type. FindObjectsByType Retrieves a list of all loaded objects of Type type. Instantiate Clones the object original and returns the clone. InstantiateAsync Captures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation. Operators Operator Description bool Does the object exist? operator != Compares if two objects refer to a different object. operator == Compares two object references to see if they refer to the same object.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4