The board administrator and developer will be on vacation until the end of July. Therefore replies will be slower than usual.

Reload Equipment

User avatar
PeterBibinin
Posts: 162
Joined: Mon Oct 24, 2016 10:55 pm

Reload Equipment

Postby PeterBibinin » Thu Jul 13, 2017 2:45 pm

Hi there! Below you can get working script for Reload Equipment.

Note: This script should execute after SaveLoad

Code: Select all


public CharacterUI characterUI; //Assign in Inspector
private uint quantity;


public void ReloadEquipment()
        {
            if (characterUI != null)
            {

                for (int i = 0; i < characterUI.Count(); i++)
                {
                    var itemToUnEquip = characterUI[i].item as EquippableInventoryItem;


                    if (itemToUnEquip != null)
                    {
                        quantity = itemToUnEquip.currentStackSize;
                    }

                    Debug.Log("Quantity :" + quantity);
                    if (itemToUnEquip != null)
                    {
                        var itemID = itemToUnEquip.ID;
                        var itemToEquip = ItemManager.database.items[itemID] as EquippableInventoryItem;
                        if (quantity != 0)
                        {
                            itemToEquip.currentStackSize = quantity;
                        }
                        characterUI.UnEquipItem(itemToUnEquip, false);
                        characterUI.EquipItem(characterUI.equippableSlots[i], itemToEquip);

                    }
                }
            }
            else
            {
                Debug.LogError("CharackterUI is not assigned! Cant Reload Equipment");
            }
        }
Waiting for sunrise
----------------------------------------------
Try make world beter ;]
----------------------------------------------
BAZINGA !

hugo.canané
Posts: 125
Joined: Sat Jul 02, 2016 12:28 am

Re: Reload Equipment

Postby hugo.canané » Thu Jul 13, 2017 6:41 pm

MY BRO BIG BOSS
Sos Survival - In steam - Thanks DevDog

http://store.steampowered.com/app/528970

hugo.canané
Posts: 125
Joined: Sat Jul 02, 2016 12:28 am

Re: Reload Equipment

Postby hugo.canané » Fri Jul 21, 2017 5:36 pm

What api is need for stats please all is good but if you have item stats if you quit and joins items reload but no stats ,

thansk for help
Sos Survival - In steam - Thanks DevDog

http://store.steampowered.com/app/528970


Return to “Share custom components”

Who is online

Users browsing this forum: No registered users and 1 guest