Search Unity

Resolved How to access Exposed Properties for Advanced Shape Types, like Circle

Discussion in 'Visual Effect Graph' started by Livealot, Apr 25, 2021.

  1. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Playing with the bonfire example, there's an exposed property called "Spawn Area" of type Circle, which is one of the many Shape Types now offered.

    The Circle has two values: a Vector3 called "Center" and a Float called "Radius"

    How do you access any of those via script?

    Something like...
    Code (CSharp):
    1. int spawnAreaID = Shader.PropertyToID("Spawn Area");
    2. myVFX.SetVector3(spawnAreaID, Vector3.one);
    3. myVFX.SetFloat(spawnAreaID, 1.5f);
     
    MEMOMEM likes this.
  2. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    As far as I know it will be property's name combine with value's lowercase name with _.
    You can check it if you enable inspector's Debug Mode and see your VFX' component.
    However it only shows when you enable to edit in your VFX' component.

    If your Circle property called "Circle" then its radius's property name will be "Circle_radius".
    name.jpg
     
    MEMOMEM and Livealot like this.
  3. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Lovely! Thanks @lilacsky824

    The Inspector Debug tip didn't work for me. It just revealed the subvalue name, not the underscore pair like in your screenshot.

    But the underscore syntax does work.

    So the short answer is propertyName_subvalueName

    For my circle example where the circle property is called "Spawn Area"
    Code (CSharp):
    1. spawnAreaCenterID = Shader.PropertyToID("Spawn Area_center");
    2. spawnAreaRadiusID = Shader.PropertyToID("Spawn Area_radius");
     
    MEMOMEM likes this.