I figured I’d dedicate a separate short
lesson to VRChat specific prefabs, because there are a few that I know a lot of people
want in their worlds. Many VRChat prefabs can be found on the VRCPrefabs
database. Note that SDK2 prefabs will not work in our
SDK3 world, only Udon Prefabs will work. Many prefabs require UdonSharp to work; this
complies C# code to Udon. You don’t need to know how it works, just
make sure you import it before importing an Udon prefab that requires it. One of the most popular features of small
worlds is a video player. One of the most popular of these is Merlin’s
UdonSharp player (which we will be using), but some other ones are VRCUdon’s and ProTV. Technically all of these are supported on
Quest HOWEVER YouTube and Twitch URLs do not work, more info in a post in the description. First, we need to import UdonSharp. Grab the unitypackage from the Github page
under releases for both UdonSharp and UsharpVideo. There should be a videoplayer prefab in the
UsharpVideo folder in the project, drag that into the scene, unpack and you’re done! You can change some options on the player,
like whether control is locked to the master of the world or whether anyone can paste video
links. You can change the UI style by going to the
ControlsUI gameobject in the prefab, clicking on the style file and draggin in a different
one from the folder or you can make your own. You can add URLs for the Videoplayer to play
by default by clicking the + icon under “Default Playlist URLs” on the root gameobject of
the prefab. The prefab comes with audio settings pre-setup
but you may want to change them. Some of the audio settings are pretty self-explanatory
or as always you can click the circle with the ? to go to the documentation page; however
some are a little confusing so I’ll go over them. The spatial blend controls how much the audio
source is handled by the 3D engine; so if it is set all the way to the left, to 2D,
all of the settings under the 3D settings dropdown are ignored and the sound is always
omnipresent. Spread controls where the sound is coming
from. If it is set to 0, then it will sound like
the sound is coming from the audio source; if it is set to 360 then the sound will come
from the direction opposite of the source. Personally for video players I like to set
the spread to 180 so it won’t sound any different when you move your head (like an
omnipresent sound) but still set the spatial blend to 3D, the falloff to logarithmic and
the min distance to something like 4, at least in larger worlds with at least a few rooms,
so that if players walk further away from the video player the sound will start to fall
off. Also if you do this make sure you set the
stream audio source to stereo mix and disable the other stream audio source channel gameobject
– then don’t forget to apply the same settings to the video audio source! If you’re just making a one room world you
can disable the 3D spatialization settings entirely by unchecking the “Enable Spatialization
” box under advanced settings in the VRC Spacial Audio Source component. Prefabs with Udon elements can cause conflicts,
so it’s best to unpack your prefabs in your scene to ensure they work properly. You can right click on the prefab in the hierarchy
and click unpack prefab; this will make your object no longer a prefab. Another popular prefab is Qvpens. Grab these from their page on Booth.pm and
make sure it is the Udon version. After importing, drag the prefab into the
scene. If you want a low quality mirror without the
skybox, you can use VRCPlayersOnlyMirror. It comes with a UI pre-setup. The standard shader isn’t very good but
thankfully there are community created replacements that are much more intuitive and fully featured. Some of these include z3y’s shaders or Silent’s
Filimented, but the one we are going to use is Mochie Standard because it is the easiest
to install and tells you if your grayscale textures are set to sRGB and provides a button
to automatically fix it if they are. It uses the industry standard roughness maps
instead of smoothness maps, and gives greater control over the parallax mapping for heightmaps,
among many other features. Water shaders are also something many world
creators want, and Mochie’s shader package also comes with a decent water shader. Other VR specific water shaders I would recommend
are Red_Sim’s water shaders, Silent’s Clear water, and Norbien’s water, among
others. Note that to have refraction, the shader must
use a grabpass which is computationally expensive and does not work on Quest. Many water shaders also require a depth pass,
which necessitates that a realtime light with shadows be in the scene. There is a DepthPass prefab included in VRWorldTooklit
that is set to have the least impact on performance. As for my personal opinions on them, I think
Red_Sim’s have the best caustics (Mochie’s water caustics look too much like a voronoi
texture) and Norbien’s seem to have the best performance and also works with Quest
and doesn’t require a real time light for a depth pass. Some prefabs don’t come in a unitypackage
but in a zip file with a package.json file inside. To import these, open the package manager,
click the plus icon, then click the package.json file and open it. They will then show up in Custom packages
in the package manager and can be removed from there. Note that if you move the location of the
package on your hard drive you will either have to move it back or reinstall it. For those who are interested, if you want
to convert Unity C# scripts to UdonSharp, it typically isn’t very difficult, as long
as the methods used in the script are exposed in Udon. A lot of the time you can just change the
base class from MonoBehavior to UdonSharpBehavior, and change or remove the namespace if it has
one; then create a new Udon# program asset, plug the script into it, plug that into an
udon component (UdonSharp will automatically fill in the rest) and it should work. You can check the UdonSharp class exposure
tree by going to Window>UdonSharp>Class Exposure Tree. If you run into problems or have more questions
visit the Discord server linked in UdonSharp’s Github page. If you plan on writing Udonsharp scripts I
would also recommend UdonToolkit, which allows you to create custom inspectors for your scripts
(like I did on my fork of Nova_Max’s Daynight cycle prefab!). It helps make them easier to use for not only
yourself but also anyone else if you plan on making it available. That’s it for this episode. Join me next time for the final lesson in
this series where we will upload our world to PC and Quest!