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

[Asset] Primitive UI - Draw shapes and lines in the new UI

Discussion in 'UGUI & TextMesh Pro' started by Senshi, Oct 4, 2015.

  1. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    552
    Asset Store | Web Demo | Manual | Preview Images

    Hi everyone,

    First off, apologies if these kind of posts are not allowed or appreciated here; I couldn't really find any forum rules or stickies regarding this.

    That said, my first ever Asset Store submission just got accepted and since I've seen the topic of drawing primitives and complex shapes come up a couple of times already on this forum, I'd like to share it here as well.

    Condensed ales talk:
    Primitive UI lets you draw both simple primitives and more complex shapes and lines onto a component called PrimitiveCanvas. The way it works is reminiscent of the HTML5 canvas and is a great way to get arbitrary shapes on the screen without needing custom textures or masks.

    It comes with out-of-the-box support for the following shape types:
    • Squares and Rectangles
    • Circles and Ellipses
    • Regular and Irregular Solids
    • Lines and Paths
    In addition, you can pass in a series of polygon points for the UI to fill in automatically, as well as a series of raw VBO points for Unity 4.6-5.1 or mesh vertices and triangle indices for Unity 5.2.

    Sample uses may include graphs, animated 2D shapes, dynamically drawn content or placeholder/ debug art.

    Small warning:
    The new Unity 5.2.1p1 patch release introduced a new change in the UI drawing API. Primitive UI still works as expected, but will throw an obsoletion warning on compilation. Since another change in this API is expected for the p3 patch release, and as patch releases are not officially supported as production-ready by Unity, I will not be further supporting patch releases p1 and p2 either, unless an asset-breaking bug is found.

    Besides the obvious of checking out the asset, I would also very much appreciate any and all feedback you may have for me. I'd like to produce more Asset Store content in the future and would love to know what I could improve on.

    Thanks!
    -Patrick
     
    SimonDarksideJ likes this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Great stuff @Senshi Awesome work!
     
    Senshi likes this.
  3. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    552
    Thanks Simon!
     
    SimonDarksideJ likes this.
  4. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi Senshi,
    Purchased the asset, works as expected.
    Nice, simple and clean.
     
    Senshi likes this.
  5. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    552
    Awesome, glad to hear that!
     
  6. crispybeans

    crispybeans

    Joined:
    Apr 13, 2015
    Posts:
    210
    Whau I will have to check that you! I ve been missing somethign like this for one of our projects.
     
    Senshi likes this.
  7. mecharius

    mecharius

    Joined:
    Jan 11, 2014
    Posts:
    20
    I'm enjoying the asset @Senshi, would be great if I could use Primitive UI to draw text as well
     
  8. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    552
    Thank you! I'm afraid text is a whole beast of its own and I don't feel there would be very many benefits to it. There are some great text solutions out there already though! =)
     
  9. dthurn

    dthurn

    Joined:
    Feb 17, 2015
    Posts:
    77
    Hi Patrick, does this asset support drawing shapes on a world space canvas, or is it screen space only? I'm hoping to be able to draw shapes on a 3d scene.
     
  10. Senshi

    Senshi

    Joined:
    Oct 3, 2010
    Posts:
    552
    I've never tried it, but I don't see why not! In the end it's just another Graphic inheriting from UI.MaskableGraphic. =)