Reader small image

You're reading from  Unity Certified Programmer Exam Guide - Second Edition

Product typeBook
Published inMay 2022
Reading LevelIntermediate
PublisherPackt
ISBN-139781803246215
Edition2nd Edition
Languages
Right arrow
Author (1)
Philip Walker
Philip Walker
author image
Philip Walker

Philip Walker originally started as a 3D game artist, but then decided he wanted to combine his current skills with coding so that he could see through the majority of his games' and apps' development himself. Philip has worked in various different industries as an artist and as a Unity developer using various types of technology and techniques.
Read more about Philip Walker

Right arrow

Adding a Singleton design pattern

As you will recall, back in Chapter 1, Setting Up and Structuring Our Project, we spoke about design patterns and how useful they are for maintaining our code. One of the design patterns we briefly covered was the Singleton pattern. Without repeating ourselves, the Singleton pattern gives us global access to code that can then be obtained at a point in our game. So, where can we see the benefits of using the Singleton design pattern? Well, we could use it so that Unity always keeps certain scripts accessible, no matter what scene we are in. We have already added a lot of structuring to our game framework and we still have a couple of manager scripts to add, such as ScoreManager and ScenesManager.

Now is a good time to give all of the manager scripts global access to all other scripts in the game. Managers give a general overview of what is going on and steer which way the game needs to go without getting caught up in the details of the other scripts...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Unity Certified Programmer Exam Guide - Second Edition
Published in: May 2022Publisher: PacktISBN-13: 9781803246215

Author (1)

author image
Philip Walker

Philip Walker originally started as a 3D game artist, but then decided he wanted to combine his current skills with coding so that he could see through the majority of his games' and apps' development himself. Philip has worked in various different industries as an artist and as a Unity developer using various types of technology and techniques.
Read more about Philip Walker