Scripting Support (C#)
advanced scriptingMystify FX · Scripting Support (C#)
MystifyFXMain class:
MystifyEffect (MonoBehavior) — attach to any GameObject with a Renderer.Settings: stored in
MystifyEffectProfile (ScriptableObject). Create via Assets > Create > Mystify FX Profile.
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();
}
}
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 includeTypeDetermines which renderers are affected: OnlyThisObject, IncludeChildren, Custom, or ByLayer. Default: IncludeType.OnlyThisObject.
MeshType meshTypeMesh geometry used for the effect: Existing, Quad, Disc, Sphere, Hexasphere, or Cylinder. Default: MeshType.Existing.
LayerMask includeLayerMaskLayer mask used when includeType is set to IncludeType.ByLayer.
List<Renderer> customRenderersExplicit list of renderers to affect when includeType is set to IncludeType.Custom.
List<Renderer> renderersThe resolved list of renderers currently being processed by this effect. Populated by GetRenderers(). Not serialized.
Material matThe runtime material instance used by the effect. Created and managed internally. Not serialized.
bool writesToDepthWhether the effect currently writes to the depth buffer. Set automatically based on the intersection effect. Not serialized.
bool needsUpdateMaterialFlag indicating the material needs to be rebuilt on the next update. Set to true by UpdateMaterialProperties(). Not serialized.
List<HitRequest> hitRequestsQueue of pending hit-effect requests. Populated by calling HitFX(). Not serialized.
Static Fields
static readonly List<MystifyEffect> instancesGlobal list of all currently enabled MystifyEffect instances in the scene. Updated automatically on enable/disable.
Properties
MystifyEffectProfile profilePer-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 sharedProfileDirect 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 cullModeFace culling mode. Default: CullMode.Back.
WrapMode wrapModeUV wrap mode for the effect texture. Default: WrapMode.Repeat.
TextureSource textureSourceSource for the effect texture: Screen (grab-pass) or Object (object texture). Default: TextureSource.Screen.
bool renderOnTopIf true, the effect renders on top of all other scene objects (sets depth test to Always). Default: false.
bool grabPassIf true, the effect renders over the results from other Mystify FX objects. Default: false.
bool alwaysOnIf true, the effect renders even if the renderer component is disabled. Default: true.
Texture2D maskTextureMask texture that controls where effects are applied. The alpha channel specifies effect intensity.
float alphaCutoffPixels with alpha less than this value are discarded. Range: 0–1.
float globalOpacityOverall opacity of the effect. Range: 0–1. Default: 1.
MystifyEffect ownerReference to the MystifyEffect that owns this profile instance. Set automatically when a per-instance clone is created.
Stop Motion
bool useStopMotionIf true, animated effects use a stop-motion style (discrete frame steps). Default: false.
float stopMotionIntervalTime interval between stop-motion frames (in seconds). Default: 0.125.
UV / Transform
float scaleFactorOverall scale multiplier for the effect. Minimum: 1. Default: 1.
float zoomFactorZoom factor applied to the effect. Minimum: 1. Default: 1.
Vector2 sourceOffsetOffset applied to the source texture coordinates.
Vector2 sourceScaleScale applied to the source texture coordinates. Default: Vector2.one.
Vector2 uvOffsetOffset applied to the UV coordinates.
Vector2 uvScaleScale applied to the UV coordinates. Default: Vector2.one.
float vertexDistortionAmount of vertex-level distortion applied to the mesh geometry. Default: 0.
float vertexDistortionSpeedAnimation speed of the vertex distortion. Default: 1.
Blur
float blurIntensityIntensity of the blur effect. Range: 0–1. Default: 0.
Color / Tint
float brightnessBrightness multiplier. Range: 0–2. Default: 1.
float contrastContrast adjustment. Range: 0.5–1.5. Default: 1.
float vibranceColor vibrance. Range: −2–3. Default: 0.
ColorEffect lutEffectColor effect mode: None, LUT, Thermal, or DirectionalTint. Default: ColorEffect.None.
Texture lutTextureLUT texture (2D or 3D) used when lutEffect is set to ColorEffect.LUT.
float lutIntensityIntensity of the LUT color grading effect. Range: 0–1. Default: 1.
Gradient tintGradientHDR gradient used for the directional tint effect (when lutEffect is ColorEffect.DirectionalTint).
Vector3 tintPos1Start position of the directional tint gradient in local space. Default: (0, -0.5, 0).
Vector3 tintPos2End position of the directional tint gradient in local space. Default: (0, 0.5, 0).
bool tintApplyAlphaToAllIf true, the gradient alpha channel is applied to the entire effect, not just the tint layer. Default: false.
Texture2D tintGradientTexBaked 1D texture generated from tintGradient. Updated automatically via CheckTintColors().
int pixelatePixelation level. Higher values increase the pixel size. Range: 0–255. Default: 0.
Distortion
bool distortionEnables the UV distortion effect. Default: false.
Vector2 distortionAmplitudeAmplitude of the distortion on the X and Y axes.
float distortionFrequencyFrequency of the distortion wave pattern. Default: 3.
float distortionAnimationSpeedSpeed of the distortion animation. Default: 1.
float distortionFalloffFalloff curve for the distortion effect. Default: 5.
float distortionRimPowerIncrease to limit the distortion to the edges of the object. Default: 0.
Rim
float rimIntensityIntensity of the rim lighting effect. Range: 0–1. Default: 0.
float rimPowerSharpness of the rim falloff. Higher values produce a tighter rim. Default: 5.
Color rimColorColor of the rim lighting (HDR, no alpha). Default: Color.yellow.
Texture2D rimTextureOptional texture applied to the rim area.
float rimTextureOpacityOpacity of the rim texture. Range: 0–1. Default: 1.
float rimTextureScaleTiling scale of the rim texture. Default: 8.
Scan Lines
float scanLinesIntensityIntensity of the scan lines effect. Range: 0–1. Default: 0.
bool scanLinesScreenSpaceIf true, scan lines are computed in screen space rather than object space. Default: false.
int scanLinesSizeSize (thickness) of the scan lines in pixels. Minimum: 2. Default: 4.
float scanLinesAnimationSpeedScroll speed of the scan lines animation. Default: 0.
Color scanLinesColorColor of the scan lines (HDR, no alpha). Default: Color.black.
float scanLinesMaxDistanceMaximum view distance for scan lines visibility. Range: 0.001–10. Default: 2.
float scanLinesRotationRotation angle of the scan lines in degrees. Range: −180–180. Default: 0.
Noise
float noiseSizeScale of the noise pattern. Range: 1–32. Default: 2.
float noiseAmountAmount of noise applied to the effect. Range: 0–1. Default: 0.
Haze
float hazeIntensityIntensity of the haze overlay. Default: 0.
float hazeThresholdThreshold that controls haze visibility. Default: 0.5.
MappingMode hazeModeMapping mode for haze coordinates: 2D (object space) or 3D (world space). Default: MappingMode._3D.
Gradient hazeGradientColor gradient used for the haze effect.
Vector2 hazeScaleScale of the haze pattern. Default: (0.2, 0.2).
float hazeSpeedAnimation speed of the haze effect. Default: 1.
Texture2D hazeGradientTexBaked 1D texture generated from hazeGradient. Updated automatically via CheckHazeColors().
Frost
float frostIntensityIntensity of the frost overlay effect. Default: 0.
float frostSpreadHow far the frost spreads from the edges. Default: 2.5.
Color frostColorTint color of the frost overlay. Default: Color.white.
Crystalize
float crystalizeAmount of crystallization distortion. Range: 0–0.2. Default: 0.
float crystalizeSpreadSpread of the crystallization pattern. Default: 0.
Vector2 crystalizeAnimationSpeedAnimation speed for the crystal pattern on X and Y axes.
Vector2 crystalizeScaleScale of the crystal pattern. Default: (1, 1).
Intersection
bool intersectionEnables the depth-based intersection highlight effect. Default: false.
float intersectionThicknessThickness of the intersection highlight. Range: 0.1–2. Default: 0.5.
Color intersectionColorColor of the intersection highlight (HDR with alpha). Default: Color.white.
bool intersectionNoiseAdds noise to the intersection edge for a rougher look. Default: true.
Hexa Grid
bool hexaGridEnables the hexagonal grid overlay. Default: false.
float hexaGridScaleScale of the hexagonal cells. Default: 1.
Color hexaGridColorColor of the hex grid lines (HDR with alpha). Default: (1, 1, 1, 0.35).
float hexaGridRimPowerRim power for the hex grid, limiting the grid to edges. Default: 0.
float hexaGridNoiseStrengthStrength of noise applied within hexagonal cells. Default: 5.
Color hexaGridNoiseColorColor of the hexagonal grid noise (HDR with alpha). Default: (0.5, 0.5, 1, 0.65).
float hexaGridNoiseThresholdThreshold for noise visibility within hex cells. Range: 0–1. Default: 0.3.
float hexaGridNoiseScaleScale of the noise pattern within hex cells. Default: 0.2.
float hexaGridSweepAmountIntensity of the sweeping highlight animation on the hex grid. Default: 0.
float hexaGridSweepSpeedSpeed of the hex grid sweep animation. Default: 1.
float hexaGridSweepFrequencyFrequency of the hex grid sweep bands. Default: 1.5.
Hit FX
float hitIntensityDefault intensity for hit effects. Range: 0–1. Default: 0.
Color hitColorDefault color for hit effects (HDR, no alpha). Default: Color.yellow.
float hitRadiusDefault radius of the hit effect. Default: 0.2.
float hitSpeedDefault animation speed for hit effects. Default: 1.
float hitNoiseScaleScale of the noise pattern on hit effects. Range: 0–1. Default: 1.
float hitNoiseAmountAmount of noise distortion on hit effects. Range: 0–1. Default: 1.
Rain / Glass
bool rainEnables the rain/glass water drop effect. Default: false.
float glassTinyDropsIntensity of tiny stationary water drops. Range: 0–1. Default: 0.6.
int glassTinyDropsGridSizeGrid density for tiny drops. Higher values produce more, smaller drops. Range: 48–256. Default: 64.
float glassLargeDropsIntensity of large sliding water drops. Range: 0–1. Default: 0.7.
int glassLargeDropsGridSizeGrid density for large drops. Range: 9–24. Default: 12.
float glassLargeDropsSpeedSpeed at which large drops slide down. Range: −10–10. Default: 1.
float glassWaterDropIntensityOverall refraction intensity of water drops. Range: 0–1. Default: 1.
float rainfallAmount of visible rainfall. Range: 0–1. Default: 0.15.
float rainWindWind direction bias for rain drops. Range: −1–1. Default: 0.
float rainSpeedSpeed of the rain animation. Range: −2–2. Default: 1.
Fake Light
bool fakeLightEnables the fake volumetric light effect (requires camera depth texture). Default: false.
float fakeLightIntensityIntensity of the fake light. Default: 0.
float fakeLightFogAmount of fog/haze blended into the fake light. Default: 0.15.
Gradient fakeLightGradientColor gradient used for the fake light effect.
float fakeLightFalloffFalloff curve of the fake light. Range: 0–1. Default: 0.5.
float fakeLightSpeedAnimation speed of the fake light gradient. Default: 0.
Texture2D fakeLightGradientTexBaked 1D texture generated from fakeLightGradient. Updated automatically via CheckFakeLightColors().
Chromatic Aberration
float chromaticAberrationAmountAmount of chromatic aberration (RGB channel separation). Range: 0–0.01. Default: 0.
float chromaticAberrationEdgePowerPower 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();Suggest an improvement
Help us improve this documentation page.