【Accessing Components】
The most common case is where a script needs access to other Components attached to the same GameObject.A Component is actually an instance of a class so the first step is to get a reference to the Component instance you want to work with. This is done with theGetComponent function. Typically, you want to assign the Component object to a variable, which is done in C# using the following syntax:
Once you have a reference to a Component instance, you can set the values of its properties much as you would in the Inspector:
An extra feature that is not available in the Inspector is the possibility of calling functions on Component instances: