Search Unity

How to use Sprite.overrideGeometry?

Discussion in '2D' started by nostyleguy, Apr 18, 2015.

  1. nostyleguy

    nostyleguy

    Joined:
    Jul 27, 2012
    Posts:
    16
    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.
     
  2. Kuan

    Kuan

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    87
    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?
     
  3. nostyleguy

    nostyleguy

    Joined:
    Jul 27, 2012
    Posts:
    16
    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.
     
  4. Kuan

    Kuan

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    87
    Yeah... It will quite limiting if you want to do it in Editor mode.

    UVs is generated automatically after you call OverrideGeometry now.
     
  5. nostyleguy

    nostyleguy

    Joined:
    Jul 27, 2012
    Posts:
    16
    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.
     
  6. Kuan

    Kuan

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    87
    We're well aware of this shortcoming and will definitely do something about it, but, that's all I can say for now :)
     
    JoeStrout and donov like this.
  7. nostyleguy

    nostyleguy

    Joined:
    Jul 27, 2012
    Posts:
    16
    Good to hear! Thanks for the info, Kuan
     
  8. donov

    donov

    Joined:
    Apr 15, 2013
    Posts:
    55
    any progress on this, I would also like to be able to edit the Sprite class vertices, triangles, uv and texture used.
    Thanks
     
    fum1 likes this.
  9. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
  10. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    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?
     
    fireanth and fum1 like this.
  11. fum1

    fum1

    Joined:
    Jul 5, 2017
    Posts:
    4
    I want to override Sprite's uv, too.
     
    JoeStrout likes this.
  12. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    @Kuan Any progress on this since 2015?
     
  13. AnalogyBoy

    AnalogyBoy

    Joined:
    Feb 8, 2017
    Posts:
    1
    or 2019?
     
  14. surv0013

    surv0013

    Joined:
    Dec 9, 2018
    Posts:
    3
    Or 2020?
     
    JoeStrout likes this.
  15. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
  16. fireanth

    fireanth

    Joined:
    Jun 27, 2021
    Posts:
    2
    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?
     
    termway and JoeStrout like this.
  17. termway

    termway

    Joined:
    Jul 5, 2012
    Posts:
    84
    fleity likes this.