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.
  2. Dismiss Notice

Sprites Shapes crash on Android Build. v.2019.3.13

Discussion in '2D' started by oriolmanya, May 17, 2020.

  1. oriolmanya

    oriolmanya

    Joined:
    Jul 4, 2012
    Posts:
    50
    I was using Asset Ferr2D to create 2D terrains, and I unfortunately decided to change to Unity Sprite Shapes.

    I compiled my game, and when I enter a level with Sprite Shapes, starts throwing log Errors on the Android Monitor until eventually crashes after a few seconds.

    On a side note: I'm a really big fan of Unity and I've been using it for more than 10 years, so it's sad for me to feel that the 2D features are kind of sloppy, maybe they are not putting enough resources to them, I don't know. An incomplete list of my journey:
    • The Sprites Shapes are nice, but they could be much nicer:
      • Improvements on position of the corners
      • randomness of tiles
      • Lack of options to configure the complexity of the shapes
    • Anima2D:
      • You can make it work, but i'ts almost an epic journey.
      • The way to calibrate the weights of the bones is not intituitive at all if it's not kind of broke.
      • Should be a way to assign premade poses to the frames
      • If you move accidentally a bone that has not a frame on the animation it leaves the bone displaced everywhere.
      • It doesn't allow AnimationLayers, so you cannot easily make, for instance, a character walk while aiming.
        • I was working for days with an IK system to move the Arm of the animation programatically, It was hell and had to do really weird stuff.
        • I made it work on 2019.3.7
        • It stop working on 2019.3.13 (looking at the updates it should be at 2019.3.9, thou), so I ended up faking an arm in top of the hierarchy and hidding the TRUE skeleton arm.
    • Tiles:
      • Rule Palette is useful, but it should be inside the project by default, and it just scratches the surface of it could be: For example mixing types of terrains
    • Not to mention bugs like this that doesn't add much confidence in the 2D features.
    Sorry to let it go all together like that, but I've been working with all these stuff for days, and now I have the urge to spit it out.

    Hope anyway it gets this fixed and all the 2D half features really gets improved.

    This is the repeated error:

    Code (CSharp):
    1.  
    2. 05-17 23:02:54.016: E/Unity(1017): (Filena
    3. 05-17 23:02:54.049: E/Unity(1017): NullReferenceException: Object reference not set to an instance of an object
    4. 05-17 23:02:54.049: E/Unity(1017):  at Unity.Collections.NativeSlice`1[T].get_Item (System.Int32 index) [0x00001] in <f975b633560f47c595b05b83534f499e>:0
    5. 05-17 23:02:54.049: E/Unity(1017):  at UnityEngine.U2D.SpriteShapeGenerator.TessellateContour () [0x0016b] in <b69a5c72d64046ab901e3a8074cc5435>:0
    6. 05-17 23:02:54.049: E/Unity(1017):  at UnityEngine.U2D.SpriteShapeGenerator.Prepare (UnityEngine.U2D.SpriteShapeController controller, UnityEngine.U2D.SpriteShapeParameters shapeParams, System.Int32 maxArrayCount, Unity.Collections.NativeArray`1[T] shapePoints, Unity.Collections.NativeArray`1[T] metaData, UnityEngine.U2D.AngleRangeInfo[] angleRanges, UnityEngine.Sprite[] segmentSprites, UnityEngine.Sprite[] cornerSprites) [0x0004b] in <b69a5c72d64046ab901e3a8074cc5435>:0
    7. 05-17 23:02:54.049: E/Unity(1017):  at UnityEngine.U2D.SpriteShapeController.BakeMesh (System.Boolean needUpdateSpriteArrays) [0x00329] in <b69a5c72d64046ab901e3a8074cc5435>:0
    8. 05-17 23:02:54.049: E/Unity(1017):  at UnityEngine.U2D.SpriteShapeController.OnWillRenderObject () [0x00028] in <b69a5c72d64046ab901e3a8074cc5435>:0
    9.  
     
    Last edited: May 17, 2020
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    618
    Thanks for the feedback and bug report.

    Please ensure that you set a valid SpriteShape profile for all the SpriteShapeController Objects in the scene. This should fix the issue. In Editor, we allow editing SpriteShape without having a valid SpriteShape profile to prototype easier. But a valid SpriteShape profile is required to be set for runtime to render properly. A simple SpriteShape profile with a 4x4 white texture set to repeat mode as fill texture can be set to these objects.

    In the latest version, we also added a warning if a valid SpriteShape profile has not been set instead of crash. Sorry for the inconvenience caused.

    Regarding feedback:
    • Improvements on position of the corners: Corners can be set in multiple ways. In version 4.1.1, we also have stretched corners available. It would be great if you can elaborate on this ?
    • randomness of tiles: You can use the variants to set randomness within an angle range. And you can also extend its functionality through scripting as well.
    • Lack of options to configure the complexity of the shapes: Could you please provide more info on what you would like to see?
    Thanks.
     
  3. oriolmanya

    oriolmanya

    Joined:
    Jul 4, 2012
    Posts:
    50
    Hi @Venkify. First of all, thanks for this fast answer, I see from it that you really care about the problems of the platform and concerns of users.

    That solution solved my problem :)

    You write:
    "In the latest version, we also added a warning if a valid SpriteShape profile has not been set instead of crash. Sorry for the inconvenience caused."
    But I'm not able to see it anywhere, not in the inspector, nor in the logs on play.
    I checked my Package Manager, and it's confusing:
    • I'm only able to download v.3.0.10
    • The version 3.0.11 states as it is -verified-, but there is no Import buttons
    • I attach and image:
    • Captura de pantalla (14).png
    About the clarifications you ask, I write it in successive posts in this thread, I need some time to think about them deeply and write it down accurately; because the tool is powerful, and I'm glad to know I can help to improve it :)

    Thank you again!
     
  4. oriolmanya

    oriolmanya

    Joined:
    Jul 4, 2012
    Posts:
    50
    Hi again @Venkify,

    I haven't been able to see the Warning when the SpriteShape doesn't have a proper Profile applied. But in fact doesn't matter to me, because I already know the bug, but could be useful to others.

    About the clarifications:
    • "Improvements on position of the corners: Corners can be set in multiple ways. In version 4.1.1, we also have stretched corners available. It would be great if you can elaborate on this ?"
      • I'm on the last version of Unity 2019.3.13, and I'm not able to see this, as well as the warning..
      • Do I need to do anything in particluar to have the last version of SpriteShape or it cames by default on installing Unity?
      • You say "corners can be set in multiple ways". Can you point me to the documentation on how to do it or give me hints or tutorials?
    • randomness of tiles: You can use the variants to set randomness within an angle range. And you can also extend its functionality through scripting as well.
      • Ok, then I'll try to do it by code
      • But anyway, I guess it would be nice to have a "Random" checkbox where you select the Sprite Variant, and then change it manually on the vertexs if you want to polish it.
    • Lack of options to configure the complexity of the shapes: Could you please provide more info on what you would like to see?
      • I see that there is this "Spline > Detail > Low, Medium, High" option
      • I would prefer an option to set the quality with the number of vertexs de spline will create
      • Maybe adding a "Custom" option that make appear and integer field with the amount of vertexs in-between?

    Other ideas / improvements:
    • Add a Button on Inspector to store the changes on the shape on runtime
      • This is a must have: it's when you are playing that you find that you should move slightly a vertex to allow a jump or whatever.
    • The corners are only added on the "Linear" vertexs, should be possible to add it on the other types
      • More reason to do so if you have to do it manually by selecting the "Disabled, Automatic" Selector
      • Would be nice an option to add the corners by default without having to chose it
    • To show a corners, all the neighbour vertexs has to be "Linear" as well...
      • I don't know if this is intended or not, but it's annoying and unnecessary in my opinion.
      • And when you are doing it for the first time could be frustrating to try to show the corners if you are working with both "Linear" and "Continuous" Splines
    • A Key Shortcut to allow to modify the vertexs of the selected Sprite Shape:
      • It's slow to go to the inspector button to modify the vertexs
      • Or maybe a double click? Or this could mess with the Scene GameObject selection?
      • N & M & Shift to play with the vertexs are useful and fast, thou

    Concerns about performance:

    I didn't profiled the project with the SpriteShapes, so maybe I'm wong, but regarding the Stacktrace of the Bug (See the first POST of the thread), I have the impression that something is being calculated on every "Update", this SpriteShapeGenerator.TessellateContour() kind of scares me.

    I understand that if you modify the SpriteShape on runtime, that Update behaviour makes sense, but for most Sprite Shapes that are static chunks of terrain, I guess there should be an option to convert into a "static" mesh when playing the project, so maybe this would perform better.

    Does my fears have any foundation?

    And that's all by now, thanks again for your time and I'm looking forward to your answer.
     
  5. oriolmanya

    oriolmanya

    Joined:
    Jul 4, 2012
    Posts:
    50
    Some additions to the thread:
    • About the proposal I made: "Add a Button on Inspector to store the changes on the shape on runtime"
    • One more thing about the "Linear" Vertexs:
      • They are "broken", so the mesh doesn't have continuity if you want straight lines. See the attached image:
      • Captura de pantalla (16).png
      • Sometimes it can be useful to have Broken linear vertexs on the corners, but not in the middle of the path
      • Maybe should be one more type of vertex:
        • "Linear" (The broken current one)
        • "Linear Continuous (or not broken)"
     
  6. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    618
    Please take a look at Stretched Corners introduced in 4.1.0 and above.



    Please take a look at BakeMesh functionality introduced in 4.1.1 and above. More info here :
    https://forum.unity.com/threads/2d-sprite-shape-4-1-1-for-unity-2020-1.892750/#post-5866900

    No, its not executed unless there is a change in SpriteShape Inputs. Also please enable Burst so SpriteShape generation Job can take full advantage and run faster.
     
  7. oriolmanya

    oriolmanya

    Joined:
    Jul 4, 2012
    Posts:
    50
    Hi @Venkify, all these sounds like great additions & improvements :) I'll check them as I'll check the "Burst" thing.

    What do I have to do to download this 4.1.1 version? Its only available in Unity 2020 that is still in Alpha release? I have to get it on GitHub? Could you provide me the link?

    I'm currently on 2019.3.13, there is only one update ahead that is the 2019.3.14.

    On the Package Manager I can only see "2D SpriteShape" 3.0.10 & 3.0.11 (See the PrintScreen four posts before).

    --------

    Changing the subject, now the only thing it's slowing down my level design is this point I already asked on the ideas list:
    • A Key Shortcut to allow to modify the vertexs of the selected Sprite Shape:
      • It's slow to go to the inspector button to modify the vertexs
      • Or maybe a double click? Or this could mess with the Scene GameObject selection?
      • N & M & Shift to play with the vertexs are useful and fast, thou
      • "B" Key could be nice, next to "N"
    • Or maybe could be some checkbox on a configuration window to allow to automatically show the vertexs on select a SpriteShape.
      • I know it can be dangerous in multiselection, but if it's optional it would be in the hands of the developer to enable it or not
    • Have you something in mind to solve this small drawback?

    Thank you very much
     
  8. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    618
    4.1.1 is only available for 2020.1 and above. Hence stretched corners is only available on this version.

    However BakeMesh has been backported and should be available to 3.* (> 3.0.12) versions soon. Will keep this thread posted. Thanks.