I have attached the following script to a number of weapon prefabs:
public class WeaponScript : MonoBehaviour {
public enum Direction {Right, Straight, Left};
public Direction weaponDir;
// Use this for initialization
void Start () {
prepareDirection (weaponDir);
}
void prepareDirection(Direction dir) {
if (dir == Direction.Straight) {
transform.localEulerAngles = new Vector3 (0, 0, 0);
}
else if(dir == Direction.Left) {
transform.localEulerAngles = new Vector3 (0, 0, -30);
}
else if(dir == Direction.Right) {
transform.localEulerAngles = new Vector3 (0, 0, 30);
}
}
}
I also added the following script to an empty game object SetupWeapon:
public class SetupWeaponsScript : MonoBehaviour {
public GameObject[] weaponPrefabs;
public GameObject[] weapons;
void Start ()
{
weapons = new GameObject[weaponPrefabs.Length];
//makes sure they match length
for (int i = 0; i < weaponPrefabs.Length; i++)
{
weapons[i] = Instantiate(weaponPrefabs[i]) as GameObject;
}
}
}
When I select my SetupWeapon object, I am able to populate the weaponPrefabs array with the weapon prefabs I want to use, but this doesn’t allow meI can't directly alter their parameters in that same inspector view. I want to setbe able to override the Direction enum fordirection of each weapon prefab in a similar way in the editor. Each weapon prefab haslist, rather than use the same value that's stored on the prefab itself.
How can I create the weapon prefabs and weaponsSetup/weaponsSetupScriptweaponsSetupScript in such a way that I can set the direction enum for each weapon game object element entry at the same time that I set select the prefab in the editor? I believe it might have something to do with inheritance, just not too sure how to go about it though.