// Use this for initialization void Start() { // Create a new list for the containers which enter our range m_containersInRange = new List <WORLD_Container>(); // Get reference to the grid layout m_inventoryGridLayout = m_inventorySlotSubPanel.GetComponent <GridLayoutGroup>(); m_containerGridLayout = m_containerSlotSubPanel.GetComponent <GridLayoutGroup>(); // Set the cell sizes initially LIB_Inventory.AdjustGridCells(m_inventoryPanel, m_inventoryGridLayout, m_horSlotsToDisplay); LIB_Inventory.AdjustGridCells(m_containerPanel, m_containerGridLayout, m_horSlotsToDisplay); // Layout the slots to begin with, initiallizes and populates array also m_slotArrayInventory = LIB_Inventory.LayoutSlots(m_curBagSize, m_slotObject, m_inventorySlotSubPanel); if (m_slotArrayInventory.Length > 0) { LIB_Inventory.ForceGridLayoutGroupRebuild(m_inventorySlotSubPanel.GetComponent <RectTransform>()); m_slotHighlighter.transform.position = m_slotArrayInventory[0].SLOTOBJ.transform.position; m_slotHighlighter.GetComponent <RectTransform>().sizeDelta = new Vector2(LIB_Inventory.CELL_DIMENSION * 1.1f, LIB_Inventory.CELL_DIMENSION * 1.1f); } }
// Update is called once per frame void Update() { // Do container distance and icon display cycling (every 0.1 seconds the list is checked) if (m_containersInRange.Count > 0) { if (m_closestContainterCheckCoroutine == null) { m_closestContainterCheckCoroutine = containerIconCheck(); StartCoroutine(m_closestContainterCheckCoroutine); } } // Accomodate resolution change in inventory if (m_lastWidth != Screen.width) { // Set the cell sizes on rescale LIB_Inventory.AdjustGridCells(m_inventoryPanel, m_inventoryGridLayout, m_horSlotsToDisplay); LIB_Inventory.AdjustGridCells(m_containerPanel, m_containerGridLayout, m_horSlotsToDisplay); // Rebuild the inventory grid on adjust LIB_Inventory.ForceGridLayoutGroupRebuild(m_inventorySlotSubPanel.GetComponent <RectTransform>()); // Adjust the highlighter slot position on resize m_slotHighlighter.transform.position = m_slotArrayInventory[0].SLOTOBJ.transform.position; m_slotHighlighter.GetComponent <RectTransform>().sizeDelta = new Vector2(LIB_Inventory.CELL_DIMENSION * 1.1f, LIB_Inventory.CELL_DIMENSION * 1.1f); } m_lastWidth = Screen.width; }