Join Kelley Hecker for an in-depth discussion in this video Attaching a script, part of Scripting Unity with C#.
- In most cases you'll be attaching your…script to a GameObject in your scene.…The easiest way to do this is to…find your script in the project window…and click and drag it onto an object in the Hierarchy.…Another way to add a script is to click on the GameObject…and in the Inspector click Add Component.…Then find and click on the script you want to add.…As you can see a GameObject can have…multiple instances of the same script.…You can also add a script by going…to the Component menu, Scripts,…and clicking on the script that you want to add.…
Either of these methods also lets you…add a script to multiple objects at a time.…If I create some more GameObjects,…and select them all by holding down shift,…I can click on Add Component in the Inspector,…and add my script to all of them at once.…You can remove a script from an object…by clicking on the gear icon next to the script name…and selecting Remove Component.…
You can also reorder your scripts…by using the Move Up and Move Down commands.…You can even copy a script…
- Defining classes and variables
- Attaching scripts to objects
- Understanding MonoBehaviour class
- Using the Unity Scripting API
- Importing assets
- Using a singleton pattern to manage game state
- Creating an event
Skill Level Intermediate
Advanced Unity 3D Game Programmingwith Michael House3h 45m Advanced
Creating Mobile Games with Unitywith Kelley Hecker1h 12m Intermediate
1. Your First Script
3. Built-In Unity Classes
Picking up coins4m 8s
5. Events and Delegates
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.