I need to create border for my sprite. I have attached a LineRenderer component to the GameObject which also has this sprite. At runtime I am getting coordinates of renderer using bounds.
Vector2 extents = gameObject.GetComponent<Renderer>().bounds.extents;
Then with some +/- logic I get the coordinates.
Vector3 TopLeftCornerPosition = gameObject.transform.position;
TopLeftCornerPosition.x -= extents.x;
TopLeftCornerPosition.y += extents.y;
I am using these coordinates in LineRenderer to set four positions.
LineRenderer.SetPositions(blockCorners);
But when LineRenderer’s ‘Use World Space’ option is checked, it does draw the line but when I move this block object, the line border does not move along with it though for LineRenderer block is the parent.
When I uncheck ’ User World Space’ Option, I see the box drawn by LineRenderer’ but it’s scale is almost 1/3 times then the block or sprites. But it moves along with the block. How can I fix it.
Please refer the attached screenshotsalt text