Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning C# by Developing Games with Unity 5.x - Second Edition

You're reading from  Learning C# by Developing Games with Unity 5.x - Second Edition

Product type Book
Published in Mar 2016
Publisher Packt
ISBN-13 9781785287596
Pages 230 pages
Edition 2nd Edition
Languages

Table of Contents (20) Chapters

Learning C# by Developing Games with Unity 5.x Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Discovering Your Hidden Scripting Skills and Getting Your Environment Ready 2. Introducing the Building Blocks for Unity Scripts 3. Getting into the Details of Variables 4. Getting into the Details of Methods 5. Lists, Arrays, and Dictionaries 6. Loops 7. Object, a Container with Variables and Methods 8. Let's Make a Game! – From Idea to Development 9. Starting Your First Game 10. Writing GameManager 11. The Game Level 12. The User Interface 13. Collectables — What Next? Index

Working with C# script files


Until you learn some basic concepts of programming, it's too early to study how scripts work, but you still need to know how to create one.

There are several ways of creating a script file using Unity:

  1. In the menu, navigate to Assets | Create | C# Script.

  2. In the Project tab, navigate to Create | C# Script.

  3. Right-click in the Project tab, and from the pop-up menu, navigate to Create | C# Script.

All of these ways create a .cs file in the Unity Assets folder. From now on, whenever I tell you to create a C# script, use whichever method you prefer.

Lots of files can create a mess

As our Unity project progresses, we will have lots of different types of files in the Project view. It's highly recommended that you keep a clean and simple folder structure in your project.

Let's keep our scripts in the Scripts folder, textures in Textures, and so on so that it looks something like this:

From now on, let's not keep any loose files in the Assets folder.

Why does my Project tab look different?

Unity allows us to customize the user interface. Everyone has their own favorite. I prefer a one-column layout Project tab instead of Unity's default two-column layout. To change this, open the context menu in the top-right corner of the Project tab, as shown in this screenshot:

When working in a team, you will notice that every team member has his/her own layout preference. A level designer may like to use a big Scene tab. An animator will probably use the Animation and Animator tabs. For a programmer like you, all tabs are fairly important. However, the Console tab is the one that you will use a lot while testing your code. I mostly prefer a layout divided into four columns—from left to right, Scene and Console, then Hierarchy, then Project and finally Inspector. It looks like what is shown in the following screenshot:

Note

If you have trouble with moving tabs around, refer to the Customizing Your Workspace chapter in the Unity Manual.

Feel free to change the interface however you want. But try to keep the Console tab visible all the time. We will use it a lot throughout the book. You can also save your custom layouts in the Layout menu.

Note

The Console tab shows messages, warnings, errors, or debug output from your game. You can define your own messages to be sent to the console.

You have been reading a chapter from
Learning C# by Developing Games with Unity 5.x - Second Edition
Published in: Mar 2016 Publisher: Packt ISBN-13: 9781785287596
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 €14.99/month. Cancel anytime}