- Home /
The question is answered, right answer was accepted
Unable to fill list.
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);
}
}
}
Answer by Myth · Aug 20, 2014 at 12:33 AM
So I had it right, the thing had somehow cached the wrong script or something similar... Note to self, reset objects and restart computer... :(
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
C# Displaying a List in Series 2 Answers
Scripting and Coding Dictionary 0 Answers
Multiple Cars not working 1 Answer