Search Unity

Survival Inventory Pro - Add Item to Inventory

Discussion in 'Scripting' started by Skyfall106, Nov 14, 2017.

  1. Skyfall106

    Skyfall106

    Joined:
    Mar 5, 2017
    Posts:
    132
    Hello! So I bought this asset on the asset store and I've set it up but I am trying to setup my resource manager (Below) With my Inventory System. There's a Script AddItemToInventory that could work but I don't quite understand it. Any help would be appreciated. Thanks!

    Resource Manager:

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.UI;
    6. public class ResourceManager : MonoBehaviour {
    7.  public Canvas canvas;
    8.  public Text wood;
    9.  public int Wood;
    10.  public Text stone;
    11.  public int Stone;
    12.  
    13.  public void AddWood(int cnt){
    14.   Wood += cnt;
    15.   wood.text = Wood.ToString(); // yes, I changed the variable name, but you can use whatever you prefer.
    16.  }
    17.  public void AddStone(int cnt){
    18.   Stone += cnt;
    19.   stone.text = Stone.ToString(); // yes, I changed the variable name, but you can use whatever you prefer.
    20.  }
    21.  public static ResourceManager instance;
    22.  void Awake() {
    23.   if(instance == null) instance = this;
    24.   else if(instance != this) Destroy(gameObject);
    25.  }
    26.  
    27. }
    28.  
    AddItemToInventory:

    [removed]
     
    Last edited by a moderator: Nov 17, 2017
  2. RoMax92

    RoMax92

    Joined:
    May 29, 2017
    Posts:
    135
    I feel pain about this. Write this instead:
    Code (CSharp):
    1. public Text woodText;
    2. public int woodItems;
    3. public Text stoneText;
    4. public int stoneItems;
    5.  
     
    Fajlworks likes this.
  3. Skyfall106

    Skyfall106

    Joined:
    Mar 5, 2017
    Posts:
    132
    Lol, Ok
     
  4. Skyfall106

    Skyfall106

    Joined:
    Mar 5, 2017
    Posts:
    132
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You should be contacting the author of the asset about this.

    Also, if AddItemToInventory is a script that is part of the asset itself (an asset you already said you had to pay for), you have no business posting their code on here without the author's permission.
     
  6. Skyfall106

    Skyfall106

    Joined:
    Mar 5, 2017
    Posts:
    132
    I'm sorry, THe code wont work with just that script and the author is inactive.
     
  7. Skyfall106

    Skyfall106

    Joined:
    Mar 5, 2017
    Posts:
    132