Skip to main content
Advanced. This page is for programmers who are comfortable with Unity C# and assembly definitions. You don’t need it to use Pixelate Pro.
You can add your own effects to Pixelate Pro. A custom effect appears in the Add Effect menu next to the built-in ones, works with Style Profiles and per-asset overrides, and runs in the Preview, Export and Save GIF.

How an effect works

An effect is a ScriptableObject class that inherits PixelateEffect. It has three jobs:
  1. Hold settings as serialized fields. Pixelate Pro draws them in the Inspector, with override checkboxes in Pixelate Assets. The header checkbox that turns your effect on or off works per asset there too.
  2. Validate its settings and report problems the user can act on.
  3. Process the pixels of each frame, deterministically.
It must not touch the scene, edit the source’s renderers or materials, or write files. Pixelate Pro handles capture, preview and export. Effects are saved inside the Style Profile that owns them. Pixelate Pro finds every non-abstract PixelateEffect class in the project when scripts compile; there is nothing to register.

Set up an assembly

Put your code outside the Pixelate Pro folder, so updating Pixelate Pro never overwrites it:
YourStudio.PixelateEffects.asmdef
PixelateStudio.PixelatePro is Pixelate Pro’s runtime assembly. It holds every type on this page.

A complete effect

This effect reduces each color channel to a few levels.
PosterizeEffect.cs
After Unity compiles, Posterize appears in Add Effect under Stylization. Adding it from a Pixelate Asset adds it to that asset’s Style Profile, because profiles own the effect list.

The menu attribute

PixelateExtensionMenuAttribute names your effect and places it in the menu and the pipeline. PixelateExtensionCategories has the constants Lighting, Color, Stylization, Utility and Advanced (plus Required and Uncategorized, used by Pixelate Pro itself). The help icon in your effect’s header opens the Effects overview of this documentation. To open your own page instead, add Unity’s [HelpURL("https://...")] attribute to your effect class. An effect class without the attribute still appears in Add Effect, under Uncategorized, with its class name and its full type name as the id. Add the attribute before you ship. If two loaded effects share a stableId, Pixelate Pro reports the error “Duplicate Pixelate effect stable id ’…’” naming both types.

Where your effect runs

Phases run in this order: Source, Capture, Preprocess, Lighting, Color, Stylization, Export, Generate. Every effect works on the finished frame at the sprite’s final size; the phase only sets its position in the pipeline. Built-in effects use these positions, so you can place yours before or after them: The Inspector lists effects in this order, so users see yours where it runs. Effects at the same phase and order keep the order they were added in.
In lit frames, Color Adjustments always runs just before Lighting, and so does Color Palette when Lighting’s Palette Affects Lighting is off. Your effect stays at its own position. For example, a Color-phase effect runs after Lighting in lit frames. In unlit frames, Lighting doesn’t run. See processing order.

Processing pixels

Override ProcessPixels to change the frame. Pixelate Pro calls it for every Unlit and Lit frame of the Preview and Export, at your effect’s position. Normal previews and normal-map exports skip it. An effect that doesn’t override it adds no processing step, which is useful for effects that only hold settings. PixelateEffectPixelContext gives you: ProcessPixels is called on the profile’s effect, so its own fields are the profile values. Per-asset values come from OverrideShadow, as in the example. Keep processing deterministic: the same input must always give the same output, so the Preview matches Export and re-exports don’t change unrelated pixels. Custom effects run on the CPU, and the frame is copied from and back to the GPU around your step, so keep the work per pixel small.

Validation

Override Validate for setup problems the user can fix. Pick the severity by impact: Use the five-argument constructor: severity, message, how to fix it, your stableId, and the serialized field name. The field name lets the Inspector show the message next to the right field. Always say how to fix the problem. Validate is called for disabled effects too, so return early when Enabled is false, as in the example. It checks the profile’s values; per-asset override values aren’t passed to it.

Inspector

Pixelate Pro draws your serialized fields with Unity’s standard property drawers, including [Tooltip], [Range] and [Min]. Give every field a tooltip. In a Pixelate Asset’s Inspector, each field gets an override checkbox automatically. Don’t store foldout or other UI state on the effect; Pixelate Pro keeps that per user in editor preferences.

Renaming fields after you ship

Per-asset overrides remember fields by name. When you rename a serialized field, add [FormerlySerializedAs] with the old name. Pixelate Pro reads it and moves existing overrides to the new name:
If an override points at a field that no longer exists, validation reports the error “Override ’…’ no longer exists on ’…’” with the field name and your stableId. For removed fields or larger changes, plan how existing overrides migrate, and never reuse an old field name for a different meaning.

Supported API

Only these types are supported extension API:
  • PixelateEffect (with Validate, ProcessPixels, Enabled and IsFieldOverridden from its base class PixelateExtension)
  • PixelateExtensionMenuAttribute, PixelateExtensionCategories and PixelateExtensionPhase
  • PixelateEffectPixelContext
  • PixelateValidationMessage and PixelateValidationSeverity
Other Pixelate Pro types, including custom Inspector drawing and GPU processing, are internal and may change between versions.

Next steps

Effects overview

The pipeline your effect joins.

Style Profiles

How users add effects and override fields.