public virtual void Initialize() { if (!initialized) { buttonPrefab = (GameObject) Resources.Load("Prefabs/UI/TextButton"); mothership = GameObject.FindGameObjectWithTag ("Mothership"); mothershipscript = mothership.GetComponent<Mothership> (); buttonPrefab = (GameObject)Resources.Load ("Prefabs/UI/TextButton"); Transform displayControlParent = transform.FindChild ("Display Controls"); displayParent = transform.FindChild("Display"); selectedObjectName = transform.FindChild ("Status/SelectedUnitName").GetComponent<Text> (); selectedObjectClass = transform.FindChild ("Status/SelectedClassName").GetComponent<Text> (); for (int i = 0; i < displayControlParent.childCount; i++){ displayControls.Add(displayControlParent.GetChild(i).GetComponent<Button>()); string name = displayControls [i].gameObject.name.Substring (8); //first seven characters are 'Display ' displays.Add(displayParent.FindChild(name)); //find the corresponding display to the button to show it int pass = i; //pass this along to avoid mutating the value of the function set displayControls[i].onClick.AddListener (()=> ToggleDisplayTo(pass)); if (name == "Deploy"){ deployButtonOrganizer = displays[i].GetComponentInChildren<ButtonOrganizer>(); displayControls[i].onClick.AddListener (()=> DisplayDeploy()); } } initialized = true; } }
void Start() { internalRect = transform.FindChild ("Internal").GetComponent<RectTransform>(); externalRect = transform.FindChild ("External").GetComponent<RectTransform>(); internalButtons = internalRect.GetComponent<ButtonOrganizer> (); externalButtons = externalRect.GetComponent<ButtonOrganizer> (); attachmentPanel = PrefabLoader.GetGUIObject ("AttachmentPanel"); userInput = transform.root.GetComponent<ShipEditorUserInput> (); }
public override void Initialize() { Canvas canvas = transform.FindChild ("ShipEditorCanvas").GetComponent<Canvas>(); userinput = GetComponent<ShipEditorUserInput> (); foreach(GameObject g in GameObject.FindGameObjectsWithTag("Canvas")){ g.SetActive(false); //set all other canvases inactive to be sure there aren't multiple active } canvas.gameObject.SetActive (true); //activate the canvas we want buttonorganizer = canvas.GetComponentInChildren<ButtonOrganizer> (); attachmentPanel = (GameObject)Resources.Load ("Prefabs/UI/AttachmentPanel"); shipPanel = (GameObject)Resources.Load ("Prefabs/UI/ShipPanel"); framePanel = (GameObject)Resources.Load ("Prefabs/UI/FramePanel"); }
public override void Initialize() { crewmanager = GetComponent<CrewManager> (); crewpanel = (GameObject) Resources.Load ("Prefabs/UI/CrewPanel"); shippanel = (GameObject) Resources.Load ("Prefabs/UI/ShipPanel"); Canvas canvas = transform.FindChild ("CrewManagementCanvas").GetComponent<Canvas>(); crewbuttonorganizer = canvas.transform.FindChild ("Left Panel").GetComponent<ButtonOrganizer> (); postbuttonorganizer = canvas.transform.FindChild ("Right Panel").GetComponent<ButtonOrganizer> (); dockedunits = GameObject.FindGameObjectWithTag ("Mothership").transform.FindChild("DockedUnits").gameObject; foreach(GameObject g in GameObject.FindGameObjectsWithTag("Canvas")){ g.SetActive(false); //set all other canvases inactive to be sure there aren't multiple active } canvas.gameObject.SetActive (true); //activate the canvas we want guicrewlist = crewmanager.mastercrewlist;//get a local copy DisplayCrew(); DisplayShips (); }
public virtual void Initialize() { if (!initialized) { buttonPrefab = (GameObject)Resources.Load ("Prefabs/UI/TextButton"); attachmentPanelPrefab = (GameObject)Resources.Load ("Prefabs/UI/AttachmentPanel"); crewPanelPrefab = (GameObject)Resources.Load ("Prefabs/UI/CrewPanel"); Transform displayControlParent = transform.FindChild ("Display Controls"); displayParent = transform.FindChild("Display"); selectedObjectName = transform.FindChild ("Status/SelectedUnitName").GetComponent<Text> (); selectedObjectClass = transform.FindChild ("Status/SelectedClassName").GetComponent<Text> (); healthBar = GameObject.Find("Status/HealthBG/Health").GetComponent<Image> (); healthNumbers = GameObject.Find("Status/Health Numbers").GetComponent<Text> (); for (int i = 0; i < displayControlParent.childCount; i++){ displayControls.Add(displayControlParent.GetChild(i).GetComponent<Button>()); string name = displayControls [i].gameObject.name.Substring (8); //first seven characters are 'Display ' displays.Add(displayParent.FindChild(name)); //find the corresponding display to the button to show it int pass = i; //pass this along to avoid referencing the value of the function set displayControls[i].onClick.AddListener (()=> ToggleDisplayTo(pass)); if (name == "Attachments"){ attachmentButtonOrganizer = displays[i].GetComponentInChildren<ButtonOrganizer>(); displayControls[i].onClick.AddListener (()=> DisplayAttachments()); } if (name == "Crew"){ crewButtonOrganizer = displays[i].GetComponentInChildren<ButtonOrganizer>(); displayControls[i].onClick.AddListener (()=> DisplayCrew()); } } initialized = true; } }