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

Custom 2d meshes

Discussion in '2D' started by andyz, Nov 24, 2014.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,123
    So it would be good to have 2d meshes for non-rectangular sprites and custom meshes.

    I can generate a mesh for terrain etc using the 3d Mesh object and add a 2d collider but the z coordinate is wasted and using a 3d mesh creates ordering issues - I only seem to be able to place 3d objects either in front or behind the 2d stuff by adjusting the z coordinate. I can't layer within the 2d because it's not a sprite
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Even for 2d sprites you still have to pass in a `vertex` which is 3 floats, you don't save anything by having it be a `2d mesh`. the hardware is still 3d and still needs 3d vertices.
     
  3. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,123
    Yes I know but 3d and 2d are distinct in Unity so I don't think I can layer the 2 properly with the built in Mesh class.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    No they're not. There's no real 2D; everything is 3D and lives in 3D space. For 2D meshes, just use the Mesh class as usual.

    --Eric
     
  5. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
    andyz and rakkarage like this.
  6. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,123
    And how do I layer this mesh between 2d sprites?
     
  7. Vitor_r

    Vitor_r

    Joined:
    May 23, 2013
    Posts:
    93
  8. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,123
    Yes that works if I also use a transparent shader (e.g Sprites/Default) on the mesh thanks Viktor.