UnityEngine.GameObject.GetComponent C# (CSharp) Method

GetComponent() public method

public GetComponent ( Type type ) : Component
type System.Type
return Component
		public Component GetComponent(Type type){}
		public T GetComponent(){}

Same methods

GameObject::GetComponent ( string type ) : Component
GameObject::GetComponent ( ) : T

Usage Example

コード例 #1
1
 void OnGUI()
 {
     GUILayout.Box("Legacy Effect Scale Editor", GUILayout.Width(295));
     EditorGUILayout.Space();
     Effect = (GameObject)EditorGUILayout.ObjectField("Legacy Effect", Effect, typeof(GameObject), true); 
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     Scale = float.Parse(EditorGUILayout.TextField("Scale Change Value", Scale.ToString()));
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     if (GUILayout.Button("Scale Apply", GUILayout.Height(70))) 
     {
         if (Effect.GetComponent<csLegacyEffectChanger>() != null)
             Effect.GetComponent<csLegacyEffectChanger>().LegacyEffectScaleChange(Scale);
         else
         {
             Effect.AddComponent<csLegacyEffectChanger>();
             Effect.GetComponent<csLegacyEffectChanger>().LegacyEffectScaleChange(Scale);
         }
         DestroyImmediate(Effect.GetComponent<csLegacyEffectChanger>());
     }
 }
All Usage Examples Of UnityEngine.GameObject::GetComponent