Basically the same question as this thread: http://forum.unity3d.com/threads/how-to-make-sprite-overridegeometry-work.297505/ But that was posted in the Unity5-beta only forums which I assume aren't being followed as closely now that Unity 5 is released (I also can't reply to that thread). When attempting to use Sprite.overrideGeometry, I get the following error: Not allowed to override geometry on sprite '' It seems like a hold-over from the Pro vs Free feature limitations of Unity 4.x, but maybe there is something I'm missing.
It isn't a Pro vs Free issue. This error message will pops up with you trying to use it not during runtime/playmode. Were you trying to use the method in editor mode?
Yes I was. My goal is to make a tile-map editor extension. I've actually got a fair amount of progress, but the underlying system uses 3D meshes, mesh-renderers and textures. I saw this method and thought I could use it to convert the visual representation to custom 2D sprites, and leverage the sprite-specific bits of Unity's workflow (sprite editor, pixels-per-unit, etc). Apparently, this isn't possible. I also would have needed to provide custom uvs to the sprite's mesh, which I wasn't sure how to accomplish with Sprite.OverrideGeometry, but the point it moot now.
Yeah... It will quite limiting if you want to do it in Editor mode. UVs is generated automatically after you call OverrideGeometry now.
I see. Does Unity have any plans (near or long-term) to extend this functionality to Editor time, or even runtime? As an aside, I'm kinda surprised that there is no way to override the UVs, even at import time. My use-case may be atypical but certainly anybody who is tweaking/altering a sprite's mesh is going to want to be able to tweak the UVs at the same time? Otherwise we're at the mercy of whatever mapping algorithm Unity uses for the new geometry.
We're well aware of this shortcoming and will definitely do something about it, but, that's all I can say for now
any progress on this, I would also like to be able to edit the Sprite class vertices, triangles, uv and texture used. Thanks
Try to override the geometry in AssetPostprocessor.OnPostprocessSprites in Editor It should be working!
I need to do this at runtime, for sprites loaded dynamically (from a TexturePacker sheet, if you must know). Is there really (still) no way to do this?
If you are changing the UVs during runtime, you can use (sprite).SetVertexAttribute<Vector2>(VertexAttribute.TexCoord0, (myUvs))(https://docs.unity3d.com/ScriptReference/U2D.SpriteDataAccessExtensions.html) to do so.
can you give some simple sample code that shows how to use SetVertexAttribute. Why is there no way to simply assign all mesh vertices to a sprite?
There is example here: https://forum.unity.com/threads/vector-graphics-preview-package.529845/page-5#post-3604917 Here a minimalist code: Code (CSharp): var uv = sprite.GetVertexAttribute<Vector2>(VertexAttribute.TexCoord0); var uvs = new NativeArray<Vector2>(uv.Length, Allocator.Temp); uvs.CopyFrom(spriteUV); sprite.SetVertexAttribute(VertexAttribute.TexCoord0, uvs);