Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

A way to easily make class objects with multitude of properties? (JS)

$
0
0
My game is stage based at the moment. So in a stage there will be various GUI elements being displayed, various game objects instantiating that aid the player, and even if the player has control or not. All of these are being controlled by a class with many properties like this: class Stage { var story: String; var controlArray: String[]; var taskName: String[]; var taskStatus: Texture2D[]; var PC: boolean; var arrowArray: GameObject[]; } var Stage0 = new Stage(); Stage0.story = ""; Stage0.controlArray[0] = "Spacebar"; Stage0.controlArray[1] = "something"; Stage0.controlArray[2] = "anotherSomething"; Stage0.taskName[0] = "GoSomewhere"; Stage0.taskName[1] = "GoSomewhereElse"; Stage0.taskName[2] = "GoBack"; Stage0.taskStatus[0] = a2Dtexture; Stage0.taskStatus[1] = a2Dtexture; Stage0.taskStatus[2] = a2Dtexture; Stage0.PC = true; Stage0.arrowArray[0] = someGameObject; Stage0.arrowArray[1] = someOtherGameObject; var Stage1 = new Stage(); //different properties var Stage2 = new Stage(); //different properties THE QUESTION: Is there a way to quickly and easily make these stage objects and give them there individual properties without having to go through manually and type out each one or fill it in in the inspector? Is there a way to create a simple constructor that could address most if not all properties without being a huge pain in the ass to instantiate? Using JS btw

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>