How do I
Keep an effect a script turns on in the build
Builds leave out the shaders of effects no Volume Profile in the build holds; tick an effect only a script adds under Project Settings > Pass Forge > Always Include, or add it to a profile a build scene uses.
You want
Your options menu adds CRT to the Volume from a script. It works in the Editor, and in the build the call does nothing, with no error. You also want the build to stay small.
A player build carries only the effects it uses, so a game that shows only CRT does not carry the watercolor or glitch shaders. An effect counts as used when a Volume Profile that the build's scenes, Resources folders, asset bundles, Addressables groups or render pipeline assets depend on holds it.
Steps
- Open Project Settings > Pass Forge.
- Press Show What A Build Leaves Out. It lists what the build keeps and leaves out, one category per line, and names the scenes it counted, so a scene missing from the build's list stands out.
- Under Always Include, tick each effect that only a script adds or turns up while the game runs. The effects your scenes use are kept without a tick, so leave the rest empty.
- Or add the effect, switched off or at zero, to a profile one of the build's scenes uses, and turn it up from the script.
- Set Leave Out Unused Effects:
- Not In Any Profile, the default, keeps every effect a profile holds.
- Not Turned On In Any Profile also leaves out effects a profile holds switched off, which helps when an Effects Volume (All Effects) holds every effect.
- Keep All keeps everything, which confirms whether stripping is the cause of a problem.
- When a script adds a Dissolve, Occluder Fade or Cross Section while the game runs, tick Dissolve, Occluder Fade And Cross Section Added From Scripts.
What you should see
Play Mode warns in the Console, once per effect, when an effect shows in a scene of the build's list but no profile in the build holds it. After you tick it, the warning goes, and the build log lists what a build left out.
Some effects are always kept, because a component, a script or the game's options decide to draw them: Shockwave, Screen Shake, Transition, Screen Flash, Flash Lights, VHS Rewind, Damage Direction, Damage Numbers, Lens Blood, Color Vision, Fog of War, Reveal Lens, Panel Backdrop, Ground Markers, Beacons, Route, Off-screen Indicators, Tethers, Spotlight and Screen Warps. Object effects such as highlights and afterimages, the PF Panel, Compass Bar and Fog Minimap shaders are always kept too.
If it does not work
- AgX does nothing in the build. A build leaves out the AgX pass when no profile in it turns AgX up. Tick AgX Tonemapping under Always Include, or ship a profile with AgX up and change its Volume's weight instead.
- The Console says the Lit Effects shader is missing. None of Dissolve, Occluder Fade and Cross Section is placed in a scene of the build. Tick Dissolve, Occluder Fade And Cross Section Added From Scripts.
- A custom node is gone in an IL2CPP build. IL2CPP strips a custom node's class: add a
link.xmlunder Assets that preserves the assembly your node lives in. - The default Volume Profile holds every effect. Unity fills it with every Volume component in the project and marks each setting overridden, so only effects actually turned up there are kept.
From a script
using PassForge.Effects;
using UnityEngine;
using UnityEngine.Rendering;
public class CrtOption : MonoBehaviour
{
[SerializeField] Volume m_Volume;
CrtEffect m_Crt;
void Awake()
{
var profile = m_Volume.profile; // a private copy; the asset is untouched
// An effect a script adds needs Always Include in Project Settings > Pass Forge, or builds leave it out.
if (!profile.TryGet(out m_Crt))
m_Crt = profile.Add<CrtEffect>();
}
public void SetCrt(float amount)
{
m_Crt.active = true;
m_Crt.intensity.Override(amount); // a Volume ignores a setting that is not overridden
}
}