コード例 #1
0
ファイル: GameManager.cs プロジェクト: MaddJhin/Holdout
    /* Function: Gives each element of the control UI a reference to it's relevant unit
     * Parameters: None
     * Returns: None
     */
    public static void AssignLoadoutUI(GameObject UI_playerPanel, InputManager IM)
    {
        Button[] b = UI_playerPanel.GetComponentsInChildren<Button>();                                       // Gets each button in the canvas
        int i;

        for (i = 0; i < playerLoadout.Length; i++)
        {
            if (playerLoadout[i] != null)
            {
                PlayerUnitControl param = playerLoadout[i].GetComponent<PlayerUnitControl>();     // Cache the character controller to be added

                Debug.Log("Unit Active: " + playerLoadout[i].activeInHierarchy);
                Debug.Log("UI PARAM: " + param);

                b[i].onClick.AddListener(delegate { IM.SetTarget(param); });                                // Add a new listener with the cached controller
                HpBarManager hpData = b[i].GetComponent<HpBarManager>();
                param.hpBar = hpData;
            }
        }
    }