Multiple Scenes, view, and coordinates

In the video Level Flow Layout in (Complete C# Unity Game Developer 2D Online Course (Unity 2018) - Archive course.) we talk about loading multiple scenes and moving them. The instructor also says that you need to be careful to select all items and that this method may have issues down the road.

Would it not be efficient to link all items in each scene to a empty game object example level 1 have an empty game object level 1 and then link all related level 1 scene items under it to force all items of said scene to share the universal 0,0,0 coordinate system as if they were in the original positions?

Sorry about the run-on sentence here. Would this work or would it cost excessive system resources down the road? Previously the instructor talked about how memory is expensive and this could be caching the coordinates in memory rather than calculating them?

EDIT
Picture Example of linking the Items under a universal game object to keep the 0,0,0 coordinate system

Hi Oxidine,

Welcome to our community! :slight_smile:

In little games like ours, your approach would be perfectly fine. In larger projects, it is not recommended to create “thousands” of game objects for organising the Hierarchy because each game object is a fairly large object due to the inheritence from MonoBehaviour. You will have to find a good balance between organising the code and having as few game objects as possible.

That being said, I’m afraid there is no universal answer to your question. If your idea solves a problem, it could make sense to apply that idea.


See also:

Fantastic, thank you very much for your response. Can you go into further detail about “it is not recommended to create “thousands” of game objects for organising the Hierarchy because each game object is a fairly large object due to the inheritence from MonoBehaviour.”?

When you say its a fairly large object, do you mean resources wise, space, processing power, or maybe a mix of the previous? Being a new developer I feel its best to understand best practice as I do not wish to make any major mistakes that could be significant down the road for larger projects.

EDIT
Just want to add a quick ninja edit that im not looking for anything super complex, just basic information on these. I kinda assumed that empty game objects were 0 or low cost for resources.

Do you know C# objects? A pure C# object with “nothing” in it does not take up much space in memory. If you extend the script with variables, etc., the objects become larger. MonoBehaviour is a large class in the UnityEngine namespace. If your script inherits from it, your object becomes fairly large compared to the “empty” C# object.

If you create a game object in the Hierarchy, you have at least a GameObject object and a Transform object. Unity has to handle these game objects during runtime. The more objects there are, the more it has to do. Obviously.

Furthermore, the children depend on parents. Whenever something happens in the scene, Unity might have to check the entire tree. As you can imagine, that might be time consuming.

A couple of years ago, I read in the Unity manual that it was not recommended to have too many empty game objects to organise one’s project. The topic was “performance opimisation”. Maybe it referred to UI stuff where it is fairly easy to ruin the performance.

I was not able to find that information again but maybe you’ll stumble upon it in the future. I found this article, though, which seems to cover the same topic.

Performance optimisation is a huge topic, and it is not easy to grasp if you are not familiar with Unity. For this reason, don’t worry too much about it unless you spot an issue in your project. Once you have a problem, it’ll be easier to solve it than trying to learn solutions by heart for problems that you don’t have. Also, don’t waste your time optimising the performance if you don’t have a problem with the performance. Otherwise, it might be that you’ll never complete your project.

Awesome, I had to go over a it a few times but basically by doing it this way It will cause the system to link all items of a scene as child objects of the whole. This could cause slowdowns in the system for example when using GetComponent and other lines of code that can search for items. According to the link posted above under level 2 they mention to never go past 4 levels of depth to any game object. My method in this post would make that 3 in this context. As for the “50 child elements” that would be components, scripts, and other items; would this be correct?

If you do not mind, am I understanding this correctly?

I don’t know what the author of the article means by “50 child elements”. You could message him. Maybe he’ll reply.

All good, I think I have enough here to close this thread with resolution. Thank you very much for your time and response’s and hope you have a great day.

You’re welcome. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms