Inventory.adjustInventorySize C# (CSharp) Method

adjustInventorySize() public method

public adjustInventorySize ( ) : void
return void
    public void adjustInventorySize()
    {
        int x = (((width * slotSize) + ((width - 1) * paddingBetweenX)) + paddingLeft + paddingRight);
        int y = (((height * slotSize) + ((height - 1) * paddingBetweenY)) + paddingTop + paddingBottom);
        PanelRectTransform.sizeDelta = new Vector2(x, y);

        SlotGridRectTransform.sizeDelta = new Vector2(x, y);
    }

Usage Example

Example #1
0
    void sizeOfInventoryGUI()
    {
        EditorGUI.indentLevel++;
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.IntSlider(inventoryHeight, 1, 10, new GUIContent("Height"));
        EditorGUILayout.IntSlider(inventoryWidth, 1, 10, new GUIContent("Width"));
        if (EditorGUI.EndChangeCheck())
        {
            inv.setImportantVariables();
            inv.updateSlotAmount();
            inv.adjustInventorySize();
            inv.updatePadding(slotsPaddingBetweenX.intValue, slotsPaddingBetweenY.intValue);
            inv.updateSlotSize(inventorySlotSize.intValue);
            inv.stackableSettings();
        }

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.IntSlider(inventorySlotSize, 20, 100, new GUIContent("Slot Size"));                                                    //intfield for the slotsize
        if (EditorGUI.EndChangeCheck())                                                                                                        //if intfield got changed
        {
            inv.setImportantVariables();
            inv.adjustInventorySize();
            inv.updateSlotSize(inventorySlotSize.intValue);
        }

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.IntSlider(inventoryIconSize, 20, 100, new GUIContent("Icon Size"));                                                    //intfield for the slotsize
        if (EditorGUI.EndChangeCheck())                                                                                                        //if intfield got changed
        {
            inv.updateIconSize(inventoryIconSize.intValue);
        }

        GUILayout.BeginVertical("Box");
        showInventoryPadding = EditorGUILayout.Foldout(showInventoryPadding, "Padding");
        if (showInventoryPadding)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.indentLevel++;
            slotsPaddingLeft.intValue     = EditorGUILayout.IntField("Left:", slotsPaddingLeft.intValue);
            slotsPaddingRight.intValue    = EditorGUILayout.IntField("Right:", slotsPaddingRight.intValue);
            slotsPaddingBetweenX.intValue = EditorGUILayout.IntField("Spacing X:", slotsPaddingBetweenX.intValue);
            slotsPaddingBetweenY.intValue = EditorGUILayout.IntField("Spacing Y:", slotsPaddingBetweenY.intValue);
            slotsPaddingTop.intValue      = EditorGUILayout.IntField("Top:", slotsPaddingTop.intValue);
            slotsPaddingBottom.intValue   = EditorGUILayout.IntField("Bottom:", slotsPaddingBottom.intValue);
            EditorGUI.indentLevel--;
            if (EditorGUI.EndChangeCheck())
            {
                inv.adjustInventorySize();
                inv.updatePadding(slotsPaddingBetweenX.intValue, slotsPaddingBetweenY.intValue);
            }
        }
        GUILayout.EndVertical();


        EditorGUI.indentLevel--;
    }
All Usage Examples Of Inventory::adjustInventorySize