Drag and Drop a GAMEOBJECT or COMPONENT in an INSPECTOR VARIABLE in Unity

Publicado el: 14 enero 2021
en el canal de: GDT Solutions ES
4,547
47

We see how to DEFINE A VARIABLE inside a Script in Unity, to make this variable APPEAR IN THE INSPECTOR and in this way we can DRAW a GameObject to that variable in the inspector.
This method allows us to store the reference of a GameObject in a GameObject type variable, but we can also store any component we need, for example if we define an AudioSource type variable and we make it appear in the inspector, we can drag a GameObject to that variable, if the GameObject we drag has an AudioSource component in that case Unity will automatically extract the reference of the AudioSource assigned to that GameObject and we will have that specific component of the scene assigned to that variable.

Drag and Drop a GameObject in an inspector variable in Unity is one of the simplest ways to find the reference of an object or component to use in a script, this method requires that such objects and components exist in the scene at the design stage.
If the object that we want to reference does not exist during the design stage, for example an object that is instantiated during the execution of the game or application (at run time) this method of assigning a GameObject in a variable of the inspector will not work.

INTRODUCTION VIDEO OF THE REFERENCE SERIES IN UNITY:
   • Video  

ARTICLE ON HOW TO DRAG AND DROP OBJECTS IN THE INSPECTOR IN UNITY:
https://gamedevtraum.com/en/game-and-...

____________________________________________________________
LINKS

Portfolio: https://gamedevtraum.com/es/portfolio...

LinkedIn:   / gamedevtraum  

Descargas: https://gamedevtraum.itch.io/

Contacto 1: [email protected]

Contacto 2:   / gamedevtraum  
____________________________________________________________


En esta página del sitio puede ver el video en línea Drag and Drop a GAMEOBJECT or COMPONENT in an INSPECTOR VARIABLE in Unity de Duración hora minuto segunda en buena calidad , que subió el usuario GDT Solutions ES 14 enero 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4,547 veces y le gustó 47 a los espectadores. Disfruta viendo!