// ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        protected void Initialize()
        {
            if (this.playerHUDController == null)
            {
                this.playerHUDController = this.GetComponentInParent <PlayerHUDController>();
            }
        }
示例#2
0
        // ----------------------------------------------------------------------------------------------------
        #endregion

        #region Initialization
        // ----------------------------------------------------------------------------------------------------
        /// <summary>
        /// Called upon awaking this behavior.
        /// </summary>
        private void Awake()
        {
            if (instance != null && instance != this)
            {
                Destroy(this.gameObject);
                Debug.LogWarning("[HUDManager] More than one instance of HUDManager found!");
                return;
            }
            instance    = this;
            hasInstance = true;


            // Create Panels
            var playerPanel = GameObject.Instantiate(this.playerPanelPrefab, this.playerOnePanel, false);

            playerPanel.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            this.playerOneController = playerPanel.GetComponent <PlayerHUDController>();

            playerPanel = GameObject.Instantiate(this.playerPanelPrefab, this.playerTwoPanel, false);
            playerPanel.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            this.playerTwoController = playerPanel.GetComponent <PlayerHUDController>();

            // Handle Player registration
            PlayerManager.Instance.OnPlayerRegistered   += this.RegisterPlayer;
            PlayerManager.Instance.OnPlayerUnregistered += UnregisterPlayer;
        }