background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "How I Simplify Unity Development with the Façade Pattern"

input logo icon
Video tags
|

Video tags

unity tutorial
unity arcade game
unity game tutorial
unity
game development
game dev
game development unity
programming
c#
software development
learn to code
learn programming
unity tutorials
unity devlog
indiedev
gamedev
unity3d
unity post processing
unity beautify 3
unity painting
unity facade pattern
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:00
when I want to expose several systems
00:00:02
through a single interface I use the
00:00:03
facade pattern here's an example I'm
00:00:06
using three Tools in this project to
00:00:08
control visual effects when my player
00:00:10
moves from place to place or some kind
00:00:12
of cinematic occurs I want to change the
00:00:15
effects what I don't want to do is call
00:00:17
several methods and change properties
00:00:19
every time on all of these systems you
00:00:21
might be doing this with weather systems
00:00:23
or audio systems or anywhere else where
00:00:25
you have operations that affect an
00:00:27
entire subsystem of objects and this is
00:00:30
where the facade comes in today we're
00:00:32
going to create a facade for three
00:00:33
post-processing effects to create
00:00:35
complex visual styles with just one
00:00:38
method call while you could use any
00:00:40
combination of subsystems behind a
00:00:42
facade today I'm going to show you how I
00:00:44
would combine regular postprocessing
00:00:46
effects with the unique features of
00:00:48
beauy 3 and oil paint assets to create
00:00:51
some unique visuals for this
00:00:57
game so as part of the system I've
00:00:59
created a few different volume profiles
00:01:01
that we can use for the different styles
00:01:03
of effects I want to have so we've got a
00:01:05
really basic ones here I've got an
00:01:06
artistic one that doesn't do too much
00:01:08
because I'm going to count on some FX
00:01:09
for this one but the horror one is going
00:01:12
to slightly change the color a little
00:01:14
bit to a bluish color it has some other
00:01:16
features like chromatic aberration and
00:01:18
depth of field and I've created a movie
00:01:20
volume that just has some things like
00:01:22
vignette motion blur depth of field and
00:01:25
then I've also created another volume
00:01:27
that has all my beautify settings now
00:01:30
you can see beauy of course has so many
00:01:32
settings you can choose and I've only
00:01:33
set some of them a little bit more Bloom
00:01:36
some anamorphic flares and a little bit
00:01:39
further down is a new feature of
00:01:40
beautify 3 which is the ability to have
00:01:43
cinematic bands on your screen so what
00:01:45
I'm going to do is have horizontal bands
00:01:47
on the top and bottom of my shot when
00:01:49
I'm playing a cinematic
00:01:51
sequence so I'm going to go ahead and
00:01:53
create an empty game object here that'll
00:01:55
just hold a bunch of buttons that'll
00:01:57
interact with our
00:01:58
facade
00:02:00
I've already created an empty script
00:02:02
that will hold our buttons but let's
00:02:03
also create one for the facade as well
00:02:06
it's going to be a Singleton and I'll
00:02:07
move it into its own file here our
00:02:09
facade is going to be an interface
00:02:11
between the different post-processing
00:02:12
setups I want to have and the rest of
00:02:14
the game so we'll have some public
00:02:16
methods here that will hide the
00:02:17
complexity of how these systems will
00:02:19
behave so these three methods here will
00:02:21
form our public API any button or
00:02:24
Trigger or other event that needs to
00:02:26
change the postprocessing effects just
00:02:28
needs to call one of these public
00:02:29
methods
00:02:30
back in the buttons class let's define
00:02:32
three buttons one for each of those
00:02:34
public API methods uh I'm going to use
00:02:36
Odin here so I'll just Define a color
00:02:38
quickly and then I'll just use the
00:02:40
Odin's button attribute to create a
00:02:42
button for each one once I've got the
00:02:44
first one written here I think co-pilot
00:02:46
should be able to take over from here so
00:02:49
yeah it already knows what I want to do
00:02:50
so there we go set up horror set up
00:02:53
cinematic and setup artistic let's jump
00:02:56
back into unity and make sure these look
00:02:58
correct just drag the buttons component
00:03:01
onto my game object here and yeah there
00:03:03
we go that all looks great okay let's
00:03:05
carry on and we'll start with the first
00:03:07
part of
00:03:08
this now for each one of these public
00:03:10
methods I want to load one of the
00:03:12
volumes that I created earlier so we'll
00:03:15
store that into its own variable here
00:03:17
and start we'll run a method that will
00:03:18
initialize this all we really need to do
00:03:21
to initialize a volume is to create a
00:03:23
new game object add the volume component
00:03:25
to it and then we need to load the
00:03:28
settings into the volume
00:03:30
to actually load the settings into the
00:03:32
volume what I'm going to do is create a
00:03:34
new class here called resources utils
00:03:37
and it's just going to have an extension
00:03:38
method we'll call it load volume profile
00:03:41
it'll use the resources. load method and
00:03:43
assign the profile that it loads into
00:03:45
the volume so now we can come back to
00:03:47
the facade and the first part of each
00:03:49
one of these methods will be to load one
00:03:51
of these presets that we've already
00:03:53
created so I'm just going to put the
00:03:55
methods in here for each one of
00:03:57
those perfect now we we can test it
00:04:01
out so back over here I'm just going to
00:04:03
add the facade to the same game object
00:04:05
you don't have to but I think it's
00:04:07
simple for this demo and press play and
00:04:10
now let's check out horror so we've got
00:04:13
the colorization there cinematic nice
00:04:15
and crisp with a little more Bloom and
00:04:17
the artistic not much different than the
00:04:19
Cinematic yet but we'll be changing that
00:04:21
in a
00:04:22
moment so it's doing exactly what we
00:04:24
want it's loading all the profiles let's
00:04:26
come out to play mode and keep
00:04:28
going
00:04:30
so the two other systems I want to
00:04:31
implement are beautify and frankon games
00:04:34
oil paint system so what I'm going to do
00:04:36
is make two classes that are going to
00:04:38
control those because they're a little
00:04:39
bit more complex than just assigning a
00:04:41
profile to a volume move these into
00:04:43
their own files and we'll work on them
00:04:44
one at a time I think what we'll do is
00:04:46
actually start with the francon system
00:04:49
first so I'll create a reference for
00:04:51
that so we can store it here and we'll
00:04:54
just have another initialize method in
00:04:56
the start and it'll set up our system
00:04:58
for us basically very similar to what
00:05:00
we're doing already we'll just create a
00:05:02
new game object We'll add our new
00:05:04
component to it and that's really it for
00:05:07
this then let's jump over to the new
00:05:09
class here and start writing it out so
00:05:12
this is the first time I've actually
00:05:13
used the oil paint one so what I did was
00:05:15
went and had a look at their demo and I
00:05:17
copied a little bit of code from there
00:05:19
and I'm just going to change it a little
00:05:20
bit so I'll import the dependencies here
00:05:22
let's add a variable so that we can keep
00:05:24
a reference to the settings on awake we
00:05:26
can use a method of the class already to
00:05:29
get those
00:05:30
settings then let's just run another
00:05:32
method called initialize initialize will
00:05:35
handle the settings of everything we
00:05:36
want for this I'm just going to paste it
00:05:38
right in here now you see I've set the
00:05:40
intensity to be zero because I wanted to
00:05:42
start it with no effect at all and I'm
00:05:44
going to set when to insert to be after
00:05:47
rendering the
00:05:48
Skybox let's take a quick look inside of
00:05:50
this settings class you can see there's
00:05:53
quite a lot going on here so so you can
00:05:55
see there's a lot going on here this
00:05:56
tool is actually quite powerful I'm
00:05:58
starting to really like it just after
00:05:59
playing with it for one day so let's uh
00:06:02
clean this up we need one method here
00:06:03
that's going to change the intensity for
00:06:05
us so we can just accept a toggle like a
00:06:08
Boolean on and off let's call it is
00:06:10
active if it's active let's set
00:06:11
intensity to one otherwise zero that's
00:06:14
all we need to turn this effect on and
00:06:16
off let's come back to the facade I'm
00:06:18
going to move all the initialization
00:06:20
stuff keep it at the bottom and so in
00:06:23
each of our public API methods what
00:06:25
we'll do is we will decide whether or
00:06:26
not we want the painting effect to be on
00:06:28
or off so the only one I actually want
00:06:30
it on is in the artistic one so with
00:06:33
that done we can actually go back and
00:06:35
see if it works I'll just hit play here
00:06:38
and let's might as well just start at
00:06:39
the top again make sure everything's
00:06:40
working correctly so horror yeah that's
00:06:43
what we want how about artistic yeah and
00:06:45
there we go so now we have a cool hand
00:06:47
painted effect whenever we want to do
00:06:49
kind of an artistic render of something
00:06:52
and I've got it turned up to pretty much
00:06:54
the max for this particular setting but
00:06:56
uh it's definitely worth playing around
00:06:58
with I'd check that out if you're
00:06:59
interested in that kind of effect so
00:07:01
next let's add beautify into our mix so
00:07:04
that our facade can control the
00:07:05
different beautify settings if this
00:07:07
video is helpful or useful to you give
00:07:09
it a thumbs up it helps YouTube share it
00:07:11
with more people and it gives me
00:07:13
feedback that it's useful for
00:07:16
you I'm just going to add a few more
00:07:18
using statements because we're going to
00:07:19
need them in a moment and for beautify
00:07:22
what we can do is store the beautify
00:07:24
settings similar to what we just did
00:07:26
with the francone ones I'm also going to
00:07:28
add a little bit more functionality here
00:07:29
to make it a little bit more useful in
00:07:31
the future so I might want to access the
00:07:34
settings of beautify from a public
00:07:36
property and we can also use a null
00:07:38
coalescing assignment Operator just to
00:07:40
make sure that there is something
00:07:41
actually in there when we go to
00:07:43
initialize this component I will have
00:07:45
already loaded our beautify volume onto
00:07:48
this game object so what we can do in a
00:07:50
wake is we can actually grab a reference
00:07:52
to that volume let's iterate over all of
00:07:55
the components find the one that is the
00:07:58
beautify component and return that one
00:08:00
that way we're not using the static one
00:08:02
from the beautify settings we're using
00:08:04
the one that's actually on this game
00:08:06
object and if for some reason we don't
00:08:08
find it there let's just log an error
00:08:10
message so that we know that but that
00:08:12
should be a little bit more robust and
00:08:14
it'll get us the one that's local to
00:08:16
this particular
00:08:17
instance so that's all the setup I want
00:08:19
to do in this class but now let's start
00:08:21
adding some utility what if we just
00:08:23
wanted to turn off beautify altogether
00:08:26
we could just have a disable method here
00:08:28
that would turn off the let's see it's
00:08:30
called active yeah there we go active
00:08:32
equals
00:08:33
false and we can start toggling settings
00:08:36
or actually just turning them explicitly
00:08:38
on and off I'll just make some room here
00:08:40
I'm not going to make methods for every
00:08:42
single beautify setting because there's
00:08:44
probably hundreds of them but basically
00:08:46
we can just start with blur we can
00:08:48
toggle it on and off we could toggle on
00:08:50
and off sharpen how about vignette we
00:08:52
could uh there's two vignette settings
00:08:54
actually there's the outer ring and the
00:08:56
inner ring so we can just toggle them
00:08:58
I'll come down here here let's make some
00:09:00
activate ones that'll actually accept a
00:09:02
Boolean we might as well do vignette
00:09:04
first so this is just basically the same
00:09:07
except we'll assign the Boolean value
00:09:09
looks like I got a typo there let fix
00:09:10
that okay how about we do the Cinematic
00:09:13
bands now that one I've already
00:09:14
configured it on the volume so all I
00:09:16
really need to do is turn it on and off
00:09:19
on the volume that setting is called
00:09:21
frame and all we have to do is turn it
00:09:23
on so that's probably enough for our
00:09:25
little demo I think I'll just do a
00:09:26
little bit of cleanup here once that's
00:09:28
done we can jump back over to the facade
00:09:30
now we need to have another initialized
00:09:32
method for beautify that's going to do
00:09:34
something very similar to all the other
00:09:35
ones basically we'll create a game
00:09:37
object for it we're going to add a
00:09:39
volume component to it and we'll load in
00:09:42
the specific beautify volume that's
00:09:44
already created and then we need to add
00:09:47
our new class to it so that we can
00:09:49
control it I'll just move this down
00:09:51
below with the other initialized methods
00:09:54
and then we can start putting it to use
00:09:56
so let's keep it super simple for now in
00:09:58
the hor
00:09:59
settings I don't want any bands but I do
00:10:02
want the vignette so let's turn the
00:10:04
bands off and vignette on now I'll just
00:10:07
copy and paste this down to cinematic
00:10:09
but I actually want the opposite I want
00:10:11
the bands on and the vignette off and
00:10:14
then finally down in the artistic one I
00:10:16
actually want to turn both of those
00:10:18
things off so I just paste it in there
00:10:19
again and switch cinematic bands to off
00:10:22
yeah and then we should be good I think
00:10:25
just before we go back to Unity I'm
00:10:26
going to quickly quickly add one more
00:10:28
thing for outline because I want to use
00:10:30
it in the horror setting so I'll have a
00:10:32
toggle n and activate and I'll turn it
00:10:34
on in horror but off in the other
00:10:38
two there we go all right let's jump
00:10:41
back to
00:10:43
Unity so if I hit playe out we'll see
00:10:45
all three systems will load up in the
00:10:47
hierarchy and we've got a pretty nice
00:10:49
looking screen right now if I start
00:10:51
flipping through the buttons here hor is
00:10:53
going to work the way we think but
00:10:54
cinematic now should show us our bands
00:10:56
so that looks pretty awesome it's got
00:10:58
all the beauy effects happening um and
00:11:01
the regular post-processing that looks
00:11:03
awesome if we come over to Artistic of
00:11:05
course it's going to give us our oil
00:11:06
painted look again and we can just
00:11:08
toggle between these as we like and we
00:11:11
could hook them up any way we want in
00:11:12
code now and that's the real power of
00:11:15
the facade pattern we don't have to
00:11:16
worry about all the complexities of
00:11:18
managing these three different systems
00:11:20
we just have one method to call for each
00:11:22
of these styles that we want to present
00:11:23
to the
00:11:25
player so just to make this a little bit
00:11:27
more robust I'm going to add require
00:11:29
component of type volume to our beautify
00:11:32
system and I'm going to add one more
00:11:35
extension method here and I'm going to
00:11:36
put this in the repository for the
00:11:38
extensions for some objects like this we
00:11:41
just want to hide them from the
00:11:42
hierarchy because they're hidden behind
00:11:44
the facade we don't care about them so
00:11:46
much we're not really going to interact
00:11:48
with them of course there's sometimes
00:11:49
you're going to want to interact with
00:11:51
them but for the most part this is kind
00:11:52
of set and forget you go through the
00:11:54
facade and you don't worry about the
00:11:55
rest of it so let's just hide each of
00:11:58
these in the the hierarchy as we're
00:12:00
initializing them so with that done
00:12:03
let's just have a quick look at what
00:12:04
we've come up with here we've got
00:12:06
basically a facade with three public
00:12:08
methods setup horror setup cinematic and
00:12:10
setup artistic the rest of your game
00:12:13
really only needs to know about these
00:12:14
three methods and that's it that's as
00:12:16
simple as it gets I'm just going to say
00:12:19
one last thing and that is do not be
00:12:20
tempted to use the facade simply to hide
00:12:23
your messy code from the rest of your
00:12:25
game that's not what it's for as
00:12:28
tempting as might be the facade is
00:12:30
really just to provide an easyto ous
00:12:33
friendly interface over top of complex
00:12:36
subsystems that's all I've got for you
00:12:38
today I'll see you in the next one

