#Aligning Sprite to a Template Sprite

1 messages Β· Page 1 of 1 (latest)

safe hedge
#

Hi guys, so I have these two sprites, the first big box sprite is my main template sprite, the three sprites at the bottom are Button sprites, I want to place it and align them into my template accurately. How do I do that?

grim pulsar
#

though i feel like it'd be easier to simply add the buttons fully in-engine rather than aligning them onto a template

grim pulsar
#

oh huh?

safe hedge
#

maybe I should've built it as a UI object πŸ’€

#

that's why I was struggling

grim pulsar
#

it does look like ui yeah

safe hedge
#

yeah I guess I need to change my approach πŸ€”

grim pulsar
#

is it screen space?

#

or world space

safe hedge
#

I am not sure what those mean but I would assume world space πŸ˜‚

#

it's definitley not in a Canvas

grim pulsar
#

is it an in-world object or is it an overlay on the screen?

safe hedge
#

it's an in-world object

grim pulsar
#

then you use a world space canvas i'd imagine

#

or is it not ui at all?

safe hedge
#

I did not πŸ˜‚

#

I think I should change it to a Screenspace object

#

instead of a world space

#

I have everything coded out, I just need to play around with game objects right?

grim pulsar
#

what is it supposed to be?

safe hedge
#

well, u click the buttons at the correct order to complete the task

#

and the right top button will light up

grim pulsar
#

hm

#

you might wanna make it a world space canvas then

#

can you show how it looks in the game?

safe hedge
#

I am changing it to Canvas yes

grim pulsar
#

i mean it's just an object positioned somewhere in the game world right, not a popup menu or something? if so you'd wanna use a world space canvas instead of screen space

#

though you could also just use normal non-ui game objects

safe hedge
#

it's a simple game for a game jam πŸ˜‚

#

now my Canvas is smaller than my object πŸ€”

grim pulsar
safe hedge
grim pulsar
#

a screen space canvas is positioned on the screen directly, irrespective or where the camera is

safe hedge
#

Screen space overlay or scren space camera?

grim pulsar
#

while a world space one is positioned in the game world and moves with the camera

safe hedge
#

there's another one called World Space Canvas

grim pulsar
safe hedge
#

Why is my Panel not stretching tho?

#

I mean, I did click set native size

grim pulsar
#

these left right up and down are offsets, you can change them

#

you can also press on the stretch icon and select center, then change the position and size

safe hedge
#

Hmmm, odd it didn't move

grim pulsar
#

yeah, they keep the position nad size when you change them

#

you need to change the numbers

safe hedge
#

Hmm lemme look up some tutorial to refresh my memory on how to do this πŸ˜‚

#

I remember there's a green anchor stuff

#

ok so I figured out how to stretch an empty game object to the canvas

#

now I want to stretch the Image and keep the ratio, how do I do that?

grim pulsar
#

you can turn on preserve aspect on the image component

safe hedge
#

awesomeee

#

So I know my measurements, but they are in pixel πŸ€”

#

how do I convert it to the right size?

grim pulsar
#

you can press set native size on the image

safe hedge
#

it's in a grid layout though, when I press that, nothing happens

#

do I need to wrap it in another game object?

grim pulsar
#

on the panel i meant

#

tho i think you might just have to screw around until it looks about right

safe hedge
#

I think so too πŸ€”

safe hedge
grim pulsar
#

no the template one

safe hedge
#

does changing my PPU helps?

grim pulsar
#

you can do that yeah

safe hedge
#

to 1?

grim pulsar
#

actually i don't think it'll do much? it might change what it looks like when you press set native size

safe hedge
#

it becomes extremely big if I set it to 1 πŸ˜‚

grim pulsar
#

yeah, ppu is pixels per unit, so now 1 pixel in your image is 1 unit in the game

#

(and i think your canvas's reference pixels per unit is set to 100 by default)

safe hedge
#

so if I want to use my measurements that I measure from Aseprite

#

I should have my PPU as 1 right?

grim pulsar
#

you'd want it the same as what you have set as your canvas's reference pixels per unit, which is by default 100

#

usually all that matters is you keep it the same for all sprites

safe hedge
#

interesting

#

why is my anchor doing this

#

I have a horizontal layout in my BUttonBox

grim pulsar
#

hm, what are the settings on it?

safe hedge
#

but I kinda wanna control the size of each horizontal column though, the width

grim pulsar
#

separately?

safe hedge
#

ticking the height solves the problem

grim pulsar
#

you probably also wanna tick width

safe hedge
#

OMG I DID IIIITTTTT

safe hedge
#

I want to do something like this

grim pulsar
#

i think you can, you just need to give it a layout element component

safe hedge
#

which is?

safe hedge
#

ohhh

#

okay I'll look into it

#

why is there no max width and max height

grim pulsar
#

you probably wanna change preferred width and height

#

or if it's too big you can turn off force expand children

#

but yeah ugui layout is a bit annoying sometimes (often)

safe hedge
#

I can add padding too :D

#

I think what's annoying for me right now is the units

grim pulsar
#

yeah!

#

they're pretty weird yeah

safe hedge
#

is there a way to use my aseprite pixel units 😭

#

cause if I set it to 1 PPU, I can multiply every pixel to 100

grim pulsar
#

i don't think so?

safe hedge
#

but if I set it to 100, I can't use my normal pixel size

#

oof

grim pulsar
#

also, you should probably select "scale with screen size" on the canvas scaler component

safe hedge
#

okay

#

Oof

#

Imma take a break

#

pretty burned from UI πŸ˜‚

grim pulsar
#

understandable kekw

safe hedge
#

Maybe I should stop using the template

#

and just eyeball the UI πŸ˜‚

grim pulsar
#

that's what i usually do haha

safe hedge
#

I'll think about it after dinner thank you so much :D