Search Unity

  1. Unity 2019.4 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[FREE] Shapes2D - Procedural 2D shapes for Sprites and UI

Discussion in 'Assets and Asset Store' started by all_iver, May 21, 2016.

  1. TheHumanHack

    TheHumanHack

    Joined:
    Aug 17, 2017
    Posts:
    3
    This asset is rad. I am, however, having an issue getting the functionality that it is designed for. For instance when I go to customize a polygon I am unable to manipulate the nodes of the shape consistently. What happens is the node jumps directly to a non-intended spot which appears to be dependent on where my editor camera is.

    That is, when I click on a node and move the mouse the node will jump to a specific point within the white square bound, if I select a second node and attempt to move it without repositioning my editor cam then the second node jumps to the same place the first node jumped to. If i move the camera then the node will jump to another location when attempting to manipulate.

    I can very barely move the node from this position, only a few hundredths of a unit at a time regardless of mouse sensitivity.

    Additionally I am having an issue saving sprites, it is unreliable which layer will be applied to the top regardless of which generation the individual elements are placed on.
     
  2. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    Hmm, are you in 2D mode in the editor view? It doesn't work well in 3D mode. There could be something else going on too though.

    What do you mean by "which generation the individual elements are placed on"? Is this with sprite shapes or UI shapes?
     
  3. TheHumanHack

    TheHumanHack

    Joined:
    Aug 17, 2017
    Posts:
    3
    I will try it in 2d mode.

    By generation I meant it was inconsistent if the parent or the child would be overlapping. I tried several different methods and they all worked or didn't work seemingly randomly.

    Methods tried were:
    Creating the shapes objects in sequence(first object then directly creating a child)
    Opposite sequence( creating the child then the parent and making the child a child of the parent)
    Creating an empty GO and then making both objects children of that
    Creating an empty GO and making the intended parent a child of that and the intended child a child of the parent.
     
  4. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    If it's a sprite shape, then it should obey the sorting layer and order you set up in your SpriteRenderers. If two shapes are in the same sorting order/sorting layer then it will go by the z world position. If it's a UI shape then it should be based on the order of the child GameObjects in the hierarchy. It sounds like maybe you're using a sprite shape and not setting the sorting layer/sorting order? That would give you undefined results, I think.
     
  5. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    64
    Edit path is not working in 2019.3.12f1.
    When I click on Edit Path in inspector unity editing hides but the path points does not show.
    Please help!

    Plus i think there should be a gradient color for outline too.
     
  6. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    It works for me in 2019.3.12f1, is it possible you have gizmos turned off globally or for the Shape component? A gradient for outlines is a good idea, I'm in maintenance mode for Shapes2D due to other projects taking my time, but you could put it as a feature request in Github if you want.
     
    tahir_ali likes this.
  7. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    64

    Global Gismoz are enabled. Scripts hides its all editor if I disable Shape gismos.(Issue is still there)

    I put the feature idea in github issues. I add one more thing in the feature Corner based gradient like multiple gradient on single shapre.If its easy you can add it.
     
  8. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    Hmm, in that case I'm not sure what the issue is. Can you send a screenshot to oliver@sub-c.org? Maybe I'll notice something if I can see your screen.
     
  9. tahir_ali

    tahir_ali

    Joined:
    Jan 6, 2018
    Posts:
    64
    Fortunately it started working.
    I was trying to make video of issue. So for better view I changed the layout. After changing Layout of editor from 2 by 3 to default it started working. :)
     
    all_iver likes this.
  10. Askins

    Askins

    Joined:
    Jul 3, 2017
    Posts:
    11
    Holy moly this is an excellent plugin! I was busy trying to get these kinds of shapes using the SVG features in Unity now, but this gives such a better range of control. Really great stuff!
     
    all_iver likes this.
  11. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    Thanks @Askins, glad you like it!
     
  12. Askins

    Askins

    Joined:
    Jul 3, 2017
    Posts:
    11
    Just a quick question regarding performance, it says in the documentation that simple shapes such as rectangles are fine when not converted to sprite, I presume rounded rectangles apply to this instance? I'm debating whether to use this plugin or the new svg feature for my assets in Unity and I'm wondering what method would be best for performance for my mobile game. A lot of the shapes in my game will be made up of simple vector shapes so I'm currently using imported svgs for my assets, however because of lack of 9 slice (it's still currently in Preview) even rounded rectangles have to be made in a roundabout way in Unity if I want to have any control over their size. If this plugin can give roughly the same amount of performance as svg meshes on mobile though then this will be a much easier solution in the end, it'd be great to have your thoughts on it. Ideally it'd be amazing to have an option to convert to an svg sprite instead of a png, would this be possible at all? I presume it'd be quite complicated due to the way the shaders work but it'd be a brilliant option to have if possible.

    Also does animating these shapes alter the way the shaders are calculated at all? In most cases these shapes will be used for BG stuff so will be mostly static and not altered dynamically in runtime, but it'd be great to know how the shaders work so I can optimize them as much as possible!

    Thanks again, it's a truly brilliant plugin!
     
  13. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    Unfortunately I don't have a satisfying answer to this. Rectangles (round or not) are the fastest shape to render since the shader is pretty simple, but I haven't used Unity's SVG stuff so I don't know how that compares. It's been a long time since I did any performance tests. Maybe you could do a test on your target platform and see if performance is good enough with the amount of shapes you need (make sure they are sized correctly too).

    The other potential risk is that occasionally I get a bug report that some device doesn't render Shapes2D correctly, and it's hard for me to troubleshoot without the device. The only current problem I know of has to do with radial gradients (it's in the github issues), but I'd assume Unity's SVG stuff will be more battle tested in that respect.

    I'm not sure how hard it would be to convert to an SVG sprite. It probably depends on what kind of shape settings you use...it might be possible though. So your issue is just that it's harder to create the SVGs but really you want them as SVGs? I guess I'm wondering how many shape types you need and how much time you think you'd save vs just powering through and making them as SVGs.

    It's not so much that the shaders change, it's that each time you change a shape's settings then it has to send the new shader parameters to the GPU which is slow if you need to do that every frame for a lot of shapes. Again, I'd recommend you test on your target platform.

    I guess it depends on whether you can test enough to be confident beforehand, or if you just want to get something going quickly and potentially replace it later. Sorry I don't have a better answer!
     
  14. IcarusCell

    IcarusCell

    Joined:
    Dec 7, 2019
    Posts:
    2
    Heya! This is an incredibly useful tool, though one part of it is refusing to function on my end for some reason. Any time I attempt to edit a polygon none of the nodes appear. Any idea what could be causing the issue? Ive tried 2d and 3d mode, and reinstalling.
     
  15. yaboo

    yaboo

    Joined:
    Mar 23, 2016
    Posts:
    34
    Each Shape generate drawCall. Is it possible to optimize?
     

    Attached Files:

  16. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    @IcarusCell is it possible you have gizmos turned off in the editor? That's all I can think of right now that might cause it...what version of Unity are you using?
     
  17. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    @yaboo yeah, each Shape uses its own material. It's possible they could be batched or instanced or something, I think Unity has made some changes since I last checked. But unfortunately I don't have the time to look into it in depth now, sorry!
     
  18. IcarusCell

    IcarusCell

    Joined:
    Dec 7, 2019
    Posts:
    2
    Gizmos are on and the version is 2019.2.11f1
     
  19. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    Can you send me a screenshot of what it looks like when you try to edit a polygon? Maybe I will notice something. You can email oliver@sub-c.org.
     
  20. VaccionesMad

    VaccionesMad

    Joined:
    Apr 17, 2014
    Posts:
    3
    Hello Oliver, first of all I'd like to congratulate you on such a fantactic Unity Asset. Way to go man :D

    I came with a doubt about converting to sprites that my artist is having (pretty sure we messed up somewhere).

    He was saying that during the Shape creation and editing it looks straight with no blur on the edges, like this basically.

    Pre Convert to Sprite.png

    But when he converts it to sprite it gets all blurry like this

    Post Convert to Sprite.png

    We were wondering where we messed up to make it look smooth, any help is appreciated.
     

    Attached Files:

  21. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
    Thanks @VaccionesMad ! A sprite will be blurry compared to a Shape because the Shape is recalculated on the fly depending on how you're looking at it. You're zoomed in close in that screenshot, are you saying it still looks too blurry at the normal zoom level? In a Screen Space canvas the size of your Shape determines the size of your PNG sprite. So if the shape is 64x64 canvas units you get a 64x64 pixel PNG, the bigger you scale it up the less blurry it would be at the expense of file size.

    Here's a change that would make it easier, I should probably do this in the official version too...

    in Shapes2D/Scripts/Shapes.cs, change the lines at 1514,1515 from this:

    Code (CSharp):
    1. w = Mathf.Max(1, Mathf.RoundToInt(bounds.size.x / scaleFactor));
    2. h = Mathf.Max(1, Mathf.RoundToInt(bounds.size.y / scaleFactor));
    to:

    Code (CSharp):
    1. w = Mathf.Max(1, Mathf.RoundToInt(bounds.size.x / scaleFactor * pixelsPerUnit / 100));
    2. h = Mathf.Max(1, Mathf.RoundToInt(bounds.size.y / scaleFactor * pixelsPerUnit / 100));
    Then you can use the "Pixels Per Unit" setting in Shapes2D/Preferences, so for instance if you set it to 400 then your 64x64 Shape gets turned into a 256x256 PNG which should look nicer. You can also play around with the mipmap settings for the imported PNG, that might make a difference in how it ends up looking in-game.
     
  22. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    102
unityunity