Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Learning C# by Developing Games with Unity
  • Toc
  • feedback
Learning C# by Developing Games with Unity

Learning C# by Developing Games with Unity

By : Harrison Ferrone
4.4 (47)
close
Learning C# by Developing Games with Unity

Learning C# by Developing Games with Unity

4.4 (47)
By: Harrison Ferrone

Overview of this book

It's the ability to write custom C# scripts for behaviors and game mechanics that really takes Unity the extra mile. That's where this book can help you as a new programmer! Harrison Ferrone, in this seventh edition of the bestselling series will take you through the building blocks of programming and the C# language from scratch while building a fun and playable game prototype in Unity. This book will teach you the fundamentals of OOPs, basic concepts of C#, and Unity engine with lots of code samples, exercises and tips to go beyond the book with your work. You will write C# scripts for simple game mechanics, perform procedural programming, and add complexity to your games by introducing intelligent enemies and damage-dealing projectiles. You will explore the fundamentals of Unity game development, including game design, lighting basics, player movement, camera controls, collisions, and more with every passing chapter. Note: The screenshots in the book display the Unity editor in full-screen mode for a comprehensive view. Users can easily reference color versions of images by downloading them from the GitHub repository or the graphics bundle linked in the book.
Table of Contents (18 chapters)
close
15
Pop Quiz Answers
16
Other Books You May Enjoy
17
Index

Firing events

C# events allow you to essentially create a subscription system based on actions in your games or apps. For instance, if you wanted to send out an event whenever an item is collected, or when a player presses the spacebar, you could do that. However, when an event fires, it doesn’t automatically have a subscriber, or receiver, to handle any code that needs to execute after the event action.

Any class can subscribe or unsubscribe to an event through the calling class the event is fired from; just like signing up to receive notifications on your phone when a new post is shared on Facebook, events form a kind of distributed-information superhighway for sharing actions and data across your application.

Declaring events is similar to declaring delegates in that an event has a specific method signature. We’ll use a delegate to specify the method signature we want the event to have, then create the event using the delegate type and the event keyword:

...
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete