So I have this piece of code that needs to have a list of all child objects that have a weaponSet script on them. I add the objects in the inspector and they update the list, but when i run the game, the output is that there is nothing in the list… Any suggestions or improvements?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class StrikeCraftFlightInput : MonoBehaviour {
// *** other components *** //
StrikeCraftFlightPhysics myPhysics;
public List<WeaponSet> myWeapons = new List<WeaponSet>();
// *** control settings *** //
private int selectedPrimary = 0;
private int selectedSeccondry = 1;
public bool weaponsEnabled = true;
// *** player preferances *** //
private bool useInverted = false;
private bool useCruiseControl = false;
private float mouseSensitivity = 1.0f;
public bool movement = true;
Vector3 mDelta;
int mSteeringTouch = -1;
float mNextPrimary = 0f;
float mNextSecondary = 0f;
// Use this for initialization
void Start ()
{
// *** finding components section *** //
// find the strikecraft physics script
myPhysics = GetComponent<StrikeCraftFlightPhysics>();
// *** applying info section *** //
// error trap if no weapons found
if(myWeapons.Count < 1)
{
weaponsEnabled = false;
Debug.Log("No weapons were found on " + name);
Debug.Log(myWeapons.Count);
}
}
}