Description:

The Façade Pattern can help you take control of multiple related subsystems by providing a simple, easy to understand interface over a large and sophisticated body of code! In this in-depth tutorial, you'll see how to significantly improve the readability and functionality of your code by combining multiple visual effects and post processing systems into streamlined, manageable process using the Façade Pattern. Follow me, and the Asset creators featured in this video on Twitter! https://twitter.com/adammyhre1 https://twitter.com/kronnect https://twitter.com/fronkongames And before you ask, that thing under the letter C is a Cedilla and that's what makes it pronounced as `S` instead of `Kuh`! 🔔 Subscribe for more Unity Tutorials https://www.youtube.com/@git-amend ▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬ 0:00 URP Post Processing Façade 5:00 Fronkon Games Oil Paint 7:15 Kronnect Beautify 3 Unity Utilities Repo: https://github.com/adammyhre/Unity-Utils Assets Shown In This Video (Affiliate Links) Shipyard from Unity Megabundle "23 for $23": https://assetstore.unity.com/mega-bundles/best-of-2023?aid=1101lw3sv Kronnect's Beautify 3: https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/beautify-3-advanced-post-processing-233073?aid=1101lw3sv Fronkon Games Oil Paint: https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/artistic-oil-paint-264134?aid=1101lw3sv Odin Inspector: https://assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041?aid=1101lw3sv *Follow me!* https://linktr.ee/gitamend

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "How I Simplify Unity Development with the Façade Pattern" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "How I Simplify Unity Development with the Façade Pattern" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "How I Simplify Unity Development with the Façade Pattern" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "How I Simplify Unity Development with the Façade Pattern" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "How I Simplify Unity Development with the Façade Pattern"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "How I Simplify Unity Development with the Façade Pattern"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.