I’m just writing this down as I felt. Don’t take it too seriously. ![]()
Background
I previously created a canon_enemy that can fire projectiles using a collection file. Today, I wanted to give this canon_enemy the ability to move vertically in certain scenes, but the collection file simply can’t do that because modifying the canon_enemy in one scene will modify all canon_enemy in all scenes.
Of course, I can solve this problem by creating a new collection file called canon_movale_enemy.But when I need to add more functionality to the canon_enemy, I’ll be forced to create more and more collection files.
However, I later discovered that modifying the script properties of certain instantiated Collection files individually is also a good solution.
Solution
The drawback of a Game Object file is that it cannot contain Game Objects; it can only store components.
However, modifying the script properties of a instantiated Game Object file will not affect other instantiated Game Object files.
Although a Collection file can hold multiple game objects, modifying a instantiated Collection file in one scene will also modify instantiated Collection files in other scenes.
However, modifying the script properties of a instantiated Collection file will not affect other instantiated Collection files.
My solution is to put all prefabs into a single Collection File. When a scene needs these prefabs, I manually copy the corresponding prefabs from this Collection File to other scenes.
This solution reminds me of the Contruct3 game engine; I remember seeing something similar when I watched a Contruct3 video tutorial a year ago.
Then I thought of creating a collection file to store custom “components”. These components could be scripts or Game Objects. Some custom components could implement vertical movement, while others could implement bullet firing. These custom components could then be freely combined and placed elsewhere.



