Hi all,
This question is just driving me crazy! How do I access the variables of another script via an array? I have the following scripts: (this one is with the error)
using UnityEngine;
using System.Collections;
public class SoldierManager : MonoBehaviour {
public Transform[] Soldiers;
Transform SH;
PlayerID[] playerID;
HealthManager[] healtManager;
// Use this for initialization
void Start () {
SH = transform.FindChild ("SoldierHolder");
Soldiers = SH.gameObject.GetComponentsInChildren<Transform> ();
playerID = new PlayerID[Soldiers.Length];
for (int i = 0; i < Soldiers.Length; i++) {
playerID _= Soldiers *.GetComponent<PlayerID> ();*_
* }*
* }*
* // Update is called once per frame*
* void Update () {*
* }*
* void OnGUI(){*
* for( int i = 0; i < playerID.Length; i++ ) {*
* GUILayout.Label (playerID.PlayerName);*
* }*
* }*
}
and this is the id script:
using UnityEngine;
using System.Collections;
public class PlayerID : MonoBehaviour {
* public int playerID;*
* public string playerName;*
* public enum Rank{PVT, PV2, PFC, SPC, CPL, SGT, SSG, SFC, MSG, FSG, SGM, CSM, SMA};*
* public Rank rank;*
}