Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Draw primitives with Tiny

Discussion in 'Project Tiny' started by reallyhexln, Apr 30, 2019.

  1. reallyhexln

    reallyhexln

    Joined:
    Jun 18, 2018
    Posts:
    69
    Hi, guys.
    Sorry for stupid question.
    Is there any way to draw primitives in Tiny (rectangle, line, polygonal chain)?
    I want to add selection rectangle to my object on the scene. The problem is, each object has it's own size and aspect ratio, so I have to add specific Selection sprite to each object, and currently I have about 10 Selection images for different sizes and aspect ratios.
     
    Ferran_SP likes this.
  2. Zionisias

    Zionisias

    Joined:
    Apr 23, 2019
    Posts:
    40
    Nine-slicing is supported in Tiny. This would mean that you can use a single image for all different sizes and aspect ratios.

    To make a Nine-sliced image:
    1. Go to your Asset folder, and locate your image.
    2. In the import settings of your image, click on the "Sprite Editor" button.
    3. This will open up the sprite editor, where you can adjust the "Border"-variables (In pixels) in the bottom-right of your screen.
    4. Click apply in the top-right corner, and close the window.
     
    reallyhexln likes this.
  3. reallyhexln

    reallyhexln

    Joined:
    Jun 18, 2018
    Posts:
    69
    Thank you for a quick reply, Zionisias, but I know about 9-slicing and I using it now.
    Unfortunately, it has some issues:
    1) scaling of images lead to reduce resulting image quality, so I must have a very big version of sprite that will fits for all possible areas;
    2) it's an additional effort to add selection image entity to each object on the scene, especially, if you have hundred of objects.
     
    Zionisias likes this.
  4. Zionisias

    Zionisias

    Joined:
    Apr 23, 2019
    Posts:
    40
    Hey reallyhexln,

    I was a bit confused when you said that you would lose image quality, as Nine-slicing should prevent that from happening at all, so I tested it out, and it seems that Nine-slicing does not work for entities with a regular transform, but only for entities which have a RectTransform. I do not know if your entities have a RectTransform or not, but if not then Nine-slicing will indeed not be an option for you.

    If your entities do have a RectTransform, you should not need to manually add a selection-image entity to each object, as you could do this via code on initialization.

    To get back at your original question, I have not yet encountered a way to draw primitives in Unity Tiny, but I have not actively searched for this, so it might be hidden somewhere.