Esempio n. 1
0
        private void CreateConstructionButton(OrderContent orderContent, int index)
        {
            // instanciate button
            var instanciatedButton = UnityEngine.Object.Instantiate(_prefabConstructionButton);

            instanciatedButton.transform.SetParent(_parentConstructionButton, false);

            // set building type on construction button
            OrderButton orderWrapper = instanciatedButton.GetComponent <OrderButton>();

            orderWrapper.SetContent(orderContent);

            Assert.IsNotNull(orderWrapper, "Prefab construction prefab misses a UI_ConstructionButton component.");

            _orderButtons[index] = orderWrapper;
        }
Esempio n. 2
0
        /// <summary>
        /// Find each UI_OrderWrapper inside _ordersLineParent.
        /// </summary>
        private void InitializeOrdersField()
        {
            Assert.IsNull(_orders, "_orders field is not null. Can't initialize it.");

            _orders = new OrderButton[_ordersLineParent.Length][];

            for (int i = 0; i < _ordersLineParent.Length; i++)
            {
                int childCount = _ordersLineParent[i].childCount;

                _orders[i] = new OrderButton[childCount];

                for (int j = 0; j < childCount; j++)
                {
                    _orders[i][j] = _ordersLineParent[i].GetChild(j).GetComponent <OrderButton>();
                }
            }
        }