• G#

GameObjectRecorder.BindKomponenOfType

Declaration

publik void BindComponentsOfType( GameObject target, bool recursive);

Declaration

publik void BindComponentsOfType( GameObject target, Jenis componentType, bool recursive);

Parameters

target root atau anak-anaknya.
recursive Binds juga sifat transformasi anak-anak target ketika diatur ke true.
componentType Jenis komponen.

Description

Menambahkan ikatan untuk semua sifat komponen pertama dari tipe T ditemukan di target, dan juga untuk semua anak-anak target jika recursive adalah 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); } }

Hal ini juga dimungkinkan untuk menggunakan metode non-generic, dalam kasus mana typeof() akan mendapatkan Jenis komponen.

Contoh ini mendapatkan hasil yang sama seperti contoh di atas:

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); } }