Scripting Support (C#)

advanced scripting

Mystify FX · Scripting Support (C#)

Namespace: MystifyFX
Main class: MystifyEffect (MonoBehavior) — attach to any GameObject with a Renderer.
Settings: stored in MystifyEffectProfile (ScriptableObject). Create via Assets > Create > Mystify FX Profile.
This page documents the user-facing API (public fields, properties, and methods). Enums, structs, delegates, render-feature internals, and editor-only classes are intentionally omitted.

Getting Started

Add using MystifyFX; at the top of your script. Access the component and modify effect settings through its profile:

using UnityEngine;
using MystifyFX;

public class MystifyDemo : MonoBehaviour
{
    void Start()
    {
        // Get the component
        MystifyEffect fx = GetComponent<MystifyEffect>();

        // Access the per-instance profile (cloned automatically)
        MystifyEffectProfile p = fx.profile;

        // Modify settings
        p.rimIntensity = 0.8f;
        p.rimColor = Color.cyan;
        p.distortion = true;
        p.distortionAmplitude = new Vector2(0.02f, 0.02f);

        // Tell the component to re-apply changes
        fx.UpdateMaterialProperties();
    }
}
Shared vs Instance profile: Use sharedProfile when you want all objects sharing the same asset to update together (like Renderer.sharedMaterial). Use profile to get a per-instance clone that only affects this object (like Renderer.material).

MystifyEffect

MystifyEffect is a MonoBehaviour that drives the effect on one or more renderers. It holds a reference to a MystifyEffectProfile and manages the runtime material.

Fields

IncludeType includeType

Determines which renderers are affected: OnlyThisObject, IncludeChildren, Custom, or ByLayer. Default: IncludeType.OnlyThisObject.

MeshType meshType

Mesh geometry used for the effect: Existing, Quad, Disc, Sphere, Hexasphere, or Cylinder. Default: MeshType.Existing.

LayerMask includeLayerMask

Layer mask used when includeType is set to IncludeType.ByLayer.

List<Renderer> customRenderers

Explicit list of renderers to affect when includeType is set to IncludeType.Custom.

List<Renderer> renderers

The resolved list of renderers currently being processed by this effect. Populated by GetRenderers(). Not serialized.

Material mat

The runtime material instance used by the effect. Created and managed internally. Not serialized.

bool writesToDepth

Whether the effect currently writes to the depth buffer. Set automatically based on the intersection effect. Not serialized.

bool needsUpdateMaterial

Flag indicating the material needs to be rebuilt on the next update. Set to true by UpdateMaterialProperties(). Not serialized.

List<HitRequest> hitRequests

Queue of pending hit-effect requests. Populated by calling HitFX(). Not serialized.

Static Fields

static readonly List<MystifyEffect> instances

Global list of all currently enabled MystifyEffect instances in the scene. Updated automatically on enable/disable.

Properties

MystifyEffectProfile profile

Per-instance profile. Reading this property clones the shared profile on first access (like Renderer.material). Assigning a profile clones it and makes the copy owned by this effect.

MystifyEffectProfile sharedProfile

Direct reference to the shared profile asset. Changes to this profile affect all effects that share it (like Renderer.sharedMaterial). Setting this clears any per-instance clone.

Methods

void Refresh()

Clears the renderer cache, re-validates profile settings, and marks the material for update. Call after changing includeType or renderer lists.

virtual void GetRenderers()

Resolves which renderers to affect based on the current includeType. Populates the renderers list.

void GetRenderersByLayer()

Finds all renderers in the scene whose layer matches includeLayerMask and adds them to the renderers list.

void UpdateMaterialProperties()

Marks the material as needing an update. The actual update happens on the next render pass. Call this after modifying profile fields at runtime.

void UpdateMaterialPropertiesNow()

Immediately rebuilds the material with current profile settings, including all shader keywords and uniform values. Normally called internally by the render feature.

void HitFX(Vector3 position, float intensity = 0, Color color = default, float radius = 0, float speed = 0, float noiseAmount = 0, float noiseScale = 0)

Triggers a hit effect at the given world-space position. Parameters default to values from the profile if omitted or zero. The hit expands outward and fades over time.

MystifyEffectProfile

MystifyEffectProfile is a ScriptableObject that holds every effect setting. Create one via Assets > Create > Mystify FX Profile and assign it to a MystifyEffect component.

Rendering

CullMode cullMode

Face culling mode. Default: CullMode.Back.

WrapMode wrapMode

UV wrap mode for the effect texture. Default: WrapMode.Repeat.

TextureSource textureSource

Source for the effect texture: Screen (grab-pass) or Object (object texture). Default: TextureSource.Screen.

bool renderOnTop

If true, the effect renders on top of all other scene objects (sets depth test to Always). Default: false.

bool grabPass

If true, the effect renders over the results from other Mystify FX objects. Default: false.

bool alwaysOn

If true, the effect renders even if the renderer component is disabled. Default: true.

Texture2D maskTexture

Mask texture that controls where effects are applied. The alpha channel specifies effect intensity.

float alphaCutoff

Pixels with alpha less than this value are discarded. Range: 0–1.

float globalOpacity

Overall opacity of the effect. Range: 0–1. Default: 1.

MystifyEffect owner

Reference to the MystifyEffect that owns this profile instance. Set automatically when a per-instance clone is created.

Stop Motion

bool useStopMotion

If true, animated effects use a stop-motion style (discrete frame steps). Default: false.

float stopMotionInterval

Time interval between stop-motion frames (in seconds). Default: 0.125.

UV / Transform

float scaleFactor

Overall scale multiplier for the effect. Minimum: 1. Default: 1.

float zoomFactor

Zoom factor applied to the effect. Minimum: 1. Default: 1.

Vector2 sourceOffset

Offset applied to the source texture coordinates.

Vector2 sourceScale

Scale applied to the source texture coordinates. Default: Vector2.one.

Vector2 uvOffset

Offset applied to the UV coordinates.

Vector2 uvScale

Scale applied to the UV coordinates. Default: Vector2.one.

float vertexDistortion

Amount of vertex-level distortion applied to the mesh geometry. Default: 0.

float vertexDistortionSpeed

Animation speed of the vertex distortion. Default: 1.

Blur

float blurIntensity

Intensity of the blur effect. Range: 0–1. Default: 0.

Color / Tint

float brightness

Brightness multiplier. Range: 0–2. Default: 1.

float contrast

Contrast adjustment. Range: 0.5–1.5. Default: 1.

float vibrance

Color vibrance. Range: −2–3. Default: 0.

ColorEffect lutEffect

Color effect mode: None, LUT, Thermal, or DirectionalTint. Default: ColorEffect.None.

Texture lutTexture

LUT texture (2D or 3D) used when lutEffect is set to ColorEffect.LUT.

float lutIntensity

Intensity of the LUT color grading effect. Range: 0–1. Default: 1.

Gradient tintGradient

HDR gradient used for the directional tint effect (when lutEffect is ColorEffect.DirectionalTint).

Vector3 tintPos1

Start position of the directional tint gradient in local space. Default: (0, -0.5, 0).

Vector3 tintPos2

End position of the directional tint gradient in local space. Default: (0, 0.5, 0).

bool tintApplyAlphaToAll

If true, the gradient alpha channel is applied to the entire effect, not just the tint layer. Default: false.

Texture2D tintGradientTex

Baked 1D texture generated from tintGradient. Updated automatically via CheckTintColors().

int pixelate

Pixelation level. Higher values increase the pixel size. Range: 0–255. Default: 0.

Distortion

bool distortion

Enables the UV distortion effect. Default: false.

Vector2 distortionAmplitude

Amplitude of the distortion on the X and Y axes.

float distortionFrequency

Frequency of the distortion wave pattern. Default: 3.

float distortionAnimationSpeed

Speed of the distortion animation. Default: 1.

float distortionFalloff

Falloff curve for the distortion effect. Default: 5.

float distortionRimPower

Increase to limit the distortion to the edges of the object. Default: 0.

Rim

float rimIntensity

Intensity of the rim lighting effect. Range: 0–1. Default: 0.

float rimPower

Sharpness of the rim falloff. Higher values produce a tighter rim. Default: 5.

Color rimColor

Color of the rim lighting (HDR, no alpha). Default: Color.yellow.

Texture2D rimTexture

Optional texture applied to the rim area.

float rimTextureOpacity

Opacity of the rim texture. Range: 0–1. Default: 1.

float rimTextureScale

Tiling scale of the rim texture. Default: 8.

Scan Lines

float scanLinesIntensity

Intensity of the scan lines effect. Range: 0–1. Default: 0.

bool scanLinesScreenSpace

If true, scan lines are computed in screen space rather than object space. Default: false.

int scanLinesSize

Size (thickness) of the scan lines in pixels. Minimum: 2. Default: 4.

float scanLinesAnimationSpeed

Scroll speed of the scan lines animation. Default: 0.

Color scanLinesColor

Color of the scan lines (HDR, no alpha). Default: Color.black.

float scanLinesMaxDistance

Maximum view distance for scan lines visibility. Range: 0.001–10. Default: 2.

float scanLinesRotation

Rotation angle of the scan lines in degrees. Range: −180–180. Default: 0.

Noise

float noiseSize

Scale of the noise pattern. Range: 1–32. Default: 2.

float noiseAmount

Amount of noise applied to the effect. Range: 0–1. Default: 0.

Haze

float hazeIntensity

Intensity of the haze overlay. Default: 0.

float hazeThreshold

Threshold that controls haze visibility. Default: 0.5.

MappingMode hazeMode

Mapping mode for haze coordinates: 2D (object space) or 3D (world space). Default: MappingMode._3D.

Gradient hazeGradient

Color gradient used for the haze effect.

Vector2 hazeScale

Scale of the haze pattern. Default: (0.2, 0.2).

float hazeSpeed

Animation speed of the haze effect. Default: 1.

Texture2D hazeGradientTex

Baked 1D texture generated from hazeGradient. Updated automatically via CheckHazeColors().

Frost

float frostIntensity

Intensity of the frost overlay effect. Default: 0.

float frostSpread

How far the frost spreads from the edges. Default: 2.5.

Color frostColor

Tint color of the frost overlay. Default: Color.white.

Crystalize

float crystalize

Amount of crystallization distortion. Range: 0–0.2. Default: 0.

float crystalizeSpread

Spread of the crystallization pattern. Default: 0.

Vector2 crystalizeAnimationSpeed

Animation speed for the crystal pattern on X and Y axes.

Vector2 crystalizeScale

Scale of the crystal pattern. Default: (1, 1).

Intersection

bool intersection

Enables the depth-based intersection highlight effect. Default: false.

float intersectionThickness

Thickness of the intersection highlight. Range: 0.1–2. Default: 0.5.

Color intersectionColor

Color of the intersection highlight (HDR with alpha). Default: Color.white.

bool intersectionNoise

Adds noise to the intersection edge for a rougher look. Default: true.

Hexa Grid

bool hexaGrid

Enables the hexagonal grid overlay. Default: false.

float hexaGridScale

Scale of the hexagonal cells. Default: 1.

Color hexaGridColor

Color of the hex grid lines (HDR with alpha). Default: (1, 1, 1, 0.35).

float hexaGridRimPower

Rim power for the hex grid, limiting the grid to edges. Default: 0.

float hexaGridNoiseStrength

Strength of noise applied within hexagonal cells. Default: 5.

Color hexaGridNoiseColor

Color of the hexagonal grid noise (HDR with alpha). Default: (0.5, 0.5, 1, 0.65).

float hexaGridNoiseThreshold

Threshold for noise visibility within hex cells. Range: 0–1. Default: 0.3.

float hexaGridNoiseScale

Scale of the noise pattern within hex cells. Default: 0.2.

float hexaGridSweepAmount

Intensity of the sweeping highlight animation on the hex grid. Default: 0.

float hexaGridSweepSpeed

Speed of the hex grid sweep animation. Default: 1.

float hexaGridSweepFrequency

Frequency of the hex grid sweep bands. Default: 1.5.

Hit FX

float hitIntensity

Default intensity for hit effects. Range: 0–1. Default: 0.

Color hitColor

Default color for hit effects (HDR, no alpha). Default: Color.yellow.

float hitRadius

Default radius of the hit effect. Default: 0.2.

float hitSpeed

Default animation speed for hit effects. Default: 1.

float hitNoiseScale

Scale of the noise pattern on hit effects. Range: 0–1. Default: 1.

float hitNoiseAmount

Amount of noise distortion on hit effects. Range: 0–1. Default: 1.

Rain / Glass

bool rain

Enables the rain/glass water drop effect. Default: false.

float glassTinyDrops

Intensity of tiny stationary water drops. Range: 0–1. Default: 0.6.

int glassTinyDropsGridSize

Grid density for tiny drops. Higher values produce more, smaller drops. Range: 48–256. Default: 64.

float glassLargeDrops

Intensity of large sliding water drops. Range: 0–1. Default: 0.7.

int glassLargeDropsGridSize

Grid density for large drops. Range: 9–24. Default: 12.

float glassLargeDropsSpeed

Speed at which large drops slide down. Range: −10–10. Default: 1.

float glassWaterDropIntensity

Overall refraction intensity of water drops. Range: 0–1. Default: 1.

float rainfall

Amount of visible rainfall. Range: 0–1. Default: 0.15.

float rainWind

Wind direction bias for rain drops. Range: −1–1. Default: 0.

float rainSpeed

Speed of the rain animation. Range: −2–2. Default: 1.

Fake Light

bool fakeLight

Enables the fake volumetric light effect (requires camera depth texture). Default: false.

float fakeLightIntensity

Intensity of the fake light. Default: 0.

float fakeLightFog

Amount of fog/haze blended into the fake light. Default: 0.15.

Gradient fakeLightGradient

Color gradient used for the fake light effect.

float fakeLightFalloff

Falloff curve of the fake light. Range: 0–1. Default: 0.5.

float fakeLightSpeed

Animation speed of the fake light gradient. Default: 0.

Texture2D fakeLightGradientTex

Baked 1D texture generated from fakeLightGradient. Updated automatically via CheckFakeLightColors().

Chromatic Aberration

float chromaticAberrationAmount

Amount of chromatic aberration (RGB channel separation). Range: 0–0.01. Default: 0.

float chromaticAberrationEdgePower

Power curve that limits chromatic aberration to edges. Range: 0–1. Default: 0.

Methods

void ValidateSettings()

Clamps all fields to their valid ranges and regenerates baked gradient textures. Called automatically on enable and validation.

void CheckHazeColors()

Regenerates the baked haze gradient texture from hazeGradient.

void CheckTintColors()

Regenerates the baked tint gradient texture from tintGradient.

void CheckFakeLightColors()

Regenerates the baked fake-light gradient texture from fakeLightGradient.

Code Examples

Toggle Distortion at Runtime

MystifyEffect fx = GetComponent<MystifyEffect>();
MystifyEffectProfile p = fx.profile;
p.distortion = !p.distortion;
p.distortionAmplitude = new Vector2(0.05f, 0.03f);
p.distortionFrequency = 5f;
fx.UpdateMaterialProperties();

Trigger a Hit Effect

MystifyEffect fx = GetComponent<MystifyEffect>();

// Use profile defaults (intensity, color, radius, etc.)
fx.HitFX(transform.position);

// Or override specific parameters
fx.HitFX(
    position: hitPoint,
    intensity: 0.9f,
    color: Color.red,
    radius: 0.5f,
    speed: 2f
);

Swap Profile at Runtime

public MystifyEffectProfile shieldProfile;
public MystifyEffectProfile damageProfile;

void ActivateShield()
{
    MystifyEffect fx = GetComponent<MystifyEffect>();
    fx.sharedProfile = shieldProfile; // all objects sharing this profile update
}

void TakeDamage()
{
    MystifyEffect fx = GetComponent<MystifyEffect>();
    fx.profile = damageProfile; // per-instance clone, only this object changes
    fx.UpdateMaterialProperties();
}

Animate Haze Intensity Over Time

MystifyEffect fx;
MystifyEffectProfile p;

void Start()
{
    fx = GetComponent<MystifyEffect>();
    p = fx.profile;
}

void Update()
{
    p.hazeIntensity = Mathf.PingPong(Time.time * 0.5f, 1f);
    fx.UpdateMaterialProperties();
}

Find All Active Mystify Effects

// Use the static instances list instead of FindObjectsOfType
foreach (MystifyEffect fx in MystifyEffect.instances)
{
    MystifyEffectProfile p = fx.profile;
    p.globalOpacity = 0.5f;
    fx.UpdateMaterialProperties();
}

Rain Effect with Wind

MystifyEffect fx = GetComponent<MystifyEffect>();
MystifyEffectProfile p = fx.profile;

p.rain = true;
p.rainfall = 0.4f;
p.rainWind = 0.3f;
p.glassTinyDrops = 0.8f;
p.glassLargeDrops = 0.9f;
p.glassWaterDropIntensity = 0.7f;
fx.UpdateMaterialProperties();
Was this page helpful?