Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug In 2022.1.b11, lost subgraph if I open vfx.

Discussion in 'Visual Effect Graph' started by shibi2017, Mar 24, 2022.

  1. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    I add some subgraphs I made in vfx, save it, and it works fine.
    when I want to re-edit it again, open it, the subgraphs all lost and replace by a empty subgraph.
    It happens a lot in my project. And every time I need to add the subgraph and all the properties again.
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hi @shibiUNITY ,

    This shouldn't be happening; can you please log a bug with the vfx and subgraph(s) in question so we can take a look? Also, are there any console errors?

    Thanks!
     
  3. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    here is my console. there are 2 error but can be cleared by click clear button. Its a big projects so I can not figure why these error exist:
    upload_2022-3-26_16-21-40.png
    And for example: here is a vfx using my subgraph:
    upload_2022-3-26_16-21-24.png
    When I copy this vfx file and open the new one. It does missing the subgraph. But not everytime so I can not give you a specific stiation or vfx file to reproduce this error.
    But it did happen in my project.
     
  4. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    When I rename my sub-graph file, it missed in vfx file:
    upload_2022-3-30_15-3-31.png
     
  5. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Are the two issues you mentioned related?
    I just tried renaming a subgraph and did not reproduce the same issue. (the link is though the file's ID, not its name, so renaming it should not affect it).

    If you can file a bug with the assets causing you issues we can take a look, otherwise I'm afraid it's a bit hard to say what's going on.
     
  6. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    it's same issue and occured in same sub-graphs. Because my project is updated from the lower version and only the custom sub-graphs in this project cause this result, I did not find a clear solution to deal with it, so I decide leave it alone.
     
  7. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    But I got a new question about vfx, can you help me here?
    how the VfxOutputEventRigidbody get custom needed data? where should I define the impluse force/ velocity paras?
    I saw the code says: static readonly int k_PositionID = Shader.PropertyToID("position");
    is it means I need creare a global shader property named positon? and use it as my custom position or velocity or other properties?
     
  8. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Output Events are a way to pass the initial values set in the Spawn context over to C#.
    In the VFXOutputEventRigidbody example, here's how the script maps to the VFX attributes:


    In the same example, it is simply using the velocity attribute you set in the VFX Graph to add force to the rigidbody:
    Code (CSharp):
    1.          switch (eventType)
    2.             {
    3.                 case RigidBodyEventType.Impulse:
    4.                     rigidBody.AddForce(velocity, ForceMode.Impulse);
    5.                     break;
    6.                 case RigidBodyEventType.Explosion:
    7.                     rigidBody.AddExplosionForce(velocity.magnitude,  position, size);
    8.                     break;
    9.                 case RigidBodyEventType.VelocityChange:
    10.                     rigidBody.AddForce(velocity, ForceMode.VelocityChange);
    11.                     break;
    12.                 default:
    13.                     break;
    14.             }
    You are just inheriting any attributes set in the Spawn context with SetSpawnEvent [Attribute] for the specific effect you are referencing:


    And this bit is for optimization only, as it's faster to look for an int that do string comparison:
    Code (CSharp):
    1. static readonly int k_Position = Shader.PropertyToID("position");
    2. var position = eventAttribute.GetVector3(k_Position);
    You can also directly do this:
    Code (CSharp):
    1. var position = eventAttribute.GetVector3("position");
    ("position" can be replaced with anything else you want to inherit, "age", "color", etc.)

    You can view in the Inspector the names of all attributes used for a context by selecting a context. In this case, all attributes available in Initialize:

    These are the names you can refer to in your code, and as long as they are set in the SpawnContext, you can grab them in C# and then create your custom logic on what you'd want to do with them (like in the rigibody example, add physics force based on the velocity attribute value, or in the AddExplosionForce option, add a directional explosion based on the velocity, position, and size attributes)

    Important to note, you can only get the initial values with Output Events when the particle first spawns, this will not allow you to continue tracking its values over the particle's lifetime.

    Hope this helps!
     

    Attached Files:

    PaulDemeulenaere and Qriva like this.
  9. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    Definitely! I'm tring to do some vfx base these new features, I'll let you know if I make some good.
     
  10. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    And Now I create an empty prject with Unity 2022.1.b11. I add VFX Additions to my project, when I change the name of vfx file with vfx edit window open, the subgraph inside Additions missing again.
    The Clamp(AABox) turn into an empty subgraph operator, I need to create a new one and reconnect them to fix it.
    upload_2022-4-11_15-34-46.png
     
  11. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    I can see the same issue on my side! We'll take a look, thanks for raising this!
    You can track the resolution here (it may take a few hours for the link to go live)
     
  12. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    thank you and happy to hear that!
     
  13. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    and in my case I think the renaming is not th only one cause this error. You may try to leave the window open and change other obejcts in scene or any file name. Sometime a ctrl+s inside editor casue this error to me.
     
  14. shibi2017

    shibi2017

    Joined:
    Jan 18, 2018
    Posts:
    153
    edit code and save when I leave the vfx window open:
    upload_2022-4-12_13-57-34.png