Components in Unity
Treehouse
Course Summary
Every GameObject in Unity can use components, which are pieces of code that can change how the game behaves. We'll explore some of the problems that can surface while programming and techniques you can use to untangle your thinking.
-
+
Course Description
About this Course Every GameObject in Unity can use components, which are pieces of code that can change how the game behaves. We'll explore some of the problems that can surface while programming and techniques you can use to untangle your thinking. What you'll learn
- Methods
- Components
- Code Architecture
About the Teacher
Nick is a teacher at Treehouse and an independent game developer. His Twitter handle is @nickrp.
-
+
Course Syllabus
Organizing Code into Methods
It's a lot harder to build on top of a mess than it is to build on a stable foundation. We'll learn how to take an existing Unity project with messy scripts and organize them into scripts that utilize methods. 5 steps- Project Overview 4:07
- Spaghetti Code 5:46
- Organizing GameManager into Methods 8:15
- Organizing ShootArrow into Methods 4:16
- Organizing Code into Methods 5 questions
- Extra Credit Feeling adventurous? Try going back to one of your previous Unity projects and look for code in the Update() method that could be reorganized into smaller methods.
Thinking in Components
Writing methods is a good start, but we can go a step further by segmenting each unique piece of behavior into a new script, and, a new component. By creating individual components that serve a clear singular purpose, we can start to build a library of reusable code. 4 stepsAdding New Behavior
Now that we've organized our code into methods and components, we're ready to start building new behavior. The true test of code quality is how easy it is to change later on, so let's try to add some new features. 3 steps