Are there any pitfalls for putting space in GameObject/Prefab names?
I know Unity allows white space in GameObject names, but I see lots of official Unity video tutorials where the presenter name there GameObjects in pascal case instead of using white space. Are there any practical reason why?
Answer by Owen-Reynolds · Jan 13, 2020 at 03:33 AM
I don't think spaces in a gameObject name can cause a real problem, but no-spaces is probably simpler. Transform redBall = balls.Find("red ball");
is harder to remember. Easier if everything is camel-cased. Plus a very minor problem of confusing 2 spaces with 1 -- "red ball" (2 spaces after red, by accident).
Historically, spaces in filenames caused problems when you used them on the command-line. (Unix didn't allow them, but Microsoft foolishly did). Some strings also turn into variables, so can't have spaces. For example, Unity allows you to name a script "red ball", but then the class becomes "red ball", with a space, which breaks it (public class red ball {).
Because of stuff like that, most people probably instinctively avoid spaces in names that users won't see.
$$anonymous$$y problem with no-space approach is that it becomes harder to read when I need a more descriptive name, "RedBall" is simple enough, but something like "RedBallBoucingSequence" just doesn't look so good. Also for non-programmer member on the $$anonymous$$m they are not use to seeing it either.
Sure, but check that's the case. Even artists may be comfortable with a no-space format due to filenames: redBall_BouncingSequence may be the most descriptive name of all.