Cannot figure out sizeof()

Hello. I am relatively new to coding, and am trying to make an object (a card) snap to a grid in the x-coordinate. I cannot figure out what it wants me to put in the parenthesis outside of sizeof, and was unable to find any information online

Here is the code

objCard.transform.position = new vector3(Mathf.round(objCard.x/sizeof(objCard.x))*sizeof(objCard.x) , objCard.y, objCard.z);

where did you got this code? is a tutorial?

No. It is not a tutorial

so what are you trying to do? I don’t understand why you are using the sizeof function

I am trying to make the card snap to a grid. The logic below is what does that
(Mathf.round(objCard.x/sizeof(objCard.x))*sizeof(objCard.x)

It is taking the x-position of the card, dividing it by the length of the card, rounding the answer, and multiplying it by the card width. If the x-position is 33, and card is 10 long, it would be
round(33/10)*10 = 30

Size of is its size in memory and is nothing whatsoever to do with its position on screen. You can quickly find this with a search though: sizeof operator - determine the storage needs for a type - C# reference | Microsoft Learn

I know that sizeof doesn’t deal with the position on the screen. I need to reference the height/width of the card

No, this is not what this expression does. What you have written is taking the x-position of the card, dividing it by the amount of bytes the x variable of the objCard needs to be represented in memory and after rounding it is multiplying it by the amount of memory the x variable needs.

There is nothing in the sizeof method that has to do anything with the length/width of the card, unless you have overwritten the method and have implemented you own sizeof(), which is a bad practice as it will confuse everyone reading it.

Why then did you title your post as “cannot figure out sizeof()” if you know what it does? If you’re not clear then you won’t get a clear answer.

The community won’t know how to get the width/height because you don’t state what the card actually is. There isn’t a “card” type in Unity so it could be anything. Again, you need to provide more information if you want a useful answer.