Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning C# by Developing Games with Unity 2019

You're reading from   Learning C# by Developing Games with Unity 2019 Code in C# and build 3D games with Unity

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781789532050
Length 342 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Harrison Ferrone Harrison Ferrone
Author Profile Icon Harrison Ferrone
Harrison Ferrone
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Section 1: Programming Foundations and C# FREE CHAPTER
2. Getting to Know your Environment 3. The Building Blocks of Programming 4. Diving into Variables,Types, and Methods 5. Control Flow and Collection Types 6. Working with Classes, Structs, and OOP 7. Section 2: Scripting Game Mechanics in Unity
8. Getting Your Hands Dirty with Unity 9. Movement, Camera Controls, and Collisions 10. Scripting Game Mechanics 11. Basic AI and Enemy Behavior 12. Section 3: Leveling Up Your C# Code
13. Revisiting Types, Methods, and Classes 14. Exploring Generics, Delegates, and Beyond 15. The Journey Continues 16. Completed Game Files 17. Supplementary Classes 18. Pop Quiz Answers 19. Other Books You May Enjoy

Utilities

Demonstrates the uses of a static class, as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public static class Utilities
{
public static int playerDeaths = 0;

public static string UpdateDeathCount(out int countReference)
{
countReference = 1;
return "Next time you'll be at number " + countReference;
}

public static void RestartLevel()
{
SceneManager.LoadScene(0);
Time.timeScale = 1.0f;

Debug.Log("Player deaths: " + playerDeaths);
string message = UpdateDeathCount(out playerDeaths);
Debug.Log("Player deaths: " + playerDeaths);
}

public static bool RestartLevel(int sceneIndex)
{
if(sceneIndex < 0)
{
throw new System.ArgumentException("Scene index cannot be negative");
}

SceneManager.LoadScene(sceneIndex);
Time.timeScale = 1...
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 $19.99/month. Cancel anytime
Banner background image