Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Game Development with Unity for .NET Developers

You're reading from   Game Development with Unity for .NET Developers The ultimate guide to creating games with Unity and Microsoft Game Stack

Arrow left icon
Product type Paperback
Published in May 2022
Publisher Packt
ISBN-13 9781801078078
Length 584 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jiadong Chen Jiadong Chen
Author Profile Icon Jiadong Chen
Jiadong Chen
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Part 1: Basic Unity Concepts
2. Chapter 1: Hello Unity FREE CHAPTER 3. Chapter 2: Scripting Concepts in Unity 4. Part 2: Using C# Scripts to Work with Unity's Built-In Modules
5. Chapter 3: Developing UI with the Unity UI System 6. Chapter 4: Creating Animations with the Unity Animation System 7. Chapter 5: Working with the Unity Physics System 8. Chapter 6: Integrating Audio and Video in a Unity Project 9. Part 3: Advanced Scripting in Unity
10. Chapter 7: Understanding the Mathematics of Computer Graphics in Unity 11. Chapter 8: The Scriptable Render Pipeline in Unity 12. Chapter 9: The Data-Oriented Technology Stack in Unity 13. Chapter 10: Serialization System and Assets Management in Unity and Azure 14. Chapter 11: Working with Microsoft Game Dev, Azure Cloud, PlayFab, and Unity 15. Other Books You May Enjoy

Creating a script and using it as a component

In addition to Unity's built-in components, we can also create script components. When you create a script and attach it to a GameObject, you can see the component you created in the GameObject's Inspector window, just like Unity's built-in components.

How to create a new script in Unity

It is very easy to create a new C# script in Unity. I will introduce two different ways to do it.

Firstly, you can right-click the Project panel in the Unity Editor, and then a menu will pop up. You only need to select Create | C# Script, then the Unity Editor will create a C# file in the folder identified in the Project panel.

Figure 2.31 – Creating a new C# script from the Create menu

The filename of the new script is NewBehaviourScript.cs by default. You can change the name when creating it.

Figure 2.32 – Changing the name of the script when creating it

For example...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime