RectTransform panelTransform; // The transform component of the panel #endregion Fields #region Methods /** * Add a single turn effect to this effect panel and update the UI * * Arguments * - TurnEffect newEffect - The effect to add */ public void AddTurnEffect(Effect newEffect) { GameObject box; // Box to instantiate EffectBoxScript boxScript; // The script attached to the box box = Instantiate<GameObject>(BoxPrefab); // Instantiate UI element box.GetComponent<RectTransform>().SetParent(panelTransform); // Set the parent box.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1); box.GetComponent<RectTransform>().anchorMin = new Vector2(1, 1); box.GetComponent<Image>().sprite = newEffect.GetIcon(); // Set the icon box.GetComponent<EffectToolTipScript>().EffectToolTipPanelObject = EffectToolTipPanel; box.GetComponent<EffectToolTipScript>().EffectToolTipTextObject = EffectToolTipPanelText; box.GetComponent<EffectToolTipScript>().AttachEffectText(newEffect.GetDescription()); // Give description boxes.Add(box); // Add this game object to the list of boxs boxScript = box.GetComponent<EffectBoxScript>(); // Get Box Script boxScript.AddEffect(newEffect); // Add the turn effect to the box updateUI(); }