Search Unity

ProtoShape 2D - Editor extension to easy create and edit 2D meshes

Discussion in 'Assets and Asset Store' started by Andrii, Apr 20, 2017.

  1. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    I'm sorry but it's not. The only thing you can do is a scripted animation: set the properties every frame from a script.
     
  2. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Sorry for the late reply but no, it's not.
     
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,090
    I like the asset so far! However, one inconvenience: Why can't I add a point and move it in one click action? Currently, I have to click the mouse button down and up to create a point and then click and drag again to move the point. With Unity's PolygonCollider I can press the mouse down to add a point and immediately drag to move it. This seems more intuitive and a tiny bit faster to me. Is there any reason for the current behaviour or could we make this an option to pick via preferences in the future?
     
  4. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    I haven't found a way yet to implement this using tools that Unity offers. I too like how PolygonCollider works and I'd love to make ProtoShape2D work in the same way.
     
  5. korifandrijs

    korifandrijs

    Joined:
    Feb 22, 2017
    Posts:
    1
    Hi! Can you move individual points from code with this? Like If I want to move corner 3 to a different position.
     
  6. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Yes. Every ProtoShape2D object has an exposed list of point objects which have position properties. You can change position of any point by setting it to Vector2. After you set new positions you should call UpdateMesh() so it would generate the shape based on new points. And it's ok to do this each frame if you need.
     
    korifandrijs likes this.
  7. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    Hey @Andrii

    I asked this a while back and thought I'd ask again since I could really use it.

    For the Anti Aliasing, would you mind exposing the aliasing width so we can adjust the thickness of the aliasing triangle strip? The default looks a bit fuzzier than I'd like and I would love to be able to tweak it a bit.
     
  8. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    Is it possible to update the color of the Protoshape in real-time via code?

    I tried setting fillColor but it doesn't seem to update real-time.

    -Jeff
     
  9. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Sure! I'll do it in next few days. Sorry, I was busy lately with some other work but now I'm confident I'll get this done soon and I'll update the asset.

    After changeing ProtoShape2D settings using the code you'll need to call a function that will apply them to mesh or to the material. If you're editing point position, you'll need to call UpdateMesh() to rebuild the shape, if you're changing the colors or texture settings you'll need to call UpdateMaterialSettings(). I'm sorry it's not explained anywhere. I'll add some code snippets to the manual.
     
  10. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    Cool. Thanks.

    I'll try out UpdateMaterialSettings... thanks. Do you know if there are any perf. issue with calling that every update? I'll just be using solid color ProtoShapes but will be updating color constantly.
     
  11. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    This won't cause any issues. I don't see how it could.
    Also, I've just added a feature that exposes antialiasing width and submitted an update for review. This means that it would probably go live early next week.
     
    jeffweber likes this.
  12. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    I tried doing this at runtime, but the color did not update.

    protoShape.color1 = color;
    protoShape.color2 = color;
    protoShape.UpdateMaterialSettings();

    Am I missing something?

    FYI, my Fill Type is color
     
  13. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Oh, I've just tried it and you also need to call UpdateMesh().
    When fill type is color it uses vertex color so the mesh needs to be updated.
    And it won't cause any issues either.
     
  14. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    But won't UpdateMesh be a bit expensive? I'm planning to have a LOT of ProtoShapes and update all the colors real-time.
     
  15. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    When there's a lot of them rebuilding meshes every frame it may cause some issues. Still depends how many.
    But there have to be few ways to optimize it. For instance, if you set fill type to gradient and set color1 and color2 you won't need to call UpdateMesh(). Only UpdateMaterialSettings(). Because that's the different shader that is not using vertex colors. And the other thing that comes to mind is this. If there will be THIS many objects, it's worth trying this approach with a custom material just for this case instead of the one that ProtoShape2D uses. Assuming that updating mesh or material settings will cause issues.
     
  16. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    I like the Property Block solution... that might work for me. I'll play with it. Thanks for the prompt responses!
     
  17. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    615
    @Andrii

    Hi, I just grabbed the latest version of ProtoShape. Thanks for making the aliasing factor public, but I was wondering if you could think about adding a bit more robustness to the aliasing.

    I had made some modifications a while back. Possibly you could incorporate them into the tool if they seem worth it to you.

    Aliasing and Scaling
    Currently, if you add the aliasing edge, then scale the protoshape the aliasing edge becomes blurry because it's scaling up 1-1 with the protoshape. To keep a sharp edge no matter the scale, I added some logic to take scale into affect. It also handles the case where you have a ProtoShape with children ProtoShapes.

    Here are some images of what I'm talking about:

    Not accounting for scaling:
    AliasingNotAccountingForScale.JPG

    Accounting for scaling.
    AliasingAccountingForScale.JPG

    Here is the code I used to do this:
    Code (CSharp):
    1.                    
    2. if (antialias){
    3.  
    4.     //If there is a parent protoshape, use it's scale to set aliasing
    5.     //of immediate children.
    6.     float scale = 1;
    7.     var parent = GetComponentInParent<ProtoShape2D>();
    8.     if (parent != null)
    9.     {
    10.         scale = parent.transform.lossyScale.x;
    11.     }
    12.     else
    13.     {
    14.         scale = transform.lossyScale.x;
    15.     }
    16.  
    17.     var z = Application.isEditor ? -35f : _camera.transform.position.z;
    18.     aaridge = aliasFactor * Mathf.Abs(z - this.transform.position.z) / scale; //Set alias thickness and adust for scale.
    19.  
    Note, I'm using a perspective camera and I'm also doing a small adjustment based on whether my object is move in the z-direction... no sure that is really needed. If not, just get rid of: * Mathf.Abs(z - this.transform.position.z)

    Also, I added the aliasing factor to the inspector... which is helpful.
    AliasInspector.JPG
    Code (CSharp):
    1.            
    2. float aliasFactor = EditorGUILayout.FloatField(new GUIContent("Aliasing Factor", "Set alias sharpness. Smaller values are more sharp"), script.aliasFactor);
    3.             if (aliasFactor != script.aliasFactor)
    4.             {
    5.                 Undo.RecordObject(script,"Change alias factor");
    6.                 script.aliasFactor = aliasFactor;
    7.                 EditorUtility.SetDirty(script);
    8.             }
    Hope some of this is useful and can be incorporated into the tool.

    -Jeff
     
  18. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Thanks Jeff!
     
  19. darryl-hill

    darryl-hill

    Joined:
    Jul 30, 2016
    Posts:
    1
    Developing a mobile app in Unity. Having a problem getting my shape to appear on top of other UI elements. Am I missing something? (not the actual shape or color but just to illustrate the situation. ) I feel like a setting is wrong or something Screen Shot 2019-06-04 at 11.44.59 AM.png
     
  20. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hi,
    right now ProtoShape2D does not support being rendered within Canvas. This asset was intended to prototype and draw within a game world but it really makes sense to use it in UI too. I'll reasearch this and add this feature in the next update but this will happen in few weeks since I'm working on other things right now.
     
  21. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    A couple things:

    To chime in on appreciation - this is a great tool. It has almost everything I need, plus a bit beyond. Most importantly, it does great job of making 2D polygon design into a straightforward task that anyone can conveniently do inside the editor.

    I am having one problem, and I'd like to ask for your advice on it. When I create a protoshape, and give it a custom material, it seems that most lights have no effect on the protoshape. Ambient lighting (as setup via the Lighting Settings menu) works just fine, but the various other lights (Directional, Point, Spotlight, etc.) have no effect on the protoshape. You can see an example of this in the screenshot below. I created a capsule, and gave it a custom material. I then created a protoshape, and gave it that same custom material. Lastly, I aimed a spotlight at these two objects. In the image, you can very clearly see the light from the spotlight on the surface of the capsule, but the spotlight has no effect on the protoshape - the effect of the light cuts off in a sharp line at the edge of the protoshape.
    Capture.PNG

    If I can't use lighting on protoshapes, I'll be a little sad. It would be nice to be able to use materials with various forms of bump-mapping, but bump-mapping doesn't really show in ambient light. In all honest, bump maps aren't necessary for my goals here. If I can't use bump-mapped textures, I'll still get a lot of use from ProtoShape 2D, but it would be nice if I could have it all, so I thought I'd ask. Am I missing something with custom materials and lighting?

    Either way, thanks for sharing your work, and for your thoughtful presence on these forums.

    - Tim
     
  22. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hey Tim,
    Thanks for choosing my asset and for your kind words!

    Thanks to you I've found that I never properly tested this asset with lighting since I'm mostly working with unlit shaders. And the code that creates the mesh is not setting the normals so that's why light doesn't work. This is easily fixed by adding this into ProtoShape2D.cs after line 410 (after setting vertices, colors and UVs):

    Code (CSharp):
    1. List<Vector3> normals=new List<Vector3>(vertices.Count);
    2. for(int i=0;i<vertices.Count;i++){
    3.      normals.Add(Vector3.back);
    4. }
    5. mf.sharedMesh.SetNormals(normals);
    This code will be included in the asset in the upcoming update.

    Another thing that can cause the issue is if you're using vertex lighting (when your spotlight render mode is set to "not important") it won't look good with ProtoShape2D since it uses the minimum possible number of vertices per polygon. Vertex lighting is faster than pixel lighting but right now ProtoShape2D will only work with pixel lighting (when your spotlight render mode is "important" or "auto" - auto makes the strongest light a per-pixel light). I'll try to find a way to build the mesh with more vertices to make the vertext lighting look better.

    Thanks for finding this issue,
    Andrii
     
  23. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    Andrii,

    Thanks much for the fast, informative, and super-helpful reply. I've added those lines to the code, and everything now works just as I'd hoped. The spotlight illuminates the capsule and the Protoshape in exactly the same way:

    Capture.PNG
     
    Andrii likes this.
  24. Rorep

    Rorep

    Joined:
    Nov 23, 2013
    Posts:
    9
    Found a bug when Anti-aliasing is enabled.

    Steps to reproduce bug:
    1. Create a new ProtoShape2D.
    2. Enable Anti-aliasing.
    3. Drag right-top point over the top-left point (while holding shift key)
    4. Drag right-bottom point over the top-left point (while holding shift key)
    5. Drag left-bottom point over the top-left point (while holding shift key)
    DragPoints.png

    6. All four points will be in the same position.
    7. Drag any point to the right.
    8. At some pont along the way Unity will throw errors.
    DragPointRight.png

    My workaround is to leave Anti-aliasing Disabled.

    This isn't a big problem when creating shapes inside the Unity editor. But my mobile game allows the players to create, modify and save shapes on their phone, and when I use anti-aliasing and align the points to a grid I get this error a lot in gameplay.

    I was trying to create a system that let the players create their own characters in game and I was about ready to give up, then I found this awesome asset that helped me to do that and so much more. Keep up the good work!
     
  25. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Thanks a lot for the detailed steps to reproduce the bug. I'll fix it in my next update soon.
     
    Rorep likes this.
  26. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hey again,
    I came up with a simple fix for this bug. I'm going to include it in the asset but it will be few more days till I update it so here's a quick way to fix it now. Open ProtoShape2D.cs, go to line 370 and replace this:
    Code (CSharp):
    1. if(antialias){
    with this:
    Code (CSharp):
    1. if(antialias && tris.Length>0){
    It will stop trying to generate antialiasing border if there's no other geometry generated.
    I hope this helps and thanks again for choosing my asset!
     
    Rorep likes this.
  27. Rorep

    Rorep

    Joined:
    Nov 23, 2013
    Posts:
    9
    Thanks for the quick response. That sanity check fixed the bug for the use case I mentioned previously, but I have a new use case where the bugs still exist.

    1. Create a new ProtoShape2D.
    2. Enable Anti-aliasing.
    3. Drag the top-right point, aligning it to the top-left point and the bottom-right point (while holding shift key)
    2019-09-30_10-38-17.png
    (at this point there are four points and two triangles so tris.Length = 6)
    4. Drag the bottom-right point between the top-left and top-right points.
    2019-09-30_10-39-45.png
    5. Unity will throw the same errors as before.
    (at this point there are four points and one triangle so tris.Length = 3)

    If I change your sanity check to:

    Code (CSharp):
    1. if(antialias && tris.Length > 3)
    It will fix the error, but I think as more points are added the minimum tris.Length needs to increase as well?
     
  28. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Yeah, number of triangles depends on number of points. This check will make sure that the antialiasing ridge will only be generated if number of triangles is exactly as it should be for the number of points:

    Code (CSharp):
    1. if(antialias && tris.Length==(vertices.Count-2)*3){
    I don't know if it's the best solution but do you need antialiasing to work for these fringe cases?
     
    Rorep likes this.
  29. Rorep

    Rorep

    Joined:
    Nov 23, 2013
    Posts:
    9
    Now I don't need antialiasing in these extreme cases. Your solution should work just fine for what I'm trying to do.

    Now that have a better understanding of exactly what's going on. I will restrict the players' ability to move points in a way that will generate an invalid number of triangle, thus eliminating this problem.

    Thanks for all your help.
     
  30. djrain

    djrain

    Joined:
    Dec 21, 2017
    Posts:
    3
    This asset looks really nice. But does it support outlines?
     
  31. MudbuG

    MudbuG

    Joined:
    May 17, 2015
    Posts:
    3
    Hey, great asset!

    However, I updated to the latest version today and there seems to be a missing class: P2DExtruder.

    ------ Build started: Project: Assembly-CSharp, Configuration: Debug Any CPU ------
    D:\Dev\Unity\Konquestia_Stable\Assets\ProtoShape2D\Scripts\ProtoShape2D.cs(472,21): error CS0246: The type or namespace name 'PS2DExtruder' could not be found (are you missing a using directive or an assembly reference?)
    D:\Dev\Unity\Konquestia_Stable\Assets\ProtoShape2D\Scripts\ProtoShape2D.cs(473,19): error CS0246: The type or namespace name 'PS2DExtruder' could not be found (are you missing a using directive or an assembly reference?)
    ------ Build started: Project: Assembly-CSharp-Editor, Configuration: Debug Any CPU ------
    D:\Dev\Unity\Konquestia_Stable\Assets\ProtoShape2D\Editor\ProtoShape2DEditor.cs(498,39): error CS0246: The type or namespace name 'PS2DExtruder' could not be found (are you missing a using directive or an assembly reference?)
    D:\Dev\Unity\Konquestia_Stable\Assets\ProtoShape2D\Editor\ProtoShape2DEditor.cs(500,38): error CS0246: The type or namespace name 'PS2DExtruder' could not be found (are you missing a using directive or an assembly reference?)
    D:\Dev\Unity\Konquestia_Stable\Assets\ProtoShape2D\Editor\ProtoShape2DEditor.cs(504,38): error CS0246: The type or namespace name 'PS2DExtruder' could not be found (are you missing a using directive or an assembly reference?)
    D:\Dev\Unity\Konquestia_Stable\Assets\ProtoShape2D\Editor\ProtoShape2DEditor.cs(505,55): error CS0246: The type or namespace name 'PS2DExtruder' could not be found (are you missing a using directive or an assembly reference?)
    ========== Build: 0 succeeded or up-to-date, 2 failed, 0 skipped ==========
     
  32. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Yeah, this is what's available:

    outline.gif

    Thanks for the heads up, I've just submitted a fix for this. This was a separate asset I was working on that would allow to 'extrude' ProtoShape2D objects into Z dimension basically creating a 'tube' the shape of the object behind it. It's unfinished and I don't know if I will finish it, probably not much demand for a specific thing likt this.

    Something like this:
    extrude.gif
     
  33. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    Impressed and grateful that you continue to support ProtoShape! It's a great tool. While Unity has released SpriteShape out of preview, ProtoShape does some things that SpriteShape does not, and I appreciate that functionality. Thanks Andrii!
     
    Andrii likes this.
  34. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Thanks a lot! I appreciate it. Feel free to contact me if you'll have any feedback.
    And consider leaving a review on the asset store - it helps a lot :)

    Thanks for using my asset!
     
  35. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    Possible bug report:

    I'd like to be able to procedurally adjust the Bezier handles during game-runtime. For example, to make certain shapes wiggle and move. And I think there may be a bug that prevents this from working. And I think I have a small idea where the problem lies.

    I've written a simple demo script that changes points[0].position, points[0].handleP, and points[0].handleN in FixedUpdate. I then created a vanilla ProtoShape using the GameObject menu option, set the curve type to Bezier in the inspector, and attached my demo script/component. When I click play, the position of that 0th point moves in a circle, as expected. However, the curve doesn't bend according to the handles. The lines between the points remain straight.

    Code (CSharp):
    1. public class ProtoShapeProcHandles : MonoBehaviour
    2. {
    3.     ProtoShape2D shape;
    4.  
    5.     void Start()
    6.     {
    7.         shape = GetComponent<ProtoShape2D>();
    8.     }
    9.  
    10.     void FixedUpdate()
    11.     {
    12.         shape.points[0].position = new Vector2(Mathf.Cos(Time.time), Mathf.Sin(Time.time));
    13.  
    14.         float degrees = 100 * Time.time;
    15.         Vector2 handleN = Vector2.up.Rotate(degrees);
    16.         Debug.Log("Degrees: " + degrees + "    handleN: " + handleN);
    17.         shape.points[0].pointType = PS2DPointType.Sharp;
    18.         shape.points[0].handleN = handleN;
    19.         shape.UpdateMesh();
    20.     }
    21. }
    As best I can tell, the problem is that when I set pointType in code, that change in pointType doesn't get to where it needs to be.

    If I use my mouse to set pointType to none in editor, and then change it to Sharp in code, the ProtoShape ignores that change, and continues to act as if all the points were 'none'. The lines between the points stay straight, and the shape ignores all the vector info in handleN and handleP.

    However! If I use my mouse to set pointType to Sharp in editor, then when I restart the game, ProtoShape will start to pay attention to handleN and handleP. The lines between the points will wiggle, as expected.

    I think. The point is that there is something funny here. Any help you could give would be appreciated.

    (For sure! I posted a positive review months ago. Continued appreciation for the quality work that you've done here.)
     
  36. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    ... P.S. Funny things also happen when I add points via script, as with shape.points.Add(new PS2DPoint(Vector3.one)). The handles come out all funny. In ProtoShape2DEditor.cs, I note that your AddPoint function does something with points.curve. Is there perhaps a way to automate this calculation? Or explain it to me so that I can get this working?
     
  37. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    I couldn't reproduce this. I've tried it when in bezier curve mode since youv'e mentioned handles. All the handles are intact for me and the new point doesn't have any curve settings. I'll need more details to reproduce this.
    You're probably already doing this but I'll remind you that it's important to call UpdateMesh() after changing anything about the points.

    What it does is, it sets the point.curve value of this new point to an average of of preceding and the following point and divides it by two just because it looks slightly better. But it's only visible if you're in the "simple" mode, not the bezier. You can easily set this value through code if needed.
     
  38. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    Curious. I've created a small demo project, and posted it to Google Drive here. There are two short scripts, and four protoshapes. I also added some notes to the scene with TextMeshPro. I think this illustrates several of the funny things going on:
    1. If a point starts out as type None, and I later change the type to Sharp via code, and then continuously change the handles via code and FixedUpdate - there is no change in the spline/shape, even after multiple calls to UpdateMesh(). It is as if UpdateMesh() doesn't notice runtime changes to pointtype.
    2. If a point starts out as a Sharp-type point, and I change the handles continuously via FixedUpdate, the spline *does* change, but not in the way I expected. The changes are muted, as if the values of handleP and handleN are somehow rounded or adjusted before the mesh is generated.
    3. If a Bezier shape has Sharp-type points, and I add additional points at runtime via code, all the handles to all the points go wonky, and the shape renders as a really interesting scribble. It's a cool effect, but not what I'd like to happen.
     
  39. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Thanks for doing this. I'll check this out and let you know. I'll try to fix this behavior and update the asset this week.
     
  40. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hey again. I've had a rough two weeks and I'm not sure when I'll be able to have some time with this but I'll let you know asap. I'm very interested in keeping updating it with bugfixes and features.
     
  41. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    As always, I appreciate that you care. I also get that life and world are tough, so please don't rush anything on my account. Protoshape is a cool tool. It makes my life as a designer much easier, and I'm overall very happy with it.

    Quick update:
    With sleep and further experimentation, I found an error in my demo project. I was setting handle positions relative to point position, rather than relative to the gameobject position. I've fixed that. This resolves #2 on my list of concerns. I'm still confused about #1 and #3:

    1. If a point starts out as type None, and I later change the type to Sharp via code, and then continuously change the handles via code and FixedUpdate - there is no change in the spline/shape, even after multiple calls to UpdateMesh(). It is as if UpdateMesh() doesn't notice runtime changes to pointtype.
    2. If a point starts out as a Sharp-type point, and I change the handles continuously via FixedUpdate, the spline *does* change, but not in the way I expected. The changes are muted, as if the values of handleP and handleN are somehow rounded or adjusted before the mesh is generated.
    3. If a Bezier shape has Sharp-type points, and I add additional points at runtime via code, all the handles to all the points go wonky, and the shape renders as a really interesting scribble. It's a cool effect, but not what I'd like to happen.
    Updated demo here - for someday that you have time.

    Thanks for making awesome stuff! Protoshape is the best!
     
    Andrii likes this.
  42. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hey,

    I've finally got time to check this.

    So on the first issue: that is a bug. I've fixed it and the updated version is under review, will be online in a few days. The code required point to have curve>0 to calculate it as a curve even in bezier mode where that value is meaningless. Not anymore.

    The third issue is something that probably can't be considered a bug. When you add/move points their bezier handles are staying in place. Their positions are not relative to the point so they don't move if you move the point. If you want to add or move the bezier point you need to set its handles too.

    I hope this makes sense and I hope it's still relevant for you. :)
     
  43. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    Re #1: Awesome! Thanks for squashing the bug.

    Re #3: Makes total sense. I did eventually figure out that handle positions aren't relative ... I just didn't think through all the consequences of that fact.

    Again, thank you.
     
    Andrii likes this.
  44. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    473
    This is amazing and would be invaluable for my current project! Please reconsider this. I'm having to rely on Probuilder or Umodeller to create 3D volumes based on my Protoshape objects.
     
    Andrii likes this.
  45. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hey, I thought about and I don't know if I can turn it into a separate asset as it is. If you still have a use for it, please email me at andrii.sudyn@gmail.com and I'll send it to you.
     
  46. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    40
    Hope to have the function of adjusting rounded corners,like this
    20200707165355.png
     
    Last edited: Jul 7, 2020
    Andrii likes this.
  47. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    Hey, thanks for using my asset! This feature is not intended for rounding the corners but to create curves.
    But technically you can create a rounded corner if you use 3 points per corner, rounding the middle one.
     
  48. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    40
    20200710205259.png
    var points = new List<PS2DPoint>();
    var radius=0.5f;
    points.Add(new PS2DPoint(new Vector2(-radius, 0)));
    points.Add(new PS2DPoint(new Vector2(0, radius)));
    points.Add(new PS2DPoint(new Vector2(radius, 0)));
    points.Add(new PS2DPoint(new Vector2(0, -radius)));

    var r = 0.5f;
    points[0].curve = r;
    points[1].curve = r;
    points[2].curve = r;
    points[3].curve = r;
    shape.points = points;

    Draw a circle through 4 points, how to calculate the curve value of each point, 0.5 is not correct.
     
  49. Andrii

    Andrii

    Joined:
    Sep 23, 2013
    Posts:
    119
    0.39 seems to do the trick
     
  50. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    40
    Thanks,I found a way.
    var a = radius * 0.551915024494f;

    points[0].pointType = PS2DPointType.Rounded;
    points[0].handleP = new Vector2(points[0].position.x, - a);
    points[0].handleN = new Vector2(points[0].position.x, a);
     
    Andrii likes this.
unityunity