How prefab the instance works?

Hi guys, let’s say I have built a entire city made of different blocks.

  • Each block is a prefab.
  • Each block has some buildings that
    are also prefabs or just models.

When in game I don’t want the entire city loaded, only the blocks around the player will be alive. Here is my doubt, Unity does not have until now a “Prefabs of Prefabs” system, when I instantiate a new different block that has some models that are already used in other prefabs does Unity knows that these are the same ones?

I must know because I’m aiming for mobile, and there can be no waste of RAM/VRAM.

Thanks in advance.

yes if you have a prefab that is

Prefab A + prefab B

and another that is

Prefab A + prefab C

of course it recognizes the connection between A in each.
As long as you make sure your actually using the prefab in both.

if in the hierarchy you have it as A and B for one. A and C for the other. It will only have 1 instance of A in memory.

That is because a prefab is meaningless to the computer, its instituted for us not for the computer. To the computer prefabs dont exist, it just says draw A here and B here and A here and C here and has no need to group A and B together.

Basically we have difficulty with doing the same thing over and over again and perfectly every time. We make mistakes and forget.

But a computer sees no need for a prefab. A prefab is really a relationship formed between multiple objects as it relates to there position/scale because remembering to set each position and each scale everytime would be tedious and difficult. Writing spawn prefab A is alot easier to do and get right everytime than
spawn object A then spawn object B so far away. Then scale A to B by so much, and doing that every single time.

But that is in fact what a computer does. It replaces your prefab with lots of tiny little instructions like that. Cause it has no problem repeating those instructions over and over again perfectly even without a frame of reference to compare it against.