Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Inventory Pro - uGUI - Performance - Mobile support & More

Discussion in 'Assets and Asset Store' started by jorisshh, Mar 8, 2015.

?

What should I build next?

  1. New currency system

    13.5%
  2. Improved serialization / saving for web

    10.9%
  3. Better properties for items (percentages, base values, etc)

    27.1%
  4. Controller support

    15.1%
  5. Unity 5.1 networking (multiplayer)

    37.0%
  6. More modular build to simplify extending

    25.5%
  7. UFPS Multiplayer (Asset integration)

    11.7%
  8. Core GameKit (Asset integration)

    4.2%
  9. Dialogue system (Asset integration)

    21.1%
  10. Wordpress integration (Asset integration)

    4.2%
Multiple votes are allowed.
  1. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    151
    Hey, just bought the asset, getting 25 errors when importing it, each one is a variation of the following:

    Assets/Standard Assets/Cameras/Scripts/FreeLookCam.cs(7,32): error CS0246: The type or namespace name `PivotBasedCameraRig' could not be found. Are you missing `Devdog.InventoryPro.UnityStandardAssets' using directive?

    Assets/Devdog/General/Managers/Editor/LocalizationManagerEditor.cs(36,57): error CS1501: No overload for method `CreateAsset' takes `2' arguments

    Assets/Devdog/InventoryPro/Scripts/Editor/GameRules/DeprecatedItemDatabase.cs(82,64): error CS1501: No overload for method `CreateAsset' takes `3' arguments

    Assets/Devdog/InventoryPro/Scripts/Managers/Editor/EasySetupEditor.cs(130,90): error CS1501: No overload for method `CreateAsset' takes `3' arguments

    Assets/Devdog/InventoryPro/Scripts/Managers/Editor/InventoryMainEditor.cs(193,54): error CS0117: `ScriptableObjectUtility' does not contain a definition for `CreateAssetChooseSaveFolder'

    Assets/Devdog/InventoryPro/Scripts/Managers/Editor/ScriptableObjectEditorCrud.cs(21,48): error CS1501: No overload for method `CreateAsset' takes `2' arguments
     
    Last edited: Nov 27, 2017
  2. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    175
    For anyone wanting to integrate Inventory Pro and UMA,....... Merry Christmas:

     
  3. xercool

    xercool

    Joined:
    Sep 5, 2017
    Posts:
    90
    It would be better to have a working official demo scene.. :D
    Anyway, thank you for your post in UMA forum thread and there.

    Btw, you could also use 2017.2p2 patched Unity version instead your 2017.1 to get UMA working...

    Merry Xmas
     
  4. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    440
    Where are the UFPS Multiplayer video(s)?
     
  5. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,206
    Thank you thank you thank you!!! :)
     
    SecretAnorak likes this.
  6. xercool

    xercool

    Joined:
    Sep 5, 2017
    Posts:
    90
    Hi guys! What is the current state of Invector TPC's integration?
     
    Last edited: Nov 29, 2017
  7. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    440
    I am using Inventory Pro with UFPS Multi-Player. I am loading the UFPSMP demo scene, the one with the giant yellow chests. I have gotten my character (the default MPheroInventoryPro) to move around, pickup items (displayed as cubes), and show their icons in the inventory. I can drag the icons to different slots, and place them in the "skillsbar". I can even use the consumable items.

    I cannot seem to get the weapons to actually equip on the UFPS player, either from the hotbar, number keys, Q/E, drag onto weapons slots, or any other way. There are no errors in the console. What is going on here?

    Mark
     
  8. xercool

    xercool

    Joined:
    Sep 5, 2017
    Posts:
    90
    up ^
     
  9. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    440
    I give up. No help here, and no current dox/videos. I have removed this asset from my current project. Hopefully, as the support and materials evolve, I will have a use for this asset in a future project.
     
  10. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    151
    Does anyone know how to fix the "inventory is full" issue? There's nothing in my characters inventory but when I try to pick something up, that error comes up.
     
  11. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    Weight can cause this, untick use weight on the inventory ui window where the restrictions are
     
    hopeful likes this.
  12. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    151
    It was a missing script. Thanks anyway.
     
    hopeful likes this.
  13. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    A few people have asked to post an update for RFPS and latest Inv Pro... Here it is :D

    First you need to create a script that can be placed anywhere in your scene or on the player, this is to call functions to enable the weapon or add ammo.
    Add these 2 functions
    Code (CSharp):
    1.  
    2. [SerializeField]
    3.         protected PlayerWeapons m_PlayerWeapons = null;
    4.         public PlayerWeapons PlayerWeapons
    5.         { get {    if (m_PlayerWeapons == null)
    6.                     m_PlayerWeapons = FindObjectOfType<PlayerWeapons>();
    7.                 return m_PlayerWeapons;
    8.             }
    9.         }
    10.  
    11. public virtual void SelectWeaponInventory (int Weapon)
    12.         {
    13.             PlayerWeapons.weaponOrder [Weapon].gameObject.GetComponent<WeaponBehavior> ().haveWeapon = true;
    14.  
    15.             PlayerWeapons.StartCoroutine(PlayerWeapons.SelectWeapon (Weapon));
    16.  
    17.         }
    18.  
    19.         public virtual void AddAmmoInventory (int Weapon, int AmmoToAdd)
    20.         {
    21.             PlayerWeapons.weaponOrder [Weapon].gameObject.GetComponent<WeaponBehavior> ().ammo += AmmoToAdd;
    22.         }
    Also, had to change Inv Pro code to allow to select Layer 0 [Default] for dropping and world layer,
    InventorySettingsDatabase.cs
    Change the Ranges to [Range(0, 31)]

    I'm using the weapons as an item and not a equipment item.

    Weapon Item Type
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Devdog.General;
    5. using Devdog.InventoryPro;
    6.  
    7.  
    8. public partial class Jims_RFPSWeaponItemType : InventoryItemBase
    9. {
    10.     public Devdog.General.AudioClipInfo pickupSound;
    11.     public uint WeaponNumber = 0;
    12.  
    13.  
    14.     public override GameObject Drop ()
    15.     {
    16.         //Reduce or remove an element from the character slot
    17.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    18.         if (skillbarCols.useReferences) {
    19.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    20.                 if (skillbarCols [i].item == this) {
    21.                     skillbarCols.NotifyItemRemoved (this, this.ID, i, 999);
    22.                     skillbarCols [i].item = null;
    23.                     skillbarCols [i].Repaint ();
    24.                 }
    25.             }    
    26.         }
    27.  
    28.         Jims_Menu Jims = FindObjectOfType<Jims_Menu> ();
    29.        
    30. //Select No Gun Once Dropped
    31.         if(Jims.PlayerWeapons.currentWeapon == (int) WeaponNumber)
    32.             Jims.SelectWeaponInventory ((int) 1);
    33.  
    34.         //Set HaveWeapon to false, it will reset to true once re-equip
    35.         Jims.PlayerWeapons.weaponOrder [(int)WeaponNumber].gameObject.GetComponent<WeaponBehavior> ().haveWeapon = false;
    36.  
    37.         return base.Drop();
    38.     }
    39.  
    40.     public override int Use ()
    41.     {
    42.         var used = base.Use ();
    43.         if (used < 0) {
    44.             return used;
    45.         }
    46.  
    47.  
    48.         //Select Weapon to Use
    49.         Jims_Menu Jims = FindObjectOfType<Jims_Menu> ();
    50.        
    51. if (Jims == null)
    52.             return used;
    53.         if (Jims.PlayerWeapons.currentWeapon == (int)WeaponNumber)
    54.             Jims.SelectWeaponInventory ((int)1);
    55.         else
    56.             Jims.SelectWeaponInventory ((int)WeaponNumber);
    57.    
    58.  
    59.  
    60.         //Reduce or remove an element from the character slot
    61.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    62.         if (skillbarCols.useReferences) {
    63.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    64.                 if (skillbarCols [i].item == this) {
    65.                     skillbarCols.SetItem (i, this, true);
    66.                     if (currentStackSize == 0) {
    67.                         skillbarCols.NotifyItemRemoved (this, this.ID, i, 1);
    68.                         skillbarCols [i].item = null;
    69.                         skillbarCols [i].Repaint ();
    70.                     }
    71.                     break;
    72.                 }
    73.             }
    74.         }
    75.  
    76.         if (itemCollection != null) {
    77.             if (currentStackSize <= 0) {
    78.                 itemCollection.NotifyItemRemoved (this, ID, index, 1);
    79.                 itemCollection.SetItem (index, null, true);
    80.             }
    81.  
    82.             itemCollection [index].Repaint ();
    83.         }
    84.  
    85.         return 0;
    86.     }
    87.  
    88.     public override bool PickupItem ()
    89.     {
    90.         bool pickedUp = base.PickupItem ();
    91.         if (pickedUp) {
    92.             transform.position = Vector3.zero;
    93.             AudioManager.AudioPlayOneShot (pickupSound);
    94.         }
    95.         return pickedUp;
    96.     }
    97.  
    98.     public override LinkedList<ItemInfoRow[]> GetInfo()
    99.     {
    100.         var list = new LinkedList<ItemInfoRow[]>();
    101.         list.AddLast(new ItemInfoRow[]{
    102.             //new ItemInfoRow("Weight", (weight * currentStackSize).ToString()),
    103.             //new ItemInfoRow("Required level", requiredLevel.ToString()),
    104.             new ItemInfoRow("Category", category.name),
    105.         });
    106.  
    107.         var extraProperties = new List<ItemInfoRow>();
    108.         foreach (var property in stats)
    109.         {
    110.             var prop = property.stat;
    111.             if (prop == null)
    112.             {
    113.                 continue;
    114.             }
    115.  
    116.             if(prop.showInUI)
    117.             {
    118.                 if(property.isFactor && property.isSingleValue)
    119.                     extraProperties.Add(new ItemInfoRow(prop.statName, (property.floatValue - 1.0f) * 100 + "%", prop.color, prop.color));
    120.                 else
    121.                     extraProperties.Add(new ItemInfoRow(prop.statName, property.value, prop.color, prop.color));
    122.             }
    123.         }
    124.         if(extraProperties.Count > 0)
    125.             list.AddFirst(extraProperties.ToArray());
    126.  
    127.  
    128.         var extra = new List<ItemInfoRow>(0);
    129.         if (extra.Count > 0)
    130.         {
    131.             list.AddFirst(extra.ToArray());
    132.         }
    133.  
    134.         return list;
    135.     }
    136. }
    Ammo
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Devdog.General;
    5. using Devdog.InventoryPro;
    6.  
    7.  
    8.  
    9. public class Jims_RFPSAmmoItemType : InventoryItemBase
    10. {
    11.     public Devdog.General.AudioClipInfo pickupSound;
    12.     public Devdog.General.AudioClipInfo addAmmoSound;
    13.     public uint WeaponNumber = 0;
    14.     public uint AmmoToAdd = 10;
    15.  
    16.  
    17.     public override GameObject Drop ()
    18.     {
    19.         //Reduce or remove an element from the character slot
    20.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    21.         if (skillbarCols.useReferences) {
    22.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    23.                 if (skillbarCols [i].item == this) {
    24.                     skillbarCols.NotifyItemRemoved (this, this.ID, i, 999);
    25.                     skillbarCols [i].item = null;
    26.                     skillbarCols [i].Repaint ();
    27.                 }
    28.             }
    29.         }
    30.  
    31.         return base.Drop();
    32.     }
    33.  
    34.     public override int Use ()
    35.     {
    36.         var used = base.Use ();
    37.         if (used < 0) {
    38.             return used;
    39.         }
    40.  
    41.         Jims_Menu Jims = FindObjectOfType<Jims_Menu> ();
    42.         if (Jims == null)
    43.             return used;    
    44.         Jims.AddAmmoInventory ((int)WeaponNumber, (int)AmmoToAdd);
    45.         AudioManager.AudioPlayOneShot (addAmmoSound);
    46.  
    47.         //Remove 1 from current Stack
    48.         currentStackSize--;
    49.  
    50.         //Reduce or remove an element from the character slot
    51.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    52.         if (skillbarCols.useReferences) {
    53.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    54.                 if (skillbarCols [i].item == this) {
    55.                     skillbarCols.SetItem (i, this, true);
    56.                     if (currentStackSize == 0) {
    57.                         skillbarCols.NotifyItemRemoved (this, this.ID, i, 1);
    58.                         skillbarCols [i].item = null;
    59.                         skillbarCols [i].Repaint ();
    60.                     }
    61.                     break;
    62.                 }
    63.             }
    64.         }
    65.  
    66.         if (itemCollection != null) {
    67.             if (currentStackSize <= 0) {
    68.                 itemCollection.NotifyItemRemoved (this, ID, index, 1);
    69.                 itemCollection.SetItem (index, null, true);
    70.             }
    71.  
    72.             itemCollection [index].Repaint ();
    73.         }
    74.  
    75.         NotifyItemUsed(1, true);
    76.         return 1;
    77.     }
    78.  
    79.     public override bool PickupItem ()
    80.     {
    81.         bool pickedUp = base.PickupItem ();
    82.         if (pickedUp) {
    83.             transform.position = Vector3.zero;
    84.             AudioManager.AudioPlayOneShot (pickupSound);
    85.         }
    86.         return pickedUp;
    87.     }
    88.  
    89.     public override LinkedList<ItemInfoRow[]> GetInfo()
    90.     {
    91.         var list = new LinkedList<ItemInfoRow[]>();
    92.         list.AddLast(new ItemInfoRow[]{
    93.             //new ItemInfoRow("Weight", (weight * currentStackSize).ToString()),
    94.             //new ItemInfoRow("Required level", requiredLevel.ToString()),
    95.             new ItemInfoRow("Category", category.name),
    96.         });
    97.  
    98.         var extraProperties = new List<ItemInfoRow>();
    99.         foreach (var property in stats)
    100.         {
    101.             var prop = property.stat;
    102.             if (prop == null)
    103.             {
    104.                 continue;
    105.             }
    106.  
    107.             if(prop.showInUI)
    108.             {
    109.                 if(property.isFactor && property.isSingleValue)
    110.                     extraProperties.Add(new ItemInfoRow(prop.statName, (property.floatValue - 1.0f) * 100 + "%", prop.color, prop.color));
    111.                 else
    112.                     extraProperties.Add(new ItemInfoRow(prop.statName, property.value, prop.color, prop.color));
    113.             }
    114.         }
    115.         if(extraProperties.Count > 0)
    116.             list.AddFirst(extraProperties.ToArray());
    117.  
    118.  
    119.         var extra = new List<ItemInfoRow>(0);
    120.         if (extra.Count > 0)
    121.         {
    122.             list.AddFirst(extra.ToArray());
    123.         }
    124.  
    125.         return list;
    126.     }
    127. }
    Health
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Devdog.General;
    5. using Devdog.InventoryPro;
    6.  
    7.  
    8. public class Jims_RFPSHealthItemType : InventoryItemBase
    9. {
    10.     public Devdog.General.AudioClipInfo pickupSound;
    11.     public Devdog.General.AudioClipInfo consumeSound;
    12.     public Devdog.General.AudioClipInfo deniedSound;
    13.  
    14.     public float HealthToRestore = 10f;
    15.  
    16.  
    17.     public override GameObject Drop ()
    18.     {
    19.         //Reduce or remove an element from the character slot
    20.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    21.         if (skillbarCols.useReferences) {
    22.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    23.                 if (skillbarCols [i].item == this) {
    24.                     skillbarCols.NotifyItemRemoved (this, this.ID, i, 999);
    25.                     skillbarCols [i].item = null;
    26.                     skillbarCols [i].Repaint ();
    27.                 }
    28.             }
    29.         }
    30.  
    31.         return base.Drop();
    32.     }
    33.  
    34.     public override bool PickupItem ()
    35.     {
    36.         bool pickedUp = base.PickupItem ();
    37.         if (pickedUp) {
    38.             transform.position = Vector3.zero; // Reset position to avoid the user from looting it twice when reloading (reloading temp. enables the item)
    39.             AudioManager.AudioPlayOneShot (pickupSound);
    40.         }
    41.         return pickedUp;
    42.     }
    43.  
    44.     public override int Use ()
    45.     {
    46.         var used = base.Use ();
    47.         if (used < 0) {
    48.             return used;
    49.         }
    50.  
    51.  
    52.         var dmgHandler = PlayerManager.instance.currentPlayer.gameObject.GetComponent<FPSPlayer> ();
    53.         if (dmgHandler != null)
    54.         {
    55.             if (dmgHandler.hitPoints != dmgHandler.maximumHitPoints) {
    56.                 dmgHandler.hitPoints += HealthToRestore;
    57.                 AudioManager.AudioPlayOneShot (consumeSound);
    58.             } else {
    59.                 AudioManager.AudioPlayOneShot (deniedSound);
    60.                 return 0;
    61.             }
    62.         }
    63.  
    64.         //Remove 1 from current Stack
    65.         currentStackSize--;
    66.  
    67.         //Reduce or remove an element from the character slot
    68.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    69.         if (skillbarCols.useReferences) {
    70.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    71.                 if (skillbarCols [i].item == this) {
    72.                     skillbarCols.SetItem (i, this, true);
    73.                     if (currentStackSize == 0) {
    74.                         skillbarCols.NotifyItemRemoved (this, this.ID, i, 1);
    75.                         skillbarCols [i].item = null;
    76.                         skillbarCols [i].Repaint ();
    77.                     }
    78.                     break;
    79.                 }
    80.             }
    81.         }
    82.  
    83.         if (itemCollection != null) {
    84.             if (currentStackSize <= 0) {
    85.                 itemCollection.NotifyItemRemoved (this, ID, index, 1);
    86.                 itemCollection.SetItem (index, null, true);
    87.             }
    88.  
    89.             itemCollection [index].Repaint ();
    90.         }
    91.  
    92.         //  NotifyItemUsed(1, true);
    93.         return 1;
    94.     }
    95.  
    96.     public override LinkedList<ItemInfoRow[]> GetInfo()
    97.     {
    98.         var list = new LinkedList<ItemInfoRow[]>();
    99.         list.AddLast(new ItemInfoRow[]{
    100.             //new ItemInfoRow("Weight", (weight * currentStackSize).ToString()),
    101.             //new ItemInfoRow("Required level", requiredLevel.ToString()),
    102.             new ItemInfoRow("Category", category.name),
    103.         });
    104.  
    105.         var extraProperties = new List<ItemInfoRow>();
    106.         foreach (var property in stats)
    107.         {
    108.             var prop = property.stat;
    109.             if (prop == null)
    110.             {
    111.                 continue;
    112.             }
    113.  
    114.             if(prop.showInUI)
    115.             {
    116.                 if(property.isFactor && property.isSingleValue)
    117.                     extraProperties.Add(new ItemInfoRow(prop.statName, (property.floatValue - 1.0f) * 100 + "%", prop.color, prop.color));
    118.                 else
    119.                     extraProperties.Add(new ItemInfoRow(prop.statName, property.value, prop.color, prop.color));
    120.             }
    121.         }
    122.  
    123.         if(extraProperties.Count > 0)
    124.             list.AddFirst(extraProperties.ToArray());
    125.  
    126.         var extra = new List<ItemInfoRow>(1);
    127.         if (HealthToRestore != null)
    128.         {
    129.             extra.Add(new ItemInfoRow("Restores ", HealthToRestore.ToString() + " Health"));
    130.         }
    131.  
    132.         if (extra.Count > 0)
    133.         {
    134.             list.AddFirst(extra.ToArray());
    135.         }
    136.  
    137.         return list;
    138.     }
    139. }

    Hunger Thirst
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Devdog.General;
    5. using Devdog.InventoryPro;
    6.  
    7.  
    8. public class Jims_RFPSHungerThirstItemType : InventoryItemBase
    9. {
    10.     public Devdog.General.AudioClipInfo pickupSound;
    11.     public Devdog.General.AudioClipInfo consumeSound;
    12.     public Devdog.General.AudioClipInfo deniedSound;
    13.  
    14.     public bool IsHungerItem = true;
    15.     public float HungerToRestore = 100f;
    16.     public bool IsThirstItem = true;
    17.     public float ThirstToRestore = 100f;
    18.  
    19.  
    20.     public override GameObject Drop ()
    21.     {
    22.         //Reduce or remove an element from the character slot
    23.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    24.         if (skillbarCols.useReferences) {
    25.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    26.                 if (skillbarCols [i].item == this) {
    27.                     skillbarCols.NotifyItemRemoved (this, this.ID, i, 999);
    28.                     skillbarCols [i].item = null;
    29.                     skillbarCols [i].Repaint ();
    30.                 }
    31.             }
    32.         }
    33.  
    34.         return base.Drop();
    35.     }
    36.  
    37.     public override bool PickupItem ()
    38.     {
    39.         bool pickedUp = base.PickupItem ();
    40.         if (pickedUp) {
    41.             transform.position = Vector3.zero; // Reset position to avoid the user from looting it twice when reloading (reloading temp. enables the item)
    42.             AudioManager.AudioPlayOneShot (pickupSound);
    43.         }
    44.         return pickedUp;
    45.     }
    46.  
    47.     public override int Use ()
    48.     {
    49.         var used = base.Use ();
    50.         if (used < 0) {
    51.             return used;
    52.         }
    53.  
    54.  
    55.         var dmgHandler = PlayerManager.instance.currentPlayer.gameObject.GetComponent<FPSPlayer> ();
    56.         if (dmgHandler != null)
    57.         {
    58.             if (IsHungerItem) {
    59.                 if (dmgHandler.hungerPoints != dmgHandler.maxHungerPoints) {
    60.                     dmgHandler.hungerPoints += HungerToRestore;
    61.                     AudioManager.AudioPlayOneShot (consumeSound);
    62.                 } else {
    63.                     AudioManager.AudioPlayOneShot (deniedSound);
    64.                     return 0;
    65.                 }
    66.             }
    67.  
    68.             if (IsThirstItem) {
    69.                 if (dmgHandler.thirstPoints != dmgHandler.maxThirstPoints) {
    70.                     dmgHandler.thirstPoints += ThirstToRestore;
    71.                     AudioManager.AudioPlayOneShot (consumeSound);
    72.                 } else {
    73.                     AudioManager.AudioPlayOneShot (deniedSound);
    74.                     return 0;
    75.                 }
    76.             }
    77.  
    78.         }
    79.  
    80.         //Remove 1 from current Stack
    81.         currentStackSize--;
    82.  
    83.         //Reduce or remove an element from the character slot
    84.         var skillbarCols = PlayerManager.instance.currentPlayer.inventoryPlayer.skillbarCollection;
    85.         if (skillbarCols.useReferences) {
    86.             for (uint i = 0; i < skillbarCols.collectionSize; i++) {
    87.                 if (skillbarCols [i].item == this) {
    88.                     skillbarCols.SetItem (i, this, true);
    89.                     if (currentStackSize == 0) {
    90.                         skillbarCols.NotifyItemRemoved (this, this.ID, i, 1);
    91.                         skillbarCols [i].item = null;
    92.                         skillbarCols [i].Repaint ();
    93.                     }
    94.                     break;
    95.                 }
    96.             }
    97.         }
    98.  
    99.         if (itemCollection != null) {
    100.             if (currentStackSize <= 0) {
    101.                 itemCollection.NotifyItemRemoved (this, ID, index, 1);
    102.                 itemCollection.SetItem (index, null, true);
    103.             }
    104.  
    105.             itemCollection [index].Repaint ();
    106.         }
    107.  
    108.         //  NotifyItemUsed(1, true);
    109.         return 1;
    110.     }
    111.  
    112.     public override LinkedList<ItemInfoRow[]> GetInfo()
    113.     {
    114.         var list = new LinkedList<ItemInfoRow[]>();
    115.         list.AddLast(new ItemInfoRow[]{
    116.             //new ItemInfoRow("Weight", (weight * currentStackSize).ToString()),
    117.             //new ItemInfoRow("Required level", requiredLevel.ToString()),
    118.             new ItemInfoRow("Category", category.name),
    119.         });
    120.  
    121.         var extraProperties = new List<ItemInfoRow>();
    122.         foreach (var property in stats)
    123.         {
    124.             var prop = property.stat;
    125.             if (prop == null)
    126.             {
    127.                 continue;
    128.             }
    129.  
    130.             if(prop.showInUI)
    131.             {
    132.                 if(property.isFactor && property.isSingleValue)
    133.                     extraProperties.Add(new ItemInfoRow(prop.statName, (property.floatValue - 1.0f) * 100 + "%", prop.color, prop.color));
    134.                 else
    135.                     extraProperties.Add(new ItemInfoRow(prop.statName, property.value, prop.color, prop.color));
    136.             }
    137.         }
    138.  
    139.         if(extraProperties.Count > 0)
    140.             list.AddFirst(extraProperties.ToArray());
    141.  
    142.         var extra = new List<ItemInfoRow>(1);
    143.         if (IsHungerItem) {
    144.             if (HungerToRestore != null) {
    145.                 extra.Add (new ItemInfoRow ("Restores ", HungerToRestore.ToString () + " Hunger"));
    146.             }
    147.         }
    148.         if (IsThirstItem) {
    149.             if (ThirstToRestore != null) {
    150.                 extra.Add (new ItemInfoRow ("Restores ", ThirstToRestore.ToString () + " Thirst"));
    151.             }
    152.         }
    153.  
    154.         if (extra.Count > 0)
    155.         {
    156.             list.AddFirst(extra.ToArray());
    157.         }
    158.  
    159.         return list;
    160.     }
    161. }
     
    Last edited: Dec 21, 2017
    jrackley likes this.
  14. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    This is to show and hide the mouse, its using rewired input but you can easily swap for unity input or which ever your using.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Rewired;
    5. using Devdog.General.UI;
    6. using BeautifyEffect;
    7.  
    8.  
    9. public class Jims_OpenInventory : MonoBehaviour
    10. {
    11.     private int RewiredPlayerId = 0; // The Rewired player id of this character
    12.     private Rewired.Player Rewiredplayer;
    13.     public MainMenu Menu;
    14.     public Beautify BFX = null;
    15.     public InputControl Input;
    16.     public SmoothMouseLook Mouse;
    17.     public WeaponPivot WeaponPivot;
    18.     public UIWindow Window;
    19.     bool HasShowen = false;
    20.  
    21.  
    22.     void Awake()
    23.     {
    24.         Rewiredplayer = ReInput.players.GetPlayer(RewiredPlayerId);
    25.     }
    26.  
    27.     void Update()
    28.     {
    29.         if (Rewiredplayer.GetButtonDown ("Inventory"))
    30.             HasShowen = !HasShowen;      
    31.  
    32.         if (HasShowen) {
    33.             Window.Show ();
    34.             ShowMouse ();
    35.         } else if (!HasShowen){
    36.             Window.Hide ();
    37.             HideMouse ();
    38.         }
    39.     }
    40.  
    41.     public void ShowMouse()
    42.     {
    43.         BFX.blur = true;
    44.         Mouse.DontControlLockState = true;
    45.         WeaponPivot.enabled = false;
    46.         Cursor.visible = true;
    47.         Cursor.lockState = CursorLockMode.None;
    48.         Input.enabled = false;
    49.     }
    50.  
    51.     public void HideMouse()
    52.     {
    53.         if(!Menu.isActiveAndEnabled)
    54.             BFX.blur = false;
    55.         Mouse.DontControlLockState = false;
    56.         WeaponPivot.enabled = true;
    57.         Cursor.visible = false;
    58.         Cursor.lockState = CursorLockMode.Locked;
    59.         Input.enabled = true;
    60.     }
    61. }
    In SmoothMouseLook I added this;
    Code (CSharp):
    1. public bool DontControlLockState = false;
    2.  
    Changed the following code;
    OnGui function
    Code (CSharp):
    1. #if UNITY_EDITOR || UNITY_WEBPLAYER
    2.     void OnGUI()
    3.     {//lock cursor - don't use OnGUI in standalone for performance reasons
    4.         if(Time.timeScale > 0.0f && FPSPlayerComponent.pauseHidesCursor)
    5.         {
    6.             if (!DontControlLockState) {
    7.                 Cursor.lockState = CursorLockMode.Locked;
    8.                 Cursor.visible = false;
    9.             }
    10.         }
    11.     }
    12.     #endif
    In Update, around line 102
    Code (CSharp):
    1. if (!DontControlLockState) {
    2.                 //Hide the cursor
    3.                 Cursor.lockState = CursorLockMode.Locked;
    4.                 Cursor.visible = false;
    5.             }
    Also in update around line 151
    Code (CSharp):
    1. }else{
    2.  
    3.             if (!DontControlLockState) {
    4.                 //Show the cursor
    5.                 Cursor.lockState = CursorLockMode.None;
    6.                 Cursor.visible = true;
    7.             }
    8.         }        
     
    Last edited: Dec 21, 2017
  15. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    151
    I'm trying to change some player stats using the info here but the InventoryCharacterStat is giving me a using directive error and after adding all the Devdog using directives, it still comes up. Anyone know what the script was changed to?

    I'm assuming it was changed because I can't even find in my project.
     
  16. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    Make sure to use the standard namespace of:

    using Devdog.InventoryPro;

    and

    using Devdog.General; // For general things like triggers, character, etc
     
  17. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    151
    The problem is with this line:

    Code (CSharp):
    1. private InventoryCharacterStat staminaStat;
    InventoryCharacterStat doesn't exist in my project. Is it a script that was renamed? A class or something else? Maybe the docs aren't quite up to date with the current version on the asset store? I've tried adding each Devdog using statement, none of them fix the issue.
     
  18. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    Yes the stat is now an interface called "IStat" in the Devdog.InventoryPro namespace.
     
    hopeful and Atzig like this.
  19. Paxew

    Paxew

    Joined:
    Apr 8, 2014
    Posts:
    30
    Hi

    I have an issue. I'm trying to get a reference to the item that is equipped in a slot.

    I.e. I'm equipping a weapon from the player inventory to the weapon slot. And now I want to get a reference to this weapon that is now in the player's hand. So that I can spawn muzle flashes and other effects on the weapons position.

    I have this code connected to the "OnAddedItem" event. But the "EquippableInventoryItem" passed in does not seem to be the same object as is visible in game.

    Code (CSharp):
    1.  
    2. void OnWeaponEquipped(EquippableInventoryItem item, uint amount, bool cameFromCollection)
    3. {
    4.     Debug.Log("Weapon Equipped");
    5.     WeaponComponent wc = item.GetComponent<WeaponComponent>();
    6.     EquippedWeapon = wc;
    7.     Debug.Log(item.gameObject.name);
    8. }


    In fact when I browse the hierarchy it seems there are two different items created:
    1. Item_pistol_#5_ItemDatabase_PFB(clone)
    2. Item_pistol_#5_ItemDatabase_PFB(clone)(clone)

    The item passed to the OnAddedItem event it the first one. While the item equipped on the player is the second one ...(clone)(clone)

    Should it behave like this? Why are there two items spawned?

    And how do I get ahold of the item that is actually equipped on the player?
     
  20. Paxew

    Paxew

    Joined:
    Apr 8, 2014
    Posts:
    30
    Ok got it. There was a "NotifyItemEquippedVisually" event in the CharacterEquipmentHandler that I missed. From this event I can get the item instance equipped on the player. It is also this equipmentHandler that clones the item.

    Is this cloning necessary? Can't the first object be displayed on the character instead, why make a second identical clone?
     
  21. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    The object is cloned and all relevant components are removed to avoid a 2nd pickup. For example, if the collider remains on the item and the user clicks it he/she would be able to pick up an equipped item again. Plus, in some conditions you may want to add extra components while the item is equipped to the character (such as collision detection scripts when hitting an enemy).
     
  22. Atzig

    Atzig

    Joined:
    Jul 17, 2014
    Posts:
    151
    Just had a chance to try out Changing Character Stats (the hunger bar example) script but this line is giving me a null reference exception:

    Code (CSharp):
    1. staminaStat = PlayerManager.instance.currentPlayer.inventoryPlayer.stats.Get("Default", "Stamina");
    The category and name strings are correct and this error pops up:

    NullReferenceException: Object reference not set to an instance of an object
    Devdog.InventoryPro.UI.StatExperienceUI+<_RepaintInterpolated>c__Iterator0.MoveNext () (at Assets/Devdog/InventoryPro/Scripts/Modules/Stats/UI/StatExperienceUI.cs:131)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Devdog.InventoryPro.UI.StatExperienceUI:Repaint(IStat) (at Assets/Devdog/InventoryPro/Scripts/Modules/Stats/UI/StatExperienceUI.cs:98)
    Devdog.InventoryPro.UI.StatExperienceUI:OnPlayerChanged(Player, Player) (at Assets/Devdog/InventoryPro/Scripts/Modules/Stats/UI/StatExperienceUI.cs:73)
    Devdog.InventoryPro.UI.StatExperienceUI:Start() (at Assets/Devdog/InventoryPro/Scripts/Modules/Stats/UI/StatExperienceUI.cs:55)

    I feel like this is something really simple that I must be overlooking, any ideas?
     
  23. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    163
    Hi
    How i can localize the inventory?
     
  24. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,062
    For some reason I can't get the icon default to show up on the inventory grid any more. It shows on the cast bar as well as the bank window, but the background of my inventory is just blank grey. The icon of an items shows, not the background though. Any ideas?
     
  25. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    Your stat does not appear to have a level set; A stat should have at least 1 level set in the definition (editor). You can leave the level 'blank', but it has to have one.
     
    hopeful and Atzig like this.
  26. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    Inventory Pro isn't currently localized. You can use the built-in localized types (LocalizedString, LocalizedTexture, etc), however, they're not currently used inside Inventory Pro.
     
  27. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    Have you modified the collection slot? (Settings > Default button prefab)? - Make sure all UI references are still valid on the prefab.
     
  28. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    163
    Hi
    can i use two "itemdatabase" (one for each language)?

    can change this in runtime?
     
  29. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    That could actually work, just keep in mind that you'd have to duplicate all items in the database, make sure the ID's remain in sync and then you can change all information of the items to localize them.
     
  30. Carmexx

    Carmexx

    Joined:
    Jul 29, 2014
    Posts:
    63
    Hi, any news of an updated inv pro version that fixes this issue..

    Thanks
     
  31. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    716
    I am having a problem getting my player to automatically pick up items, as in the completed demo scene. I can pick up items with mouse click.

    How does the walk-over pickup process work?

    EDIT: Answer provided on discord.
     
    Last edited: Jan 30, 2018
  32. MaliceA4Thought

    MaliceA4Thought

    Joined:
    Feb 25, 2011
    Posts:
    406
    @SecretAnorak

    Thank you for this.. awesome and I have it working. Quick Question though... Is there a way to start the game with clothing already in the slots in the Character screen and on the character?

    I added a Collection populator to the Character window, and whilst the clothing appears in the Character Window, the actual character is not visible on the screen. I am very new to UMA but wondered if this was due to the character being generated at runtime or some other issue.

    Regards

    M
     
  33. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,062
    I get a similar issue if I stop game play with an equipped weapon in my hand and start it up again. It is still in the slot, but doesn't show up in game. I have to take it off and put it back on again.
     
  34. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    175
    Ah, My little doodad isn't reading the inventory pro slots at start up. Silly mistake, I assumed people would load slots from their own save files and equip items using their own code. I completely forgot about the InvPro serialization. I'll have a look later on and get back to you with a quick fix.
     
    MaliceA4Thought likes this.
  35. MaliceA4Thought

    MaliceA4Thought

    Joined:
    Feb 25, 2011
    Posts:
    406
    any luck with this? :)
    M
     
  36. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    175
    @moria15 @MostHated
    Just to let you know, I've been playing with the InvPro Demo scenes and the exact same thing happens with normal equippables. Apparently it's a known issue. However after having a swift chat with Joris from DevDog I was directed to a solution.

    Grab this script and put it on your "CharacterUI" GameObject and your clothing should magically appear on reload. This little script exposes a ReloadEquipment() method which you can use to..... well...... reload your equipment. I've shoved a delayed call at the front to make sure everything is loaded up first, but you can call this however you like.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Devdog.InventoryPro;
    5. using System.Linq;
    6.  
    7. public class ItemEquipper : MonoBehaviour
    8. {
    9.     private CharacterUI characterUI;
    10.     private uint quantity;
    11.  
    12.     void Start()
    13.     {
    14.         characterUI = GetComponent<CharacterUI>();
    15.         StartCoroutine(DelayedRefresh());
    16.     }
    17.  
    18.     IEnumerator DelayedRefresh()
    19.     {
    20.         yield return new WaitForSeconds(0.1f);
    21.         ReloadEquipment();
    22.     }
    23.  
    24.     public void ReloadEquipment()
    25.     {
    26.         if (characterUI != null)
    27.         {
    28.  
    29.             for (int i = 0; i < characterUI.Count(); i++)
    30.             {
    31.                 var itemToUnEquip = characterUI[i].item as EquippableInventoryItem;
    32.  
    33.  
    34.                 if (itemToUnEquip != null)
    35.                 {
    36.                     quantity = itemToUnEquip.currentStackSize;
    37.                 }
    38.  
    39.                 Debug.Log("Quantity :" + quantity);
    40.                 if (itemToUnEquip != null)
    41.                 {
    42.                     var itemID = itemToUnEquip.ID;
    43.                     var itemToEquip = ItemManager.database.items[itemID] as EquippableInventoryItem;
    44.                     if (quantity != 0)
    45.                     {
    46.                         itemToEquip.currentStackSize = quantity;
    47.                     }
    48.                     characterUI.UnEquipItem(itemToUnEquip, false);
    49.                     characterUI.EquipItem(characterUI.equippableSlots[i], itemToEquip);
    50.                     var itemStats = itemToEquip.stats;
    51.                     characterUI.equippableSlots[i].characterCollection.character.stats.ChangeAll(itemStats, 1f);
    52.                 }
    53.             }
    54.         }
    55.         else
    56.         {
    57.             Debug.LogError("CharacterUI is not assigned! Cant Reload Equipment");
    58.         }
    59.     }
    60. }
    61.  
    This script was derived from: http://forum.devdog.io/viewtopic.php?f=22&t=3107

    Hope that helps.

    Edit 2/2/18:

    This script will work for any equippable, even if you are not using UMA. However, if you look a couple of posts down (after my replacement CollectionPopulator) you'll find a replacement for the SaverLoader that doesn't use an arbitrary time, it actually listens for the UMA being built.
     
    Last edited: Feb 2, 2018
    hopeful likes this.
  37. MaliceA4Thought

    MaliceA4Thought

    Joined:
    Feb 25, 2011
    Posts:
    406
    Hmmmm nope :) Sorry bout this.

    I have the collection populator set with 3 items. I added ItemEquipper script.

    On starting a new game, the items are populated in the Character Inventory BUT the character never appears on screen.

    If I "Use Force Set" then the char appears, but the clothing is not populated, if not, then the items are populated but no character appears.

    If the character doesn't appear then the camera position moves to the location of the head of where the character should be rather than in 3rd person view from behind.

    I am using windows 10, Unity 2017.3.0f3, ootii Caracter controller and inv pro, all integrated in all other aspects without errors.

    I have no console errors and I do see your debug line in the console from your script.

    Regards

    M

    PS.. I have subbed to your patreon because your videos have been awesome help for me so far :) Hope it helps to do loads more for us stupids :)
     
  38. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    175
    Oh yes, I got the same result with the "CollectionPopulator", how odd. The above script works with the "PlayerPrefsCollectionSaverLoader", but not the "CollectionPopulator".

    I've not used the populator before, but you're exactly right. It's mashing data into the UMA before it's finished generating so poor UMA falls over. Easy enough to fix.

    The script below is a direct replacement for the collection populator, the only real difference is that it waits for the UMA to be created before it starts ramming items on there. There is one extra field which you need to supply in the inspector; the "DynamicCharacterAvatar" which should be on your player. Other than that, it will work exactly the same as before. Oh and if you are going to use the collection populator, you wont need the previous script anymore as I've wedged it into this one.

    UMA Replacement for CollectionPopulator:

    Code (CSharp):
    1. using System.Collections;
    2. using Devdog.General.ThirdParty.UniLinq;
    3. using Devdog.General;
    4. using UnityEngine;
    5. using UMA;
    6. using UMA.CharacterSystem;
    7. //
    8. // This script is a direct replacement for the CollectionPopulator when using UMA on a Character Collection.
    9. // The script ensures that any equipment populated is actually placed on the character model.
    10. // Functionality is almost exactly the same, but this component requires the DynamicCharacterAvatar to be defined in the inspector.
    11. // Enjoy - SecretAnorak 2/2/18
    12. //
    13. namespace Devdog.InventoryPro
    14. {
    15.     public class UMACollectionPopulator : MonoBehaviour
    16.     {
    17.         public DynamicCharacterAvatar playerAvatar;
    18.         public ItemAmountRow[] items = new ItemAmountRow[0];
    19.         /// <summary>
    20.         /// This will ignore layout sizes, and force the items into the slots.
    21.         /// </summary>
    22.         public bool useForceSet = false;
    23.         private InventoryItemBase[] _items = new InventoryItemBase[0];
    24.         private CharacterUI characterUI;
    25.         private uint quantity;
    26.         void Awake()
    27.         {
    28.             // Listen for the UMA being generated for the first time.
    29.             playerAvatar.CharacterCreated.AddListener(Populate);
    30.             characterUI = GetComponent<CharacterUI>();
    31.         }
    32.         public void Populate(UMAData data)
    33.         {
    34.             // All the clever stuff from the origonal populator
    35.             _items = InventoryItemUtility.RowsToItems(items, true);
    36.             for (int i = 0; i < _items.Length; i++)
    37.             {
    38.                 _items[i].transform.SetParent(transform);
    39.                 _items[i].gameObject.SetActive(false);
    40.             }
    41.             var col = GetComponent<ItemCollectionBase>();
    42.             if (col == null)
    43.             {
    44.                 DevdogLogger.LogError("CollectionPopulator can only be used on a collection.", transform);
    45.                 return;
    46.             }
    47.             if (useForceSet)
    48.             {
    49.                 for (uint i = 0; i < _items.Length; i++)
    50.                 {
    51.                     col.SetItem(i, _items[i], true);
    52.                 }
    53.             }
    54.             else
    55.             {
    56.                 col.AddItems(_items);
    57.             }
    58.             // Reload equipment after frame is complete to allow the dust to settle
    59.             StartCoroutine(DelayedRefresh());
    60.         }
    61.         IEnumerator DelayedRefresh()
    62.         {
    63.             yield return new WaitForEndOfFrame();
    64.             ReloadEquipment();
    65.         }
    66.         public void ReloadEquipment()
    67.         {
    68.             if (characterUI != null)
    69.             {
    70.                 for (int i = 0; i < characterUI.Count(); i++)
    71.                 {
    72.                     var itemToUnEquip = characterUI[i].item as EquippableInventoryItem;
    73.  
    74.                     if (itemToUnEquip != null)
    75.                     {
    76.                         quantity = itemToUnEquip.currentStackSize;
    77.                     }
    78.                     Debug.Log("Quantity :" + quantity);
    79.                     if (itemToUnEquip != null)
    80.                     {
    81.                         var itemID = itemToUnEquip.ID;
    82.                         var itemToEquip = ItemManager.database.items[itemID] as EquippableInventoryItem;
    83.                         if (quantity != 0)
    84.                         {
    85.                             itemToEquip.currentStackSize = quantity;
    86.                         }
    87.                         characterUI.UnEquipItem(itemToUnEquip, false);
    88.                         characterUI.EquipItem(characterUI.equippableSlots[i], itemToEquip);
    89.                         var itemStats = itemToEquip.stats;
    90.                         characterUI.equippableSlots[i].characterCollection.character.stats.ChangeAll(itemStats, 1f);
    91.                     }
    92.                 }
    93.             }
    94.             else
    95.             {
    96.                 Debug.LogError("CharacterUI is not assigned! Cant Reload Equipment");
    97.             }
    98.         }
    99.     }
    100. }
    101.  
    Hope that helps :)

    PS: Thanks for your support, and trust me I'm just as stupid as the next man, I just like to show off with videos when I finally grasp something. :p
     
    Last edited: Feb 2, 2018
    hopeful likes this.
  39. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    175
    In an effort to come up with a better solution for the PlayerPrefsSaverLoader I've banged together a replacement component which works like the CollectionPopulator above. eg: it listens to the UMA and waits until it's ready:

    UMA Replacement for PlayerPrefsSaverLoader:
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using Devdog.General.ThirdParty.UniLinq;
    4. using UnityEngine;
    5. using UnityEngine.Assertions;
    6. using UMA;
    7. using UMA.CharacterSystem;
    8.  
    9. //
    10. // This script is a direct replacement for the PlayerPrefsCollectionSaverLoader when using UMA on a Character Collection.
    11. // The script ensures that any equipment loaded is actually placed on the character model.
    12. // Functionality is almost exactly the same, but this component requires the DynamicCharacterAvatar to be defined in the inspector.
    13. // You can use this on any collection but it is really only useful on your CharacterUI
    14. // Enjoy - SecretAnorak 2/2/18
    15. //
    16.  
    17. namespace Devdog.InventoryPro
    18. {
    19.     [AddComponentMenu(InventoryPro.AddComponentMenuPath + "Serialization/UMA Player Prefs Collection Saver Loader")]
    20.     public class UMAPlayerPrefsCollectionSaverLoader : CollectionSaverLoaderBase
    21.     {
    22.         public DynamicCharacterAvatar playerAvatar;
    23.         private CharacterUI characterUI;
    24.         private uint quantity;
    25.        
    26.         protected override void Awake()
    27.         {
    28.             // Listen for the UMA being generated for the first time.
    29.             playerAvatar.CharacterCreated.AddListener(Populate);
    30.             characterUI = GetComponent<CharacterUI>();
    31.             base.Awake();
    32.         }
    33.        
    34.  
    35.         public override void SaveItems(object serializedData, Action<bool> callback)
    36.         {
    37.             Assert.IsNotNull(callback, "Callback has to be set ( null given )");
    38.             Assert.IsTrue(serializedData is string, "Serialized data is not string, json collection serializer can only use a JSON string.");
    39.  
    40.             PlayerPrefs.SetString(saveName, (string)serializedData);
    41.             callback(true);
    42.         }
    43.  
    44.         public override void LoadItems(Action<object> callback)
    45.         {
    46.             Assert.IsNotNull(callback, "Callback has to be set ( null given )");
    47.  
    48.             if (PlayerPrefs.HasKey(saveName) == false)
    49.             {
    50.                 throw new SerializedObjectNotFoundException("No serialized data found with key " + saveName);
    51.             }
    52.  
    53.             callback(PlayerPrefs.GetString(saveName));
    54.         }
    55.  
    56.         private void Populate(UMAData data)
    57.         {
    58.             // Reload equipment after frame is complete to allow the dust to settle
    59.             StartCoroutine(DelayedRefresh());
    60.         }
    61.  
    62.         IEnumerator DelayedRefresh()
    63.         {
    64.             yield return new WaitForEndOfFrame();
    65.             ReloadEquipment();
    66.         }
    67.  
    68.         public void ReloadEquipment()
    69.         {
    70.             if (characterUI != null)
    71.             {
    72.  
    73.                 for (int i = 0; i < characterUI.Count(); i++)
    74.                 {
    75.                     var itemToUnEquip = characterUI[i].item as EquippableInventoryItem;
    76.  
    77.  
    78.                     if (itemToUnEquip != null)
    79.                     {
    80.                         quantity = itemToUnEquip.currentStackSize;
    81.                     }
    82.  
    83.                     Debug.Log("Quantity :" + quantity);
    84.                     if (itemToUnEquip != null)
    85.                     {
    86.                         var itemID = itemToUnEquip.ID;
    87.                         var itemToEquip = ItemManager.database.items[itemID] as EquippableInventoryItem;
    88.                         if (quantity != 0)
    89.                         {
    90.                             itemToEquip.currentStackSize = quantity;
    91.                         }
    92.                         characterUI.UnEquipItem(itemToUnEquip, false);
    93.                         characterUI.EquipItem(characterUI.equippableSlots[i], itemToEquip);
    94.                         var itemStats = itemToEquip.stats;
    95.                         characterUI.equippableSlots[i].characterCollection.character.stats.ChangeAll(itemStats, 1f);
    96.                     }
    97.                 }
    98.             }
    99.         }
    100.     }
    101. }
    102.  
    Use this instead of the normal SaverLoader and just give it a reference to your DynamicCharacterAvatar.

    Hope you find this useful.
     
    hopeful likes this.
  40. mwituni

    mwituni

    Joined:
    Jan 15, 2015
    Posts:
    345
    Are there any docs re the asset database this uses? ie. the schema etc

    I couldn't see much in the online manual.

    Also, if users are using this in a networked server-client environment, how are they syncing the asset database with a sql (or other) db on their server?

    Is there any built in support for that? Like an API etc ... ie. to load the assets from the master db, and update master db on asset changes etc?
    ________________________
    Edit: I guess I found some info in the docs (serialization, custom notification messages etc). Are there any examples?, and those that do this - do you have any issues?
     
    Last edited: Feb 19, 2018
  41. phantomy1

    phantomy1

    Joined:
    Sep 7, 2016
    Posts:
    18
    Hey @jorisshh ,
    I love your asset for its flexibility but I could need some help.

    I'm trying to combine Inventory Pro with UFPS and I ran into a few problem. Some due to deprecated scripts / functions and some due to missing or out of date documentation which is a bit frustrating.

    I got errors because of the build target 22 which is Samsung TV and does not exist anymore since 2017.4. Maybe you would like to change that.

    There was also an Error InventoryUFPSInputController which caused it not to show up in the Add Component Menu and could not be dragged onto the player. Removing the spaces in the name like this solved it:
    [AddComponentMenu(InventoryPro.AddComponentMenuPath + "Integration/UFPS/InventoryUFPSInputController")]


    I was following your video for Inv Pro legacy and UFPS because there was nothing newer. The Object Trigger FPS UI script does not seem to exist anymore. I'm using the Trigger UI script on the panel since it looks like the old one. I've set up everything but I can't register it in _Managers because I'm missing the Triggers Section in the Inventory Manager script. How can I set this up?
     
  42. phantomy1

    phantomy1

    Joined:
    Sep 7, 2016
    Posts:
    18
    @jorisshh there seems to be another issue:
    When I duplicate your existing database and save it to a folder outside from the Devdog directory, I get saving issues. As you mentioned in your video you delete all items from the duplicated database so the items list is empty. I did that.

    Then I created the bullet and the pistol items and dragged them into the scene. The connection between item and database was fine. I was able to collect the items by pressing F while in range, even though the hand with the letter "F" I tried to create in the extra panel did not appear. Now I had the bullet item and the pistol item in my inventory when pressing "i".

    Here comes the problem: I save the scene to my folder outside the Devdog directory. I save the project and quit Unity. No I reload Unity and reload the scene. The database is no longer recognised by main editor and the connection between items and database are broken. I get warnings that there are problems like "Missing component on object XY..."

    Obviously the database is not saved or not correctly loaded. Any ideas?
     
  43. RoTru

    RoTru

    Joined:
    Jun 5, 2014
    Posts:
    37
    Like Phantomy1 said UFPS no longer seems to integrate I also get a build target 22 error. I don't know how to fix it.
     
  44. jorisshh

    jorisshh

    Joined:
    Oct 6, 2009
    Posts:
    1,522
    The build target 22 will be removed, as it's removed in the later versions of Unity. Because the script doesn't fully run when turning on / off an integration you may have to manually select a script and click "reimport" to force a recompile with the new Scripting define symbols. To be safe you can reimport the entire /Assets/Devdog folder.
     
  45. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    197
    does the last inventory pro version integrate with the last ufps?Rfps?In this case which one is easier?
    I have to choose one but want to be sure they work with inventory pro actually
     
  46. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    443
    ,man.. this asset is dead and it's a shame since it was the best inventory system and the most easily intrgrable ..even better than inventory pro that is too overwhelming..
    developes was great too and i spoke to him several times by email.. but atm i thibk he left unity for other life goals..
     
  47. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    197
    which asset are you talking is dead? inventory pro or other?
     
  48. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    443
    sorry man i misread the post i was thinknig we were talking about ultimate inventory pro..sorry ..
     
  49. JeffreyStrate

    JeffreyStrate

    Joined:
    Jul 27, 2016
    Posts:
    20
    Assets/Devdog/InventoryPro/Scripts/Integration/DialogueSystem/Other/InventoryDialogueSimpleControllerHandler.cs(14,16): error CS0246: The type or namespace name `SimpleController' could not be found. Are you missing `PixelCrushers.DialogueSystem.Demo' or `PixelCrushers.DialogueSystem.Demo.Wrappers' using directive?
     
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,825
    Hi @JeffreyStrate - If you're using the Dialogue System for Unity 2.x, please follow the short setup instructions here.
     
unityunity