GameObjectRecorder.BindComponentsOfType
Declaration
public void BindComponentsOfType(GameObject target, bool recursive);public void BindComponentsOfType(GameObject target, Type componentType, bool recursive);Параметры
| Параметр | Описание |
|---|---|
| Цель | ,root, или любой из его дочерей. |
| рекурсивный | Обязывает также Цельдочерние свойства преобразуют свойства, если установлено true. |
| componentType | Тип компонента. |
Описание
Добавляет привязки для всех свойств первого компонента типа T, найденного в Цель, а также для всех дочерей Цель, если рекурсивный является true.
using UnityEngine; using UnityEditor; using UnityEditor.Animations;
public class BindComponentScript : MonoBehaviour { void Start() { var recorder = new GameObjectRecorder(gameObject);
// Add bindings for all the properties of the Transform and BoxCollider components. recorder.BindComponentsOfType<Transform>(gameObject, false); recorder.BindComponentsOfType<BoxCollider>(gameObject, false); } }
Также можно использовать негенерический метод, в котором typeof() получит Тип компонента.
В этом примере получается точно такой же результат, как и в примере выше:
using UnityEngine; using UnityEditor; using UnityEditor.Animations;
public class BindComponentNonGenericScript : MonoBehaviour { void Start() { var recorder = new GameObjectRecorder(gameObject);
recorder.BindComponentsOfType(gameObject, typeof(Transform), false); recorder.BindComponentsOfType(gameObject, typeof(BoxCollider), false); } }