I have a main script attached to a lot of game objects in my first level and I want to create a bunch of similar levels where the only thing that changes is the script.
I would prefer to create 10 different scripts for 10 different levels by copying the first script and changing each script slightly. But then I would have to assign a new script to every gameobject which seems slow.
Is there a smart way to quickly change every script A attached to gameobjects to a different script B?
My first thought is: “how similar are the two scripts?”. The reason is that you really don’t want to duplicate code. It’s against all the principles of good programming. Should you be breaking out the common function into separate classes and call using events or actions? It might then be a simple conditional test to call the different code based on level. I have to say that would be my first design approach…
It might also be that such a requirement would become some sort of state machine since that might give you options should you go to further levels with similar requirements.
I mean I want to create a new level by copying a scene and then making a new script for the new level by copying the main script and rewriting it slightly