WEBVTT

00:06.920 --> 00:07.970
Welcome back.

00:08.300 --> 00:14.870
Now, if you play tested a little bit, you might have noticed a funny issue with the sounds that we're

00:14.870 --> 00:15.590
playing.

00:15.830 --> 00:24.200
For one, if we take this spell, press, equip and equip it to the left mouse button, we get that

00:24.200 --> 00:24.650
sound.

00:24.650 --> 00:30.860
It's not too loud, but if we close the menu and open it again and do this again, it's louder.

00:30.860 --> 00:38.240
And if we do it again, it's louder and it's louder still.

00:38.510 --> 00:40.070
So why is that happening?

00:40.100 --> 00:49.640
Well, if we go into our spell globe button and look at our event graph, we've assigned a event to

00:49.640 --> 00:55.400
the spell globe reassign delegate, and every time the widget controller is set.

00:56.160 --> 00:58.860
We bind to this delegate again.

00:59.040 --> 01:01.320
Now, the fix for this is simple.

01:02.470 --> 01:05.830
When the spell glow button is destroyed.

01:07.700 --> 01:09.800
In other words, an event destruct.

01:10.500 --> 01:15.870
We unbind the delegate so we can take the spell menu Widget controller.

01:15.900 --> 01:20.820
We can type spell globe reassigned and we can unbind.

01:20.850 --> 01:28.260
We can unbind all events and all events is referring to all events on this object from the delegate.

01:31.040 --> 01:35.930
And we can do this for all the delegates that we've bound on the widget controller.

01:36.020 --> 01:38.780
We have ability info delegate.

01:39.470 --> 01:41.360
We can unbind those.

01:47.790 --> 01:48.780
So there we go.

01:48.780 --> 01:54.630
Now let's see what happens before we actually do this, I'm going to disconnect that pin and just print

01:54.630 --> 01:55.590
a string.

01:57.320 --> 02:00.320
When spell globe reassigned is broadcast.

02:02.390 --> 02:03.710
I'll change it to yellow.

02:12.520 --> 02:14.890
So there's twice as many each time.

02:17.710 --> 02:18.430
See that?

02:19.660 --> 02:22.100
Now, what happens if we unbind?

02:22.120 --> 02:23.320
Let's check it out.

02:30.690 --> 02:32.670
It's the same amount each time.

02:37.110 --> 02:43.080
So what we can do is go through and unbind all the events that we've bound to our widget controller.

02:43.830 --> 02:49.260
We'll do that here and we'll do it in our other classes and I'll just go ahead and time lapse the process.

04:46.380 --> 04:49.350
Now in the spell globe here we access none.

04:49.350 --> 04:53.340
So I'm going to use a validated get just to be safe.

05:15.470 --> 05:21.590
And you don't have to worry about removing from onclicked events or anything like that, just the ones

05:21.590 --> 05:30.200
in our spell menu widget controller and that takes care of that and everything is working great.

05:33.590 --> 05:36.770
Excellent job and I'll see you in the next section.
