Disable a group of scripts based on base class.
Hi, I'm making a very small game, I will quickly detail its entire scope. If you think there is a better solution to this class-based idea please let me know. (I've struggled for a few days failing with GetComponent, and creating ArrayLists to track all the components, and I think maybe class-based solution will hopefully work)
GAME
The game has only a 'Main Camera' and a 'Cube' - each one has five scripts ( all the scripts inherit from the Level class), called A1, A2, A3, A4, A5 on the camera, and B1, B2, B3, B4, B5 on the cube.
At the beginning of the game I only want A1 and B1 to be enabled, and the other mentioned scripts to be disabled. The scripts are paired by number, and should be enabled at the same time. As the game progresses based on user input, i would like A1 and B1 to be disabled, and then A2 and B2 to be enabled. This continues gradually until A5 and B5, the end of the game.
How can I achieve this? A simple game with a camera and a cube that rotate through five behaviors together. I just want to be told what is a simple, common, idiomatic way to achieve this in C# / Unity.
If you can please be specific as I've wasted days trying to understand vague suggestions from unity IRC ( "you should really learn to debug", "just use classes", "this doesn't sound right") which are frustrating to say the least as I'm just starting out with this ecosystem. I'm a developer of five years in another field so feel free to use big words.
If you want to see my code just ask, but there's really not much to see as you can probably gather from this question, I'm still just trying to lay out the skeleton of the game.
Really thanks a lot.
toggling the scripts like ratio groups is totally fine if it gets the job done. little hint: GetComponents<$$anonymous$$onoBehaviour>()
, or using your base class will return an array of the attached scripts in order. if either gameobject of the two collects the scripts for both of them, it's as simple as increasing an index after disabling and after that enabling the scripts of both arrays.
since the game is that easy there's just no need to get fancy if that simple solution works, right?