C# API | Visual Effect Graph | 6.9.2-preview
docs.unity3d.com
    Show / Hide Table of Contents

    C# API

    Here is the summary of the C# API available to the Visual Effects Component

    General API

    General API Functions are used for common control over the Component

    Name Signature Description
    culled public bool culled { get; }
    resetSeedOnPlay public bool resetSeedOnPlay { get; set; }
    public uint startSeed { get; set; }
    public float playRate { get; set; }
    public bool pause { get; set; }
    public VisualEffectAsset visualEffectAsset { get; set; }
    public int aliveParticleCount { get; }
    public void AdvanceOneFrame();
    public void Play(VFXEventAttribute eventAttribute = null);
    public void Reinit();
    public void Stop(VFXEventAttribute eventAttribute = null);

    Parameter API

    Parameter API enables control over Parameter Interface. Parameters can be overriden to other values and reverted to their default values.

    Every function can refer to a parameter using either a string name or an int nameID. If you need to perform access to these parameters on a per-frame basis you should cache the name and perform calls with the ID using Shader.PropertyToID()

    Use the parameter API to test if a parameter is present before accessing it.

    Name Signature Description
    ResetOverride void ResetOverride(int nameID); void ResetOverride(string name); Resets an overriden parameter to its default value, and removes its overriden state.
    Has* bool HasAnimationCurve(int nameID);
    bool HasBool(string name);
    bool HasBool(int nameID);
    bool HasFloat(int nameID);
    bool HasFloat(string name);
    bool HasGradient(int nameID);
    bool HasGradient(string name);
    bool HasInt(string name);
    bool HasInt(int nameID);
    bool HasMatrix4x4(string name);
    bool HasMatrix4x4(int nameID);
    bool HasMesh(int nameID);
    bool HasMesh(string name);
    bool HasTexture(int nameID);
    bool HasTexture(string name);
    bool HasUInt(int nameID);
    bool HasUInt(string name);
    bool HasVector2(int nameID);
    bool HasVector2(string name);
    bool HasVector3(string name);
    bool HasVector3(int nameID);
    bool HasVector4(int nameID);
    bool HasVector4(string name);
    Returns true if a parameter of given type and name/id is exposed
    Get AnimationCurve GetAnimationCurve(int nameID);
    AnimationCurve GetAnimationCurve(string name);
    bool GetBool(int nameID);
    bool GetBool(string name);
    float GetFloat(string name);
    float GetFloat(int nameID);
    Gradient GetGradient(string name);
    Gradient GetGradient(int nameID);
    int GetInt(int nameID);
    int GetInt(string name);
    Matrix4x4 GetMatrix4x4(string name);
    Matrix4x4 GetMatrix4x4(int nameID);
    Mesh GetMesh(string name);
    Mesh GetMesh(int nameID);
    Texture GetTexture(string name);
    Texture GetTexture(int nameID);
    uint GetUInt(string name);
    uint GetUInt(int nameID);
    Vector2 GetVector2(string name);
    Vector2 GetVector2(int nameID);
    Vector3 GetVector3(string name);
    Vector3 GetVector3(int nameID);
    Vector4 GetVector4(string name);
    Vector4 GetVector4(int nameID);
    Gets a value for a given named parameter or ID.
    Set void SetAnimationCurve(int nameID, AnimationCurve c);
    void SetAnimationCurve(string name, AnimationCurve c);
    void SetBool(string name, bool b);
    void SetBool(int nameID, bool b);
    void SetFloat(string name, float f);
    void SetFloat(int nameID, float f);
    void SetGradient(string name, Gradient g);
    void SetGradient(int nameID, Gradient g);
    void SetInt(int nameID, int i);
    void SetInt(string name, int i);
    void SetMatrix4x4(string name, Matrix4x4 v);
    void SetMatrix4x4(int nameID, Matrix4x4 v);
    void SetMesh(string name, Mesh m);
    void SetMesh(int nameID, Mesh m);
    void SetTexture(string name, Texture t);
    void SetTexture(int nameID, Texture t);
    void SetUInt(string name, uint i);
    void SetUInt(int nameID, uint i);
    void SetVector2(int nameID, Vector2 v);
    void SetVector2(string name, Vector2 v);
    void SetVector3(int nameID, Vector3 v);
    void SetVector3(string name, Vector3 v);
    void SetVector4(string name, Vector4 v);
    void SetVector4(int nameID, Vector4 v);
    Sets a given parameter name or id to a given value. Calling this function will result on the parameter being overridden.
    GetTextureDimension TextureDimension GetTextureDimension(string name);
    TextureDimension GetTextureDimension(int nameID);
    Returns a TextureDimension struct corresponding to the current Texture set in the given (name/ID) parameter.

    Event API

    Event API enables Sending events to the component with optional Event attribute payloads.

    VisualEffect Component

    Name Signature Description
    CreateVFXEventAttribute VFXEventAttribute CreateVFXEventAttribute(); Creates a VFXEventAttribute from the current component.
    SendEvent void SendEvent(string eventName, VFXEventAttribute eventAttribute = null); Sends a named event with a given VFXEventAttribute payload. This payload needs to be created for this specific component.

    VFXEventAttribute

    VFXEventAttributes can be created for a specific component and can be passed to the SendEvent method. You can copy event attributes between components using the CopyValuesFrom() method.

    Name Signature Description
    CopyValuesFrom void CopyValuesFrom([NotNull] VFXEventAttribute eventAttibute); Copies values from another VFXEventAttribute
    Has* bool HasBool(string name);
    bool HasBool(int nameID);
    bool HasFloat(int nameID);
    bool HasFloat(string name);
    bool HasInt(string name);
    bool HasInt(int nameID);
    bool HasMatrix4x4(string name);
    bool HasMatrix4x4(int nameID);
    bool HasUInt(int nameID);
    bool HasUInt(string name);
    bool HasVector2(int nameID);
    bool HasVector2(string name);
    bool HasVector3(string name);
    bool HasVector3(int nameID);
    bool HasVector4(int nameID);
    bool HasVector4(string name);
    Returns true if an attribute of given type and name/id is set
    Get bool GetBool(int nameID);
    bool GetBool(string name);
    float GetFloat(string name);
    float GetFloat(int nameID);
    int GetInt(int nameID);
    int GetInt(string name);
    Matrix4x4 GetMatrix4x4(string name);
    Matrix4x4 GetMatrix4x4(int nameID);
    uint GetUInt(string name);
    uint GetUInt(int nameID);
    Vector2 GetVector2(string name);
    Vector2 GetVector2(int nameID);
    Vector3 GetVector3(string name);
    Vector3 GetVector3(int nameID);
    Vector4 GetVector4(string name);
    Vector4 GetVector4(int nameID);
    Gets a value for a given named attribute or ID.
    Set void SetBool(string name, bool b);
    void SetBool(int nameID, bool b);
    void SetFloat(string name, float f);
    void SetFloat(int nameID, float f);
    void SetGradient(string name, Gradient g);
    void SetGradient(int nameID, Gradient g);
    void SetInt(int nameID, int i);
    void SetInt(string name, int i);
    void SetMatrix4x4(string name, Matrix4x4 v);
    void SetMatrix4x4(int nameID, Matrix4x4 v);
    void SetUInt(string name, uint i);
    void SetUInt(int nameID, uint i);
    void SetVector2(int nameID, Vector2 v);
    void SetVector2(string name, Vector2 v);
    void SetVector3(int nameID, Vector3 v);
    void SetVector3(string name, Vector3 v);
    void SetVector4(string name, Vector4 v);
    void SetVector4(int nameID, Vector4 v);
    Sets a given attribute name or id to a given value. Calling this function will result on the parameter being overridden.

    ​

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023