Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Official SpriteShape Preview Package

Discussion in '2D Experimental Preview' started by rustum, Mar 19, 2018.

Thread Status:
Not open for further replies.
  1. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey there,

    so I'm fooling around with the package and before I go into detail I'd like to know a specific thing:
    How is idea of the update of SpriteShape or packages in general? Now, I'm on Unity 2018.3.0f2 and I installed SpriteShape 1.0.12.
    I saw on this topic multiple posts of Unity devs stating that some things have been fixed and already available in the Alpha for Unity 2019.1. Does this mean the packages are still kind of linked with the Unity version? So in the future for example SpriteShape 1.1.8 will only be available for 2019.1 and not for...let's say 2018.3.X or 2018.4.X ?


    Alright, but here's some of my feedback so far:

    1) Problem with setting up corners

    So I have a general problem with corners. I don't get why there are only two modes: Disabled and Automatic. Especially automatic feels random. I know the requirements are that there is a straight line and both points are set to Linear Point Mode. In order to test that I created a new profile with the Sprites/Textures from the Castle-Examples.
    Here's the created Profile, I only added one range like this and set the Outer Top Left and Outer Top Right Corners.



    And here is my created SpriteShape in the scene. Only four node points and the top two are set to automatic, but the corner sprites don't show up. Why?




    Everything _seems_ setup right. Cornersprites are set up in the profile, corner nodes in the Controller are in linear point mode and aren't too close. The whole corner setup feels random, especially when you only can select between disabled corners or let the ShapeController do his automatic magic. Why isn't there another option like "Forced" which will display the corner no matter the angle? For now I only can do random guessing what went wrong with my setup and do nothing else but try&error with the setup or in this case: asking in the forums.



    And another thing, for this "problem" I did use the shapeprofiles and not my own: is there a specific reason why open ended shapes don't display the corners although both nodes are set to linear point mode and both are set to automatic borders? Have a look at the following screenshot, you'll see a closed shape with displaying borders and an open ended shape with only two points, but the open ended one doesn't display the corners, although it should. Bug or by design, and if by design: why?




    2) Problems with changing Point Modes

    For some reason the point mode is changing and with that the nodes are changing when I do something like this:

    Step 1: Creating a new ShapeController and going into Edit Mode



    Step 2: Creating a new node inbetween the top left and top right node in Linear Point Mode



    Step 3: Selecting the left corner node and changing that node to Mirrored Point Mode



    Step 4: Then when I create a new node between the top left node and the top center node for some reason it's created in Non-Mirrored Point Mode - why is this happening?



    Step 5: Then when I select the top left node again the point mode changed to Non-Mirrored Point Mode although I changed it before manually to mirrored point mode as described in Step 3 - why is this happening?



    I don't know if these are bugs or by design and if it is indeed by design I don't like this UX at all. Here's what I expected or would expect:

    - Creating a new node in a specific point mode or changing an existing one into another specific point mode is persistent and whenever I get back to that node that specific point mode gets selected
    - Is a specific node selected and a new node is created, it doesn't matter where on the shape, it get's created in the selected point mode and doesn't change right before creation of the new node


    4) Comparison to Ferr2D and general UX

    For our last project we used Ferr2D from it's 1.0 version almost to 2.0, lately I'm also fooling around with the latest Ferr2D release and I'm going to list some of the things I would like to be added or changed in SpriteShape.

    - almost the whole process of editing a Ferr2D Terrain in comparison to a SpriteShape in the scene has a better UX in Ferr2D:
    • the node points are big in Ferr2D while in the SpriteShape they are too small and it kinda needs more precision to select one. If you don't want to set the size yourself, maybe allow to set the size of the points in the preferences?
    • deleting a node point in Ferr2D needs only holding ALT and clicking on the node which one wants to destroy, in the SpriteShape I have to select a node point and hit CMD/CTRL+DELETE fearing I might delete the whole Shape...
    • adding a node outside of the spline is very simple in Ferr2D and doesn't seem to be possible at all in the SpriteShape, in Ferr2D I just have to hold SHIFT, have a look at this screenshot:



    - selecting multiple nodes and moving them is almost good, but instead of holding SHIFT when dragging multiple nodes around there shouldn't be the need to hold SHIFT imo, just selecting multiple nodes and then selecting one of those selected should give the ability to move all of them around

    - when adding a Collider2D one has to select the "Update Collider"-Checkbox in order to set the collider accordingly to the same shape as the SpriteShape itself. Is there any reason this can't happen the moment one adds the Collider2D component? I mean, if I add a PolygonCollider2D to a sprite it immediately takes shape of the sprite, why isn't this the case with the SpriteShape?

    - change the color from selected nodes - that yellow is barely visible, change it to something more distinctive like blue
    (or at least give the option to change them ourselves)

    - please give the option to actually show the indices of all the nodes themselves in the scene view, the indices could then be displayed around the nodes and why not also showing the index of the selected node in the inspector as read-only. This would be useful to work with the Scripting API so one could immediately see if the code is doing what it should do with the desired index/node. This is also possible in Ferr2D.



    That being said, what I really like is the ShapeProfile-Setup. Ferr2Ds terrain setup editor is sooo~ annoying, at least for me. It's cumbersome and it had been often the case that values haven't been saved and I had to do the whole setup again...
    The angle range view is a delight and feels intuitive, great job on that and of course the tool overall, if those listed things could be adressed it would be great tool and a also a great workflow since Ferr2D support is nonexistent for months :)
     
    Betzalel likes this.
  2. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    604
    Hi @Venkify , just wondering how the progress is going with my weird bug? :) (Where rigid body2d objects fall through the edge collider 2d)
     
  3. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    @BTStone Many thanks for the detailed feedback.
    Corner sprites connect the edge sprites when they are present. As you only have defined angle range that covers the top, there are no edge sprites on the sides or bottom based on your spriteshape profile inspector screenshot. Hence there are no corner sprites in the posted sample. Hence the issue. Also please note that the pixel height of the corresponding edge sprite and the corner sprite should be given.

    By design, only closed shapes have corners. We can consider adding corners for open shapes too.Will update this thread regarding this.

    We are revisiting this part for the upcoming version. Thanks for the feedback.
     
    BTStone likes this.
  4. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    292
    I'm creating a spriteshape from code by starting with 2 points and inserting / positioning new points on to the spline.
    I call BakeCollider() to ensure the collider is correct but the Sprite Renderer bounds are incorrect.
    Is there there a method available to update the bounds after I've updated the spline?
    And is there anything else I should be calling once i've updated the spline?
     
  5. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    292
    The world UV calculation seems to be off when using a fill texture when your sprite shape is not scale 1,1,1.
     
  6. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    Colliders are updated in Editor mode (if UpdateCollider is enabled) automatically as you Edit.
    In Playmode, BakeCollider should be explicitly called after making changes to the Spline.
    For example :
    var spriteShapeController = gameObject.GetComponent<SpriteShapeController>();
    // .. make changes to spline.
    spriteShapeController.BakeCollider();

    Could you please post a screenshot ?
     
  7. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    292
    Thanks, yes I managed to work out the baking of the collider but I only have a fudge for the issue of not being able to update the SpriteRenderer bounds.

    This bounds issue can be easily recreated by creating a spriteshape with two points which are vertical to one another.
    Then add points to the spline which give it a decent width. Then run in the editor and move the camera. Because the bounds are not recalculated on the renderer when you procedurally amend the spline in code the sprite disappears from the camera when it should still be visible.

    The world UV calculation issue for fill textures is most easily recreated by creating a spriteshape object in the editor then changing the scale and moving it around the screen in scene view. The fill texture should appear as as static but the sprite shape move freely, however the texture appears to move slightly to the right everytime you move the sprite shape to the left and vice versa.

    I can provide an example project if required?
     
  8. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    Is it possible to render holes in the sprite shape?
     
  9. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    There's probably a better way but you can use stencilmask to do what you want. I wanted to be able to put windows anywhere on a spriteshape texture and it's possible if you have the spriteshape shader write to a certain stencil buffer and then have a mask texture read from that buffer and ignore those pixels, and then you can put some sprite over that hole to cover up the cutout.
     
    nosajtevol likes this.
  10. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    That's a great idea! I'm thinking using a stencil shader on a sprite shape so I can make custom holes in a sprite shape in the background. Then I can use that conforming sprite shape script (in the demos for the package on GitHub) to make the outline for the hole and make it look organic. I think that would be a good workaround! Thanks for the idea!

    Update: Just want to let you guys know this worked out very well. I used the conforming script for the outline of the mask and now I am able to use the sprite shapes for interiors! Wahoo!
     

    Attached Files:

    Last edited: Jan 11, 2019
  11. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    Is there a simple way to cut holes on the sides of the sprite shape at runtime? I.E some procedural destruction that automatically resets the sprite shape?

    Edit: Finding simple raycasting to find the position of the edge is working well. However I'm wondering if there is a simple way to see if a point is along the path of the spline, i.e to find which index I need to insert the point at at runtime.

    An even better option would be something like Ferr2d's auto add point, that automatically adds a node to the sprite shape with only position as the parameter.

    @Sergi_Valls I saw that you mentioned previously in the thread about iterating through all Bezier points to find the closest one. Could you possibly elaborate on that?

    Update: I've figured it out!



    This script will add a point to your sprite shape based on object position. You can easily modify it with any position at all, as well as include an offset so you actually move the point, up or down, which is useful for digging and such. I also added the ability to add icons for the nodes at runtime as well as their handles. This makes a point every time you reactivate the game object with the script based on the closest area on the sprite shape.

    To make holes I plan to make new points and push them downward, or in whichever direction I want to make holes. I might share that script here as well if people are interested.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.U2D;
    5.  
    6. public class MakePointBasedOnPos : MonoBehaviour
    7. {
    8.     public SpriteShapeController spriteShape;
    9.     public Vector3[] nodes;
    10.     public Sprite nodeIcon;
    11.     public float progress;
    12.     public Vector3[] closestPointsForAllCurves;
    13.     public List<GameObject> icons = new List<GameObject>();
    14.     int closestNode = 0;
    15.     [Tooltip("Useful for moving the point")]
    16.     public Vector3 offsetPoint;
    17.  
    18.     private void Start()
    19.     {
    20.         MakeIcons();
    21.     }
    22.  
    23.     private void OnEnable()
    24.     {
    25.         MakeIcons();
    26.  
    27.         MakePoint();
    28.     }
    29.  
    30.     // Start is called before the first frame update
    31.     public void MakePoint()
    32.     {
    33.         //Get node positions
    34.         GetNodePositions();
    35.  
    36.         //Find closest points for all curves
    37.         closestPointsForAllCurves = new Vector3[spriteShape.spline.GetPointCount()];
    38.  
    39.         for (int i = 0; i < nodes.Length; i++)
    40.         {
    41.             closestPointsForAllCurves[i] = FindClosestPoint(i, transform.position);
    42.         }
    43.  
    44.         //Find closest node out of all of those points
    45.         float distance = 10000;
    46.         int closestNode = 0;
    47.  
    48.         for(int i=0; i< nodes.Length; i++)
    49.         {
    50.             float newDistance = Vector3.Distance(transform.position, closestPointsForAllCurves[i]);
    51.             if (newDistance < distance)
    52.             {
    53.                 closestNode = i;
    54.                 distance = newDistance;
    55.             }
    56.         }
    57.  
    58.         Debug.Log(closestNode);
    59.  
    60.         Vector3 closestPoint = closestPointsForAllCurves[closestNode];
    61.         transform.position = closestPoint;
    62.  
    63.         //Now insert a new point there
    64.         closestPoint = closestPoint + offsetPoint; // add offset
    65.         spriteShape.spline.InsertPointAt(Mod(closestNode + 1, spriteShape.spline.GetPointCount()), closestPoint);
    66.  
    67.         //Smooth out new point
    68.         spriteShape.spline.SetTangentMode(Mod(closestNode + 1, spriteShape.spline.GetPointCount()), ShapeTangentMode.Continuous);
    69.  
    70.         //Set icons
    71.         MakeIcons();
    72.     }
    73.  
    74.     public Vector3 FindClosestPoint(int startNodeIndex,Vector3 position)
    75.     {
    76.         Vector3 startPoint = spriteShape.spline.GetPosition(startNodeIndex);
    77.         Vector3 endPoint = spriteShape.spline.GetPosition(Mod(startNodeIndex + 1, spriteShape.spline.GetPointCount()));
    78.         Vector3 startTangent = spriteShape.spline.GetRightTangent(startNodeIndex);
    79.         Vector3 endTangent = spriteShape.spline.GetLeftTangent(Mod(startNodeIndex + 1, spriteShape.spline.GetPointCount()));
    80.  
    81.         return BezierUtility.ClosestPointOnCurveFast(position,startPoint, endPoint, startPoint + startTangent, endPoint + endTangent, out progress);
    82.     }
    83.  
    84.     private static int Mod(int x, int m)
    85.     {
    86.         int r = x % m;
    87.         return r < 0 ? r + m : r;
    88.     }
    89.  
    90.     public void GetNodePositions()
    91.     {
    92.         //Get list of all nodes
    93.         nodes = new Vector3[spriteShape.spline.GetPointCount()];
    94.  
    95.         for (int i = 0; i < nodes.Length; i++)
    96.         {
    97.             nodes[i] = spriteShape.spline.GetPosition(i);
    98.             GameObject icon = new GameObject();
    99.         }
    100.     }
    101.  
    102.     public void MakeIcons()
    103.     {
    104.         GetNodePositions();
    105.  
    106.         //Delete previous icons
    107.         foreach (GameObject icon in icons)
    108.         {
    109.             Destroy(icon);
    110.         }
    111.         icons.Clear();
    112.  
    113.         //Get list of all nodes
    114.         nodes = new Vector3[spriteShape.spline.GetPointCount()];
    115.  
    116.         for (int i = 0; i < nodes.Length; i++)
    117.         {
    118.             nodes[i] = spriteShape.spline.GetPosition(i);
    119.             GameObject icon = new GameObject();
    120.             icons.Add(icon);
    121.             icon.transform.position = nodes[i];
    122.             icon.name = i.ToString();
    123.             icon.AddComponent<SpriteRenderer>();
    124.             icon.GetComponent<SpriteRenderer>().sprite = nodeIcon;
    125.             icon.GetComponent<SpriteRenderer>().color = Color.red;
    126.             icon.transform.localScale = new Vector3(100, 100, 100);
    127.         }
    128.  
    129.         //Set tangent representations
    130.         for (int i = 0; i < nodes.Length; i++)
    131.         {
    132.             GameObject rightTangentIcon = new GameObject();
    133.             icons.Add(rightTangentIcon);
    134.             rightTangentIcon.transform.position = spriteShape.spline.GetRightTangent(i) + spriteShape.spline.GetPosition(i);
    135.             rightTangentIcon.name = i.ToString() + " Right Tangent";
    136.             rightTangentIcon.AddComponent<SpriteRenderer>();
    137.             rightTangentIcon.GetComponent<SpriteRenderer>().sprite = nodeIcon;
    138.             rightTangentIcon.GetComponent<SpriteRenderer>().color = Color.yellow;
    139.             rightTangentIcon.transform.localScale = new Vector3(100, 100, 100);
    140.  
    141.             GameObject lefTTangentIcon = new GameObject();
    142.             icons.Add(lefTTangentIcon);
    143.             lefTTangentIcon.transform.position = spriteShape.spline.GetLeftTangent(i) + spriteShape.spline.GetPosition(i);
    144.             lefTTangentIcon.name = i.ToString() + " Left Tangent";
    145.             lefTTangentIcon.AddComponent<SpriteRenderer>();
    146.             lefTTangentIcon.GetComponent<SpriteRenderer>().sprite = nodeIcon;
    147.             lefTTangentIcon.GetComponent<SpriteRenderer>().color = Color.yellow;
    148.             lefTTangentIcon.transform.localScale = new Vector3(100, 100, 100);
    149.         }
    150.     }
    151.  
    152. }
    153.  
     
    Last edited: Jan 13, 2019
  12. rootools

    rootools

    Joined:
    Nov 25, 2013
    Posts:
    20
    Good work! I have 2 issues:

    1) Editor on mac crashed when i add a material with normal map(Mobile/Bumped Diffuse for example). Bug report case - 1117034

    2) What about add opportunity set separate material to Fill sprite? This is need for correct normals work.

    3) Thank you =)
     
    Lars-Steenhoff likes this.
  13. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    If anyone's curious, I've begun working on a digging script using my above script as a base. Here's the very rudimentary version:




    Edit: Version .2

     
    Last edited: Jan 16, 2019
    shieldgenerator7 likes this.
  14. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    Nice idea. Needs work but I can see where you're going with it.

    Do we have any indication as to when this will move out of preview and into something that can be included in a build? I'm debating using this or Ferr2D for my project.
     
  15. Sergi_Valls

    Sergi_Valls

    Unity Technologies

    Joined:
    Dec 2, 2016
    Posts:
    212
    Hi, thanks for sharing your progress. Yes, this is the way I was referring to on how to find the closest point in a spline.
    If you keep track of the closest curve index and the closest "progress" returned by BezierUtility.ClosestPointOnCurve instead of the point itself you can later use BezierUtility.SplitBezier(). That method will return you two curves, left and right.
    "leftEndPosition" will be equal to "rightStartPosition", which is your new point. Use the other control points to update the neighboring tangents using SetTangentMode/SetLeftTangent/SetRightTangent. If done correctly, you should end up with a new point without a visual change in the shape.
     
    nosajtevol likes this.
  16. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    Thank you so much, Sergi! I'll try that to see if I can get the intended effect. Also, thanks so much for Anima2D, I'm still an avid user to this day and it's been my most reliable and consistent asset that I've been using for like 3 years now. So thanks so much for all the work you've been doing!
     
    Sergi_Valls likes this.
  17. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    So I could really use some kind of inverting system for the spline to make interiors; I think that would make this Sprite Shape package pretty much completed.
     
    AndrewKaninchen likes this.
  18. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Any ETA for a new update and what will be included in the new version?
     
    LDSdev and nosajtevol like this.
  19. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39
    I found two usability issues with Sprite Shape today:

    1. Exiting "Edit Spline" mode is difficult. When editing colliders, all you have to do is select off the collider. But with Sprite Shape, you have to select another object in the Hierarchy Pane in order to exit Edit Spline mode. You can't even deselect the mode button in the editor because it changed in the new Unity version (Im using Unity 2019.1.0a14). Optimally, I should be able to click anywhere in the Scene pane to exit Edit Spline mode. Or at the very least, be able to select a different Sprite Shape object to edit while staying in Edit Spline mode.

    2. Auto-Zoom Out hinders progress. Often when I'm editing my Sprite Shape, I'm already zoomed in and ready to edit the area that I want to change. But when I click the "Edit Spline" button in the editor, it zooms all the way out to allow me to see the whole Sprite Shape object. I get why it does this, and it's handy if it's wholly off screen, but it's not handy when at least part of it is on screen and that's the part I want to edit. Optimally, it would only auto-zoom / auto-move the camera when none of it is on screen.

    3. Usability Issues 1 and 2 make editing Sprite Shape objects that are very large and right next to each other very difficult. Resolving these issues will greatly improve the Sprite Shape work flow.
     
  20. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39
    If you want to easily change the terrain color during runtime, Sprite Shape is way easier:

    Sprite Shape:
    Code (CSharp):
    1. SpriteShapeRenderer spriteShapeRenderer = GetComponent<SpriteShapeRenderer>();
    2. spriteShapeRenderer.color = new Color(0,225,0);
    Ferr2D:
    you have to get the material and change the color on the material, and then call a method to update the mesh on the terrain (I don't have code for this).
    Ok maybe that's an exaggeration. Here's a direct quote from the developer:
    Another factor I consider important is dev response time, and I have to say, both are pretty great. You can see this forum for how response Sprite Shape devs are, and I can attest to the responsiveness of Ferr2D devs. The Ferr2D devs reply within 2 days max, sometimes as soon as within the hour. They're pretty great, and even helped me fix a bug I thought was theirs but was actually mine.
     
  21. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    604
    Hi @Venkify @Sergi_Valls
    I was wondering if you guys had any updates on the fog bugz I reported? :(
    > 1104919

    Thanks for the help!
     
  22. Devilwhale

    Devilwhale

    Joined:
    Jul 29, 2015
    Posts:
    4
    Hi, been messing around with this and it is great for the most part. I was going to extend it for my own use in both graphics and UI, however I ran into a problem.

    I was going to start by adding uv scale instead of pixelperunit (fillscale) but this line stopped me from adding any.

    Code (CSharp):
    1.  SpriteShapeUtility.GenerateSpriteShape(spriteShapeRenderer, m_CurrentShapeParameters,
    2.                     shapePoints.ToArray(), shapeMetaData.ToArray(), m_AngleRangeInfoArray, m_EdgeSpriteArray,
    3.                     m_CornerSpriteArray);
    I wanted to add per point scale and rotation, and fill texture x,y scale, rotation, and x,y offset.
    I also was going to look into adding a border texture / width option that could be just inset of the tiled texture. It would work like offset / of fill texture from the edge instead of center. Also I would like to extend the offset to go past 0.5 to allow for large faded fill effects (glow, effects, other gradients that need to leak past the border)

    Any way to add these with out messing with your dll? I could not find where texture / material uses fill scale to set the texture. It can't be edited with our re baking it can it? I mean I can't bake it then edit the materials of one or more of the sprites inside, just the points and a rebake?

    If there was a way to make just the tessellation process more generic, could expose the more standard options of the managed content?

    For holes the sprite mask works great.

    Thanks!
     
  23. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    Hmm I'm having an issue. Basically if I instantiate a sprite shape, and it's too big, it generates but it's invisible until I zoom the camera out either in the scene or in the game view. Thought it may be some kind of occlusion culling but it really seems like it's simply not generating the visual mesh unless it's within some kind of distance. Pretty weird.

    EDIT: It seems the Camera frustum culling could be the issue with sprite shapes. Not sure how the bounds register with sprite shapes but it seems like if the bounds are off screen it doesn't render.
     
    Last edited: Jan 24, 2019
    BTStone likes this.
  24. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    Sorry for the delay. Based on inputs from @MelvMay who took a look on the project "The bodies are falling through the floor because they are moving fast and simply step over the line-collider used as the 'floor' because they're using discrete collision detection i.e. they detect where they step to only, not the intervening space. To stop that you can use the more expensive continuous collision detection on the 2D rigidbodies. Also project has mix of 2D and 3D physics with 3D rigidbodies as children of 2D ones. That will give undefined results. In this case, the 2D rigidbody is the parent so it is in control of the transform hierarchy."

    An updated version with bug-fixes and refinements (also includes fixes for bugs posted in forums and github) will be published before release of Unity version 2019.1. Will post an update on release.

    @shieldgenerator7 Thanks for the feedback. Both the issues above are in the our existing buglist to fix and will be fixed in the upcoming release.

    Thanks for reporting. This has already been fixed and will be available in the next update.
     
    shieldgenerator7 and nosajtevol like this.
  25. MercurialKid

    MercurialKid

    Joined:
    Aug 30, 2018
    Posts:
    22
    There is a current issue with Spriteshape, and Tilemaps and Unity in general that any overlap of sprites causes double brightness at the point of overlap. This is an elephant of a problem. And I can see posts running from 2013 with people trying to fix across the Unity world. In terms of Spriteshape specifically, when joining any gaps, with the end cap method, the overlap means no diffuse shader lighting can be used.

    I'd say this was a fairly major bug.

    upload_2019-1-25_9-38-18.png

    I notice that a workaround has been to try to put overlapping sprites on different z layers, but for Spriteshape and Tilemaps, i can't see how this can be accomplished.
     
    Lars-Steenhoff likes this.
  26. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    Amazing to hear! I'm very excited where this is going as I've been finding a lot of really cool ways to use Sprite Shapes. And it seems just so performant which is a huge deal! Keep up the great work!
     
    Lars-Steenhoff likes this.
  27. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    604
    Hi @Venkify @MelvMay
    Thanks for the reply. So it seems the only solution is to use the more expensive continuous collision, right?

    This is going to sound dumb, but is there a way to "thicken" the line collider? So objects won't step over the line collider so quickly? (Hope that makes sense) :oops:

    Thanks for the help!
     
  28. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    @MercurialKid I believe its the same issue as the post below. Please try the suggested solution and let us know.
    https://forum.unity.com/threads/spr...become-transparent-issue.582217/#post-4095799

    Thanks for the feedback. For sprites, tessellation does take into account Pivot of the sprite, however Collider may not. We are simplifying Collider generation in the upcoming version that will take sprite's Pivot into account. Will post an update once it gets released.

    @Devilwhale Thanks for the feedback. For fill texture, the PixelPerUnit property can be set in SpriteShape Profile's Inspector. It does require rebake.
    We will take a look into this. Thanks.
     
    Devilwhale likes this.
  29. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39
    I'm trying to make a single non-tilable object bend with sprite shape, but the image still repeats.

    I want to do something like the tree branch from this video:

    upload_2019-2-3_18-8-38.png

    My sprite is similar. It's a PNG and it has one end that is really thick, and one end that is really thin. Repeating them like you would the bridge sprite wouldn't make any sense.

    This is what I'm getting:
    upload_2019-2-3_18-10-49.png
    The sprite on the left is what the sprite looks like normally (yes i know its not 100% straight already).
    The thing on the right is what I get when I try to use sprite shape to bend it. It repeats the sprite, but I don't want it to. What settings on the SpriteShape profile or the SpriteShape object do I use to make my image work like the tree branch in the video?
     
  30. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    It's the "Adaptive UV" setting in the sprite shape that you are looking for.
     
  31. abatcat

    abatcat

    Joined:
    Feb 8, 2015
    Posts:
    70
    Does/will this system support 3d colliders as well?
     
  32. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    Is there any indication as to when this package will be moving out of preview and can start being used in production? I have a project that I'm working on and need to decide whether to incorporate this or use some alternative.
     
  33. MrKilljoy

    MrKilljoy

    Joined:
    Aug 19, 2015
    Posts:
    9
    Just tried to make some trees with it too. Sprites follow the spline pretty well (although it's quite annoying to have to import trunk textures horizontally instead of vertically) but I there are 2 flaws that popped up pretty quickly:
    1- the height slider is capped to 2, which makes width variation pretty limited without using extremely low values and compensating with frowned-upon transform scaling
    2- Polygon and Edge colliders don't follow the height value, so any width change is only cosmetic because colliders don't match
    Is there any plan to change this?
    An option to rotate UVs by 90° would be a nice addition too
     
  34. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    @shieldgenerator7
    You can also adjust the Height on each point to achieve the same (as seen in attached gif).

    @alanmthomas We are aiming for a major release before 2019.1 (with all the bugfixes and updates). However we will ensure 2018.3 gets bugfixes and updates if necessary.

    @MrKilljoy 1) We are increasing it to 4 in the upcoming version.. 2) This is fixed in the upcoming version for 2019.1

    Could you please provide the use-case and is it for the fill area?

    @abatcat
    3D Colliders are not supported. Could you please provide us the use-case you are looking for ?
     

    Attached Files:

  35. abatcat

    abatcat

    Joined:
    Feb 8, 2015
    Posts:
    70
    I'm using 2d Flexible Platformer Controller as a character controller and it doesn't support 2d colliders.

    Ferr2d seems to have the ability to work with both 2d and 3d colliders, but I'm hesitant to use it because I'm
    unsure of its continued development.

    This is the character controller I'm referring to https://www.assetstore.unity3d.com/en/?stay#!/content/67414
     
  36. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,513
    yes option to switch between 2d and 3d would be good for a 2.5D platform game
     
  37. MrKilljoy

    MrKilljoy

    Joined:
    Aug 19, 2015
    Posts:
    9
    @MrKilljoy 1) We are increasing it to 4 in the upcoming version.. 2) This is fixed in the upcoming version for 2019.1

    Oh cool then. Thanks for the info :)
     
  38. MrKilljoy

    MrKilljoy

    Joined:
    Aug 19, 2015
    Posts:
    9
    "Could you please provide the use-case and is it for the fill area?"

    Just noticed I missed your other question. My use case is that my line is supposed to go mostly vertically along a non-closed spline, for example a tree that I want to curve a little here and there, and it's more intuitive for graphic artists to draw their tileable textures how they visualize it.
    At the moment the SpriteShape tools assume -just like the LineRenderer- that it will be mostly used horizontally, so it just repeats horizontal tiling on a vertical line.
    So no, it's not for the fill area, as in my case, it's not even used.
     
  39. SpaceGaucho

    SpaceGaucho

    Joined:
    Apr 23, 2015
    Posts:
    2
    Hey is there any way we could animate a sprite shape? Like for example I want to do a "conveyor belt" object in my game and it would be super useful to use sprite shapes for it.

    Like maybe we could switch the current sprite in the sprite array over time?
     
  40. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    The easier way to do that would be to animate the UVs of the material. With a little math, you'd be able to have object on the conveyor belt move at the same speed as the UV animation.
     
  41. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
  42. sildude

    sildude

    Joined:
    Feb 8, 2013
    Posts:
    3
    Is there an easy way to create tangents for points at runtime, just like when you change the point mode in Editor to "Tangents mirror each others angle" and it automatically creates two nice tangents?

    I'm generating a random terrain procedurally and I'd like for it to be smooth, without messing with the tangents manually and doing a lot of math. If I change the spline to Continuous in code:
    Code (CSharp):
    1. spline.SetTangentMode(i, ShapeTangentMode.Continuous)
    it doesnt automatically create the tangents like in editor. Maybe there's some way to do it in c#?
     
  43. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    @sildude
    Please take a look at :
    SplineUtility.CalculateTangents
    function. For a sample use, check the function
    void ResetTangents(int pointIndex)
    in com.unity.2d.spriteshape\Editor\SplineEditor.cs
     
  44. sildude

    sildude

    Joined:
    Feb 8, 2013
    Posts:
    3
    Thanks, just what I was looking for. Tried it out and it works perfectly!
     
  45. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39
    Thanks! It works nicely!

    upload_2019-2-13_15-36-54.png
     
  46. okasile

    okasile

    Joined:
    Jan 24, 2018
    Posts:
    2
    The corners are out of controls.It will be better if I can control the corners like Ferr2D terrain tool.
     
  47. aFeesh

    aFeesh

    Joined:
    Feb 12, 2015
    Posts:
    35
    I've come to the conclusion that Sprite Shape just doesn't work if your goal is high quality. The corners/edges don't line up well, especially when using curves. Seems Sprite Shape works best with simple assets, where overlapping and edge tearing isn't a big deal.

    I attached an example where the edge and fill just don't align. There are many other examples, this is just one of the basic ones. I've also attached an example with your own demo, where the corners are inconsistent, and look terribly misaligned.

    This had so much potential, but it seems the devs have given up on it, and there are so many editor bugs with it, ah well.
     

    Attached Files:

    Last edited: Feb 18, 2019
  48. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    633
    @Time_Flys @g344468169 Yes, we have existing cases that have mentioned the issues with corner and we have improved it in the upcoming version (https://github.com/Unity-Technologies/2d-spriteshape-samples/issues/5)
    Regarding the Corners2.PNG posted above, the point mode seems to have been set to Broken mode . To have continuity please use Continuous Tangent mode.
    We are actively working on fixing most existing issues and have a stable version asap.
     
  49. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    Hi developers of Sprite Shape. First I must say you are doing a great job and really making a tool that is lacking for 2d games. I know of ferr2d or similar but it is not well supported. I really want to use sprite shape tool for my game, but I wonder when a new update is scheduled and will this version possibly break my current shapes by the next update? To phrase my question differently? What are the simplest functions one can expect to use from the current preview version that will not break on the next version?
     
    Last edited: Feb 18, 2019
  50. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Not sure if there's an obvious answer to this, but if I had a no fill spriteshape, and it had say 5 segments and looked very similar to the tree-like structure posted a few posts above this. Is it possible to make a shader that sends a single pulse of light going from the tip to the base? I can only seem to manage to figure out how to make it so the shader makes a pulse of light going from the ends of each individual edge segment at the same time rather than treat the entire combined spriteshape as a single texture mesh.

    So here's an example:
    .

    Since each edge segment is shaded separately, the pulse happens on each segment. Is there a way to make it so I can somehow treat each segment of the SpriteShape as a single long texture? Or is that not possible.
     
    Last edited: Feb 20, 2019
Thread Status:
Not open for further replies.