# Quick Start

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.

{% embed url="<https://www.youtube.com/watch?v=t_wQDlh_3EI>" %}

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FxqYbeEyophijuG5KVXZx%2FScreenshot%202023-11-07%20at%209.03.37%20PM.png?alt=media&#x26;token=4f6584e7-cec0-47c5-ad9f-6fb649e91eb4" alt=""><figcaption></figcaption></figure>

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**](https://infinitypbr.gitbook.io/magic-pig-games/other/runtime-color-sampler/runtime-color-sampler-prefab-and-class) prefab into your scene.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FgUJqUVRa8w7D0QHtD92T%2FScreenshot%202023-11-07%20at%209.02.44%20PM.png?alt=media&#x26;token=d9978672-8423-4aa3-b165-de545ca1753f" alt="" width="310"><figcaption></figcaption></figure>

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.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2Fp0S2X0hNDIn6hfSl9X87%2FScreenshot%202023-11-07%20at%208.55.26%20PM.png?alt=media&#x26;token=3122f908-23ed-4c6a-b702-806a105a0311" alt=""><figcaption></figcaption></figure>

If you've imported the `Demo` folder, you'll see some [**Runtime Color Settings**](https://infinitypbr.gitbook.io/magic-pig-games/other/runtime-color-sampler/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.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FCEX9X1IPKoyVyiobLdRt%2FScreenshot%202023-11-07%20at%209.04.23%20PM.png?alt=media&#x26;token=4c763036-7eef-410d-8e2b-d8e056c7661f" alt=""><figcaption><p>The Export Path will be near Assets, or at the same location as your other objects, if you have any.</p></figcaption></figure>

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.

{% hint style="success" %}
You can create your own "[**Listener**](https://infinitypbr.gitbook.io/magic-pig-games/other/runtime-color-sampler/runtime-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.
{% endhint %}

{% hint style="warning" %}
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.
{% endhint %}

Add the appropriate "Listener" compoent to the object.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FZqCNTcjZR40SRWj5tkLh%2FScreenshot%202023-11-07%20at%209.05.20%20PM.png?alt=media&#x26;token=13a796a7-089e-448f-8619-40d64a8943e1" alt=""><figcaption></figcaption></figure>

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**](https://infinitypbr.gitbook.io/magic-pig-games/other/runtime-color-sampler/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.

**That's it! Press "Play"** :thumbsup:

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.

{% content-ref url="demo-walkthrough" %}
[demo-walkthrough](https://infinitypbr.gitbook.io/magic-pig-games/other/runtime-color-sampler/demo-walkthrough)
{% endcontent-ref %}
