Welcome back to part two of this lecture and now we're still continuing on our controller code.
So this controller code is going to turn the car and the dinosaur panels on and off as well as control
which image trackers are on or off.
Now each time you load in each truck you have to load another one in and this can take a little bit
of time.
So we're going to create a booth at the top called loading Lesko is loading tracker and we'll initially
set this to fall so we're going to use this switch to control when the panels become available and those
sorts of things.
Now first of all let's get rid of this stuff not die because we're not going to use those.
But we are going to include three more public methods so the first one will be public for aid on track
car.
And the Axwell just copy what we've already got and put this down here and we'll put on track dynamite
and then we'll put in and public FOID on targets loaded.
OK let's work on the on track method.
This is going to be cold when we click on the collar button.
So what it has to do is turn on the Mokka set for the cause and also display the panel with the images
on it for us.
So I'm just going to add in this sort of code it's going to first check if the cat Cheka is enabled
or not enabled then we're going to do this as well make sure that is loading tracker is false so that
we're not in the middle of loading another tracker will allow you to turn on a new set.
Now when this is loading it's going to first of all switch is loading Trischka over to true.
So as the new set of markers get loaded that remains true and we will turn it defaults in a little moment.
Now at this same time the car panel which is our panel up the top with all images on it will become
active and visible and the dorsal panel will become inactive and invisible and then we will turn the
car Trickers enabled to true so that will turn on that script and start the tracking for it.
Now the one for the dinosaur is practically the same.
It's just focused on the dinosaur instead of the car and it looks like this.
So if the domino tracker hasn't already been enabled and we're not loading something then sit lighting
to turn turn the car panel off turn the dye panel on and then turn the dawn a Trekker on as well.
And I will touch down here.
Now finally we've been setting this is loading tracker.
True true.
When we start to load a new set.
So when does it get set back to false for us.
Well it happens down in these on targets loaded and what we do is we give this to we could shoot in
a new place that we haven't looked at before.
Which will then automatically run this method for us when we could shoot has finished doing its thing
with the Mochis so we're gonna just grab this up here and we're going to put is loading tracker equal
to false because the loading of the trackers or the targets is done by the time this method is getting
cold.
OK so let's say that they will go back into unity and we'll set it all up.
The first thing we'll do is go onto our image check for cars and inspect.
Do you want to look down until you find an on targets loaded event and that's the event where you put
that new method that we wrote into.
So just click on Add and then drag and drop the controller into the space that's available then look
for that particular function in.
So that function is control and on targets loaded.
So add that in there and then wire in here and make sure you disable the image check a script and set
the concurrent toggles to three.
You want to do exactly the same thing for the dog hours as well.
While you're any ages check that you've got the correct set of concurrent targets for each of those
trackers and that you initially have the image tracker turned off.
All right so now it's on target loaded.
Plus drag and drop the controller.
And then we go controller and on Target's loaded.
Now to make the buttons activate it's pretty much the same deal.
Click on the button over in the inspector.
You want to go down until you find the on click area then click on the little plus sign to add in a
new method to code.
We're going to call our method that's attached to a controller so you drag the control up.
This is pretty much the same deal is as adding the events into the image checkers et cetera.
So go to a function control.
And this is the car button.
So it's on track ka.
Then we want to do the diner button and the controller and we fall on the controller and the on track
Dorner.
OK so that's all set up and ready to try out.
So let's press play and we want to be just trying to find the mark because we're going to start just
by showing these buttons to see if they work.
So don't always come up and you can say that the camera even found the door are there for us so those
are good markers those from the dinosaurs on them go back to the kawan.
OK so now let's see if we can find that card should have loaded all those cars up yet.
Spawning a couple of them there.
That's pretty good.
And then if we switch back to the door I know it will immediately get rid of any cars that were there
anyway because it loses all those trekkers that it had in memory and loads in the new set.
OK so that is how you would set up an application with multiple different image trackers or sets of
trackers that are in there when you want to have lots and lots of them but you can't really afford to
have them all active at the same time.