Search Unity

Visual Effect Graph

Discussion in 'Scripting' started by nonnicram, Jan 13, 2019.

  1. nonnicram

    nonnicram

    Joined:
    Apr 3, 2014
    Posts:
    20
    Hey Folks,

    i am trying to access via c# the exposed parameters of the visual effects graph. But i don`t know how to access them. There is only verly little documentation for it. What i actually want to do is to control an "exposed" float via Script. I have enabled the "expose" option in the graph for an float, but can`t find the variable. The script is attached to the gameobject where the visual effect object is attached to.

    Thanks for any help!

    Any help is appreciated!
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.VFX;
    5. using UnityEditor.VFX;
    6. using UnityEditor.Experimental.Rendering.HDPipeline;
    7. using UnityEditor.VFX.UI;
    8.  
    9. public class particleMainScript : MonoBehaviour
    10.  
    11. {
    12.     UnityEngine.Experimental.VFX.VisualEffect visualEffect;
    13.     float exposedParameter;
    14.     void Start()
    15.     {
    16.         visualEffect = this.GetComponent<UnityEngine.Experimental.VFX.VisualEffect>();
    17.         // exposedParameter = visualEffect. -> what to insert here to access the expoosed parameter?
    18.     }
    19.     void Update()
    20.     {
    21.         if (Input.GetKey("down")){
    22.             visualEffect.Stop();
    23.         }
    24.         else
    25.         {
    26.             visualEffect.Play();
    27.         }
    28.     }
    29. }
     
    rlagpals likes this.
  2. nonnicram

    nonnicram

    Joined:
    Apr 3, 2014
    Posts:
    20
    Ok, found it out.

    You have to write:

    Code (CSharp):
    1. visualEffect.SetFloat("parameter", 0);
    2.  
    "parameter" is your name of the exposed parameter
     
    Babalou, Aerrixus, rlagpals and 2 others like this.
  3. sergiobd

    sergiobd

    Joined:
    May 14, 2014
    Posts:
    37
    I love you.

    How did you find this out?
     
    Last edited: Mar 31, 2019