Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
That you may know those guys that when we actually play here
The Clare
Loses references to a couple things
When we actually go to the next scene
Tell before we enter the new level or the new scene
I've got the new player here
And you know that we have some references here to the coins the health bar and the inventory on the radio
How far coins in inventory item
So because these UI elements
Are going to destroy when we actually go to a new scene
Because we haven't actually Mark them to not destroy
When we enter the new scene
We are going to lose those references ok
Even though level 2 does include a new UI game object with all of the various items inside of it
Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1
The player here is trying to find a reference to the ones that were on a last scene
With a missing image
Missing image in missing text
So when we try and collect something is confused it doesn't know where I put it right where do I put the health where do I put the UI
So what we need to do
Is creates something called
A game manager
Don't wait to talk about the game manager a lot of you probably wondering when we were going to do a game manager
I want to wait because this is the perfect example of why you need a game manager
Game manager is a great place to store references to various UI elements
Maybe some inventory as well some additional inventory to reply or maybe when I move all of the players inventory
To a game manager script
Islam things you could do with a game images script
I'm basically a game manager a good way of thinking of it is like a backpack for the player or for the game
So as the player is not destroyed in moves from scene to scene
The game manager is going to follow along with him storing references to various values game objects UI
Etc
So basically what we want to do here is Rachel and move all of our UI elements into a new game on
Make sure everything's deselected here
I'm going to create an empty gameobject I'm going to call this
Game manager
What you want to do is just make sure that the position is zero
By the way guys have you noticed that when you create a new game object
And it says recttransform
That's because when you are selected and you create an empty child
It's actually creating in empty gameobject with a rect transform
By default because we were inside of a UI canvas just be careful when you're creating new game objects from here
Solicitors in game managing just make sure everything is $0 and the scale is 31
The reason why is because we're going to drag the UI prefab and put it inside of the game manager
Ok
So why are we just making the UI a game manager
What's because we can put other game objects inside of this game manager
Any game it treated like a backpack that follows the play around
The movie the other items may be a
Cheat codes prefab or a main menu or a Paz menu
Can I see you have none of those destroy
Well you will have them inside of the game manager here
Ok it's the next thing I want to do is just create
Can you see shop script
We're going to call it
Game
Manager what happened
By default unity knows that game managers are important
Create a Cooler
I can't hear
Hey hey this is the game manager
There is no limitation about what you can do with the game and you can do whatever you want with the game manager in
Play a game manager is going to be
Different
Turn developer you might read it totally different then I will
Just drag this game manager
Emergency
And wrinkly office manager here
And the first thing I want to do guys as we want this team manager to follow the player around wherever he goes right
So what does that mean
Will it put a new player in you remember what we did here
On start
We said don't destroy on load ok so do that
On start don't destroy on load
What do you not want to destroy
This game magic
Anytime you have a lowercase game object instead of a gameobject means you referencing this game object
That out
Down Under Fire
We renamed it
Gohenry name it
Play Magic
Equals
New game manager
You can have it whenever you want it you can name it
The master Dee manager or original Game manager
Or maybe even getting manager but I'm going to rename a new game manager and
The player is renamed to new player so anytime you see the word new in front of a game object it means that it's fear
No one
And it's not going to destroy and load of any scenes
Ok
That way when we go into a new scene
The game manager on the new scene is going to go hey there something called you gave manager and not going to be in this scene
What will destroy itself
Where to take this awake function and do the same thing we did
With new player
Does copy that
Go back to a game manager
A member of week happens before star
Ok so the moment we hit play
We're gonna run this
If there's a game object called new game manager
Destroying
What if we hit play
And we load into the very first level
Nothing's going to happen here because there's nothing called new game manager
Dennis going to jump to the start function here
Anything to say
Don't destroy me and then rename me
Play any other game managers better in another scene
Find your game manager in going to get this
Team logically working with
For the new player
There's one more thing you want to do
When are we going heading created Singleton for the game manager as well
So we can reference the game manager
Just copy this
From the new player script
Just paste it right here
This changed
The words
So we're just going to create
An instance
Navigate manage
Is Singleton instance
You just change out the word here
Is it
So now look at this one
I can reference the game manager
Whenever I want to
So for example in new player I could go game manager that instance whatever
This is where we can store certain variables in certain references
And maybe we don't want to store inside of the player ok
What's go ahead in test this out
Before we had play I just make sure level 1 and level 2 match
But save level 1 and level 2 Unit 2
Does an actually have a game manager
Why do we need a game in level 2
Who won the game manager just going forward
I mean honestly other than the environment changing we really want everything to be identical to level 1 we want the same
We want the same game manager
We want to see new y Paz menu etc ok
So if we hit play on level 22 actually tested out
Where I can get the same behaviour as level one
Level 1 in the game manager now right
I want to do is make sure the level two matches level one
In terms of the UI the player the game manager etc
So what we going to do is win a drag the game manager
Over to a prefabs folder
Now we have
A game manager right
So what you would do is if you got a little to make sure you save the level one
If you got a lot of two words going to delete the UI
Going to drag the game manager
Again I need to clarify as much as I possibly can hear
We're only putting a game manager instead of level 2
So that we can test level two
Or if we have a saved game and you're on level 2
If we load Amelia from the main menu what we want to make sure everything in level 2 is there if we
Right
Just because the game manager in the player
Iron level 1 in will load in the level 2
Does it mean that we don't also need a game manager in a player in level 2
Even when we load into this scene in me Lee from the main menu
If that doesn't make sense guys just keep following along with me I will make sense especially when we start flashing out this prototype
In making it a full-time game
Ok so let's actually test at level 1 and level 2 and see if the game manager follows the player around
Alright
First off what's a new player and new game manager have been placed inside of the don't destroy on load
Section of a hierarchy that's great that means that these two game objects and their children
Well pretty much
Survive
Is a good way of putting
A new scene load right
Ok so we get the key was jump on over the next level
So if we jump into the next level
It looks like
Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1
Alright but you are works perfectly
And when we collect items
Rui
Still works that's perfect
So you may wonder is the game manager just an empty script
Is it just an empty gameobject that stores the other game objects
The answer is no you actually want to store variables in references and maybe some inventory
Game manager
Mainly to make you feel saying while you're creating your game
Is really about organisation of you game for the long term
Not going to change anything for the players experience
Variables
In the new players script
Can we actually store
In the game manager
Will you notice that we have an inventory item image reference then it's just referencing the inventory item
So that we can actually swap it out
Only collecting inventory item
And we also have references in the new player script for the health bar in the coins
Really good examples of things we should be storing inside of a game manager not necessarily the news
Tell bear with me for just a second as we going to new player
In actually move these three variables
Inside of the game manager
Ok
Take these to hear the health bar and the coins text
When you copy those
Pace them is over game manager
That's about right here save those
And what else
Inventory item image
Will Take That
Save it
And then I stand here as well
I don't worry guys you noticed that we have the red zig zag that's because we need to go to show potential fixes
And also his using unityengine.ui is the solution here so why
Add
The namespace reference appear
That means we can now use these UI references
Ok
Ok
So
Question back in unity and take a look
Everything is working properly it looks like and get a tonne of errors which can make you
Play don't worry guys the solution here is pretty simple like
It says the name health bar does not exist in the current context
Ok so it looks like because we moved the health bar reference
Into the game manager
Window actually make sure
Changing
How we get this reference ok
1-hour interrogate manager so how do we get it we go game manager incidents health bar
Into all we have to do is just paste this in front of all of these
References to the UI elements
Because now those references are stored
Inside of a game manager
Ok
Alright
Hopefully
Everything is cleared out
Now
Wigan tip Leigh
Looks like we have some no references here
What's happening is we actually having to find
Inside of the new game manager
Where all of these are
So we move them over to the manager but we need to make sure that we tell the game manager what the reference
Actually pretty simple just drag health bar here
Text here
An inventory item image
Here
Nearest Aldi's turned bold again that's because we just change
St. Aspen
Navigate to the prefab
We want to make sure that we apply all those changes to the everyday manager prefab in every scene
Handel's references
Thing is that these references
Global rights of a level two
Can I go to the game manager here
It's not referencing the health bar from level one is actually referencing is child
And child and Child
Alright so let's go level one here and we can clear up these errors
Can you play
Alright
Looks like
Everything is in working order
Just double check here go to the next scene
Perfect alright
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.