Hey, I have some programming experience but only in traditional environments (Eclipse, VisualStudio).
I have a MouseInformer script, which takes care of what the mouse has "picked up". When I click on a button (with a picture of a die) I want that button to add a die to MouseInformer's array of dice.
In the end, I want to be able to click on a text box, into which the dice list is emptied and all the dice are rolled, and shown in the text box.
I am really not used to the programming structure of Unity and find it quite difficult to imagine how my scripts work, so apologies if this question is really basic or if I'm going about the problem the wrong way (if you have any suggestions, please write!).
I've attached my MouseInformer script:
asked May 14 '10 at 01:27 PM
I believe a .js script is treated as a class in Unity, and to reference it you only need have the script in your project. You can then write lines such as
in another .js file, and it will recognise you are creating a new instance of a Die.js component. You can assign this a value in various ways; the easiest being to attach this other script to an object, then dragging onto it a Game Object that has a Die component attached. You can access any function or variable not specified as private, like this
answered May 14 '10 at 01:41 PM
All public classes declared in Unity scripts are available to all other scripts, with the exception of certain compilation order rules.
So to create and use a new Die instance, in any other js script, just do:
answered May 14 '10 at 01:45 PM