Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity GetComponent

using UnityEngine;
using System.Collections;

public class YetAnotherScript : MonoBehaviour
{
    //Create Object which get component from other Object
    //Put script and object 
    //enter Playmode to test component
    public GameObject objectToFind;

    public AudioSource audioSource;
    private void Start()
    {
        audioSource = objectToFind.GetComponent<AudioSource>();
    }
}
 
PREVIOUS NEXT
Tagged: #unity #GetComponent
ADD COMMENT
Topic
Name
7+6 =