It may be that I am tired but I cannot seem to figure out how to place a script that doesnt inherit from monobehaviour into an array of that type in the editor/inspector
Now in the above code I have a MonoBehaviour script attached to a GameObject and it displays the weapons array but when I add more elements to it I cant just drag the BaseWeapon script to the element.
Im wanting to do this so the level designers can easily drag the weapon that they want the pickup to drop into the array, theres also code in place to select one at random if more than one weapon is in the array.
EDIT: Added additional code, Projectile is just a monobehaviour which has a public var damage and simply moves the go forward and sends the damage variable to whatever it hits. This code is not my original as I am not at home atm so i just hand typed this myself and it is not complete such as there is also a function to allow the player to cycle thru their weapons but i left it out for this... If any additional info is needed let me kno
Thanks in advanced
You seem to have a misunderstanding of what
is. It is an array of references to instantiated objects, not an array of classes. If you have a prefab with a BaseWeapon object attached to it, then you can drag that prefab onto a slot in the weapons array. If that's not what you want to do, my next guess would be that you want an array of enums. If this isn't enough to get you going, further description and code for what you want to do will be necessary to help you.
answered Feb 28 '11 at 03:29 PM