filmov
tv
How to use GAMEOBJECTS and COMPONENTES from the Scene in scripts in Unity, Null reference exception

Показать описание
Practically anything we want to do in Unity will require a script that is responsible for performing these tasks, these scripts will generally work with the objects in the scene and its components, for example if we want to control a ship we will read the motion inputs and apply the movement to the object of the ship with a certain speed to make this object move across the screen.
This video is the introduction to a series that focuses on obtaining those objects and components of the scene, how we can do to work with them from a Script, this is known as REFERENCE in programming, having an object or component stored in a variable allows us to access their information and use their functions, if they are public, this is done by applying the DOT OPERATOR on the variable that has stored the object or the specific component that we want to read or execute function.
References in programming is a very important concept in object oriented programming, in this series we are going to see different methods to achieve the same thing, to have the reference of a GameObject or scene component in a variable defined in a script.
In this video we also see what console errors can appear when we do not have the object reference but we still try to use it, the NullReferenceException and UnassignedReferenceException errors.
Introductory article of this series:
____________________________________________________________
*LINKS*
____________________________________________________________
#EN
This video is the introduction to a series that focuses on obtaining those objects and components of the scene, how we can do to work with them from a Script, this is known as REFERENCE in programming, having an object or component stored in a variable allows us to access their information and use their functions, if they are public, this is done by applying the DOT OPERATOR on the variable that has stored the object or the specific component that we want to read or execute function.
References in programming is a very important concept in object oriented programming, in this series we are going to see different methods to achieve the same thing, to have the reference of a GameObject or scene component in a variable defined in a script.
In this video we also see what console errors can appear when we do not have the object reference but we still try to use it, the NullReferenceException and UnassignedReferenceException errors.
Introductory article of this series:
____________________________________________________________
*LINKS*
____________________________________________________________
#EN
Комментарии