Quick Start
v1.0
Last updated
v1.0
Last updated
This YouTube video walks through the initial setup, which requires you to create a new Layer, and set up the Runtime Color Sampler prefab and Sampler Camera to use the new layer.
Select the Runtime Color Sampler prefab located at Assets/InfinityPBR - Magic Pig Games/Runtime Color Sampler/Prefabs
First, set the Layer of this object to ColorSampler
, including the children. Then open up the prefab, selecting the "Front Camera" object. Add the ColorSampler
layer to the culling mask of this object.
Bring the Runtime Color Sampler prefab into your scene.
Generally this prefab should be attached to your player object, so that it is sampling the location where your player is. However, it can be put wherever you'd like for your project.
View the Runtime Color Sampler in the Inspector.
If you've imported the Demo
folder, you'll see some Runtime Color Settings objects already in the list. All Runtime Color Settings objects will appear in this list. You can edit their values on each Scriptable Object, but you'll likely find it far easier to do so while viewing the Runtime Color Sampler.
Create a new Runtime Color Settings Scriptable Object by selecting a new name in the "New Settings Name" text field, and clicking the "Add" button. Note that names of these objects should be unique.
The new object will show up in the list, and you can click the "Arrow in a Circle" button to ping the object in the Project view.
Next, create an object in your scene which will "Listen" for the color. This can be any object with a material, a Text Mesh Pro text object, or a UI Image or RawImage.
You can create your own "Listener" classes! If you'd like something to respond to the color, simply create your own class which inherits from RuntimeColorListener
, similar to the classes included in the package.
Materials need to have a color option. If your material is using a custom shader, or a render pipeline material that does not have this, you'll need to create your own Listener class to handle the material.
Add the appropriate "Listener" compoent to the object.
The "Demo Cube" from the demo scene has a RuntimeColorListenerMaterial
on it. The Material value will be set automatically through the scripts OnValidate()
method. The only thing you must assign is the Runtime Color Settings field. Select one of the demo ones, or the one you just created.
You can adjust the transition time if you'd like as well. Having a transition keeps the color from changing values too rapidly, which may not provide a pleasing experience for your players. Try out different values to see what works for you and your project.
The "Blending" options are used at runtime to override the color values on a per-object basis. You can test this at runtime by changing the color, blend mode, and then sliding up the blend amount. These can be scripted to create effects like "Got Hit" overlays, and more.
The final thing to do is set up some lighting in your scene -- anything will work, just set up some areas where there are various lighting conditions. Dark, light, colorful lights, whatever you'd prefer.
Unless you're using a player object that can move, just move the object around in the Scene view, and see the results on the object that is listening to the sampler. The color should be changing based on the lighting conditions where the sampler is.
That's it! Press "Play"