Gameplay programming
Resources and workflows for creating C# scripts in Unity to control elements of your application.
Read time 2 minutesLast updated 7 days ago
Programming in Unity refers to authoring your project's functionality in code rather than through the Unity Editor UI. This allows you to go beyond what can be done in the Editor UI alone. Interacting directly with the public Unity APIs allows for finer control and a greater degree of customization.
Learning to program in particular languages is beyond the scope of this section. However, there are many books, tutorials, and other resources for learning how to program with Unity. Refer to Unity Learn for further details.
Topic | Description |
|---|---|
| Get started with programming in Unity | Get started with creating, naming, and editing your first Unity scripts. |
| Programming with math | Use Unity's mathematical APIs to apply trigonometric, logarithmic, and other functions in your application, move objects with vectors, and generate random values. |
| Control when your code updates | Understand the order in which Unity executes your script components and the lifecycle callbacks within those scripts during the runtime application loop. |
| Manage time and frame rate | Understand how Unity measures time so you can manage the rate at which time passes in your application and ensure values update according to the appropriate time scale. |
| Distribute work across threads | Move work off the main thread so that expensive operations don't block frame updates. |
| Split tasks across frames with coroutines | Split the execution of a task synchronously across multiple scenes with coroutines. This can be useful for tasks that should progress gradually over several frames, such as a fade out effect. |
| Handle type data generically with Unity Properties | Use the Unity Properties API to generically discover and manipulate object properties at runtime. |
| Interacting with web servers | Use the UnityWebRequest system to allow your application to interact with a web server via HTTP. |
Additional resources and examples
- 📖 E-Book:Use a C# style guide for clean and scalable game code (Unity 6 edition)
- 📖 E-Book:Level up your code with design patterns and SOLID
- 📖 E-Book:Create modular game architecture in Unity with ScriptableObjects
- 📖 E-Book:Introduction to the Data-Oriented Technology Stack for advanced Unity developers
- 💡 Resources:Unity Learn Scripting tutorials
- 💡 Resources:An example of a Unity C# code style guide
- ⚙️ Sample project:Level up your code with design patterns and SOLID
- ⚙️ Sample project:ScriptableObjects Paddle Ball project
- 📺 Video:Tips for creating your own C# code style guide
- 📺 Video:Level up your code with game programming patterns: Command pattern
- 📺 Video:Level up your code with game programming patterns: Factory pattern
- 📺 Video:Level up your code with game programming patterns: Model-view-presenter
- 📺 Video:Level up your code with game programming design patterns: Object pool
- 📺 Video:Level up your code with game programming patterns: Pattern combo
- 👥 Community:Scripting section at Unity Discussions