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

Veröffentlicht am: 14 Januar 2021
auf dem Kanal: 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  
____________________________________________________________


Auf dieser Seite können Sie das Online-Video Drag and Drop a GAMEOBJECT or COMPONENT in an INSPECTOR VARIABLE in Unity mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer GDT Solutions ES 14 Januar 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 4,547 Mal angesehen und es wurde von 47 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!