GameObject.AddComponent
Deklarasyon
public Component AddComponent(Type componentType);
Açıklama
component type türünde bir bileşen sınıfını GameObject'e ekler. C# kullanıcıları, bu metodun jenerik versiyonunu kullanabilir.
using UnityEngine; using System.Collections; public class AddComponentExample : MonoBehaviour { void Start() { SphereCollider sc = gameObject.AddComponent(typeof(SphereCollider)) as SphereCollider; } }
Bir bileşeni kaldırmak için RemoveComponent() yoktur, bunun yerine Object.Destroy kullanın.
Deklarasyon
public T AddComponent();
Açıklama
Bu metodun jenerik versiyonu.
using UnityEngine; using System.Collections; public class AddComponentExample : MonoBehaviour { void Start() { SphereCollider sc = gameObject.AddComponent<SphereCollider>(); } }
Eskimiş
Deklarasyon
public Component AddComponent(string className);
Açıklama
className adlı bir bileşen sınıfını GameObject'e ekler.
Kullanımdan kaldırıldı: Bunun yerine AddComponent(Type) veya bu metodun jenerik versiyonunu kullanın.
Bu blog Unity Docs'un Türkçeye çevrilmiş halidir.
Yorumlar
Yorum Gönder