Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Shape Request: Picture Frame

Discussion in 'Visual Effect Graph' started by Livealot, May 11, 2021.

  1. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    So there's already a Circle Shape, which is the 2D equivalent of the Sphere. But there's not yet a Square Shape, as the 2D equivalent of the AABox.

    I know there are workarounds, like using 4 line emitters, or emitting from a square object, but having a Square Shape would be handy for common scenarios like:
    1. Emitting from outside the gameview, and then animating into the game view (No popping!!!)
    2. Emitting from the outer edge of a rect (sparkly buttons), or in a sequence around the perimeter
    If I'm missing an obvious way to do those with the current shapes, please educate me.
     
  2. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    549
    Hey @Livealot ,

    Would a box shape with 0 depth not work?
     

    Attached Files:

  3. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Tried that, and no. The particles still spawn across the full surface, rather than just at the edges. So there's no way to get the clean outline of the box.
     
  4. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Square "Outline" might be a better descriptor than square
    SqShape.JPG
     
  5. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    549
    Oh, I see. You can maybe do a boolean-type setup where you spawn in a square and kill off particles in a slightly smaller square.


    But yes, there's nothing out of the box which directly that produces a square outline position that I can think of. Feel free to submit a feature request idea, and in the meantime if you find that you use it a lot and the above solution doesn't work for you, I'd recommend making a subgraph with custom logic to create an outline square so you can easily drop it in any project.
     

    Attached Files:

    Livealot likes this.
  6. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Here's a pretty generic graph setup to spawn a picture frame with parameters for width, height, and thickness of the border PictureFrameSpawn.JPG
     
    VladVNeykov likes this.
  7. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    549
    Nice! You can combine all of this into a subgraph block and have your own slick picture frame position shape block which you can reuse between other graphs in your project :)
     
    Livealot likes this.
  8. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    Wowzer! I use operator subgraphs a lot, but didn't know that I could subgraph blocks and systems and all the combinations. Awesome!

    Here's the doc reference I found on it

    Here's my shiny, compact Window Box Block
    PictureFrameSubgraphBlock.JPG

    The right-click to create was super easy, with a couple of notes:
    • My first attempt failed since I selected a group of operators rather than the individual operators which is required to be included in the sub-graph. Being able to add groups would be nice.
    • There's no undo. That's fine, but without warning and without backing up a graph first, that could lead to lost progress, all because you mis-clicked a node. Or later decided a subgraph wasn't the way to go.
    Overall, great feature!
     
    VladVNeykov likes this.
  9. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    549
    That's a really good point, I've jotted it down as a UX issue, it should include the contents of the group.

    Hm, this should not be the case. I think you need to maybe undo 1-2 times more (to account for any selection change) but I just tried it and it should work:

    (note: undo will not delete the subgraph asset you created, but it should restore the operators/blocks within your graph)

    Thanks for the feedback, glad you got it working!
     

    Attached Files:

    laurentlavigne and Livealot like this.
  10. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    OK. Ctrl-Z works great for Undo, as you say. That's great, and all I need.

    I had right-clicked the new subblock graph, and didn't see any option to Undo. There's options like "Disconnect All" but nothing similar to the opposite of "Convert to Subgraph Block", something like "Expand/Expose/Explode/Undo Subgraph Block". That is probably harder to implement than it is valuable to have.

    While I marked this thread "Resolved" as I now have a basic workaround, I still want the Picture Frame feature that I submitted to the list. Reasons include:
    1. Picture frames are a really common scenario for both the screen and UI elements
    2. This workaround technique has a very spotty distribution of spawned particles in the desired space, since it's the edges of another space that IS evenly distributed.
    3. A dedicated shape could include features from other shapes, like Set Position: Sequential to spawn around the edge/perimeter of the shape, or Arc to control sections of the shape (like the top right corner of the picture frame), or a Position Mode that flips whether particles initially spawn/move into or away from the picture frame. Lots of fun possibilities to build upon.
    Thanks for all the help!