public void Initialise(IComponentController shield) { Shield = (ShieldController)shield; ShieldNameLabel = transform.Find("ShieldName").GetComponent <Text>(); ShieldNameLabel.text = Shield.Name; TargetButton = transform.Find("TargetButton").GetComponent <Button>(); TargetButton.onClick.AddListener(StartTargeting); ArcButton = transform.Find("ArcButton").GetComponent <Button>(); ArcButton.onClick.AddListener(ToggleArc); DirectionSlider = transform.Find("DirectionSlider").GetComponent <Slider>(); DirectionSlider.onValueChanged.AddListener(SetDirection); DirectionSlider.value = Shield.GetRotationProportion(); DirectionSlider.interactable = (Shield.GetTarget() == null); RechargeToggle = transform.Find("RechargeToggle").GetComponent <Toggle>(); RechargeToggle.isOn = Shield.Recharging; RechargeToggle.onValueChanged.AddListener(SetRecharging); // store text color so we can set back labelColor = ShieldNameLabel.color; buttonColor = TargetButton.GetComponentInChildren <Text>().color; }
public void StopTargeting(ShipController ship) { // set color back ShieldNameLabel.color = labelColor; TargetButton.GetComponentInChildren <Text>().color = buttonColor; DirectionSlider.interactable = (Shield.GetTarget() == null); }