# Install and Configure

{% embed url="<https://youtu.be/OmJbQ3X6slE>" %}

Video that shows Installation and Configuration of the Inventory System Described Below

### Installation Details

&#x20; Version1: **Disabled Link:&#x20;*****Download Link: Inventory System Code Unity Package***&#x20;

**UPDATED - Version 2:** [ **Download Link:  Inventory System Code - Version 2 - Unity Package**](https://utdallas.box.com/s/p7ypi8yk3l4e6hb6ejwxzxwpn89e48d7) **4/11/2020**

#### IMPORTANT;  If you imported InventorySystem prior to using the updated version 2, 4/11/2020, then import the updated code files using the package below.&#x20;

&#x20;    \-  [**Updated Inventory System Code Files - To overwrite Version 1 - files:**](https://utdallas.box.com/s/v4o36lcfsmoyz4ig9tuuvdyidezacxar)  **4/13/2020**

**Step 1.  IMPORTANT:** Prior to Importing the Package:  **DELETE the following Scripts in your project:  PickUp.cs, GameData.cs**\
You will import new versions of these files, so you need to delete the old versions to insure you don't end up with 2 instances of a script.  If the package scripts are in a different folder structure than they are in your project, then they won't get overwritten and you'll have 2 versions of the scripts, it may be difficult to tell which one needs to be deleted, so do that as the first step.

**Step 2.  Import Custom Package:** In your Unity project, select top menu:  Assets >  Import Package > Custom Package:   Select from downloads:  InventorySystem\_S20\_v1

You should see the items listed in the image below.  Submit using the Import Button

![Import Custom Package](https://1604956922-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0-KLgOacVpbicrqehO%2F-M4AE4to9gHsf8xcHTC8%2F-M4AK1OsLFEoU0Yx7xzI%2FScreen%20Shot%202020-04-05%20at%2012.11.25%20PM.png?alt=media\&token=7a508951-42b1-48da-82c6-3aa9c779f751)

### Configuration Details - Fix any Code Errors

**IMPORTANT FIX POSSIBLE CODE ERRORS:**  See [Details for Fix](https://kdoore.gitbook.io/cs2335/cs2335_f20/inventory-system/inventory-scriptableobject/updated-inventorysystem/pickup-gamedata-mods) for Possible Errors in **`PlayerStats.cs`** due to inconsistent variable name:  score / Score vs totalScore / TotalScore in **`GameData.cs`**

```csharp
//FIX CODE IN PlayerStats.cs
private void UpdateDisplay()
    {
        scoreText.text = "Score: " + GameData.instanceRef.Score; //replace .TotalScore
        healthText.text = "Health: " + GameData.instanceRef.Health;
    }
```

### **Step 1: BeginScene - GameData issues:** &#x20;

* In BeginScene, make sure the **GameManager** gameObject has no errors on the **GameData.cs script component.** (**TO FIX: Remove component, re-add**)
* **Create an Inventory ScriptableObject:** named: **`Inventory.`** ( no additional configuration needed for GameInventory scriptableObject )
* **Add GameInventory** scriptableObject **to the GameData.cs component** on GameManager.

![](https://1604956922-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0-KLgOacVpbicrqehO%2F-M4AKdiPk-dOCGfRNTqC%2F-M4ALPvfEyUB2NNEVx0D%2FScreen%20Shot%202020-04-05%20at%2012.17.44%20PM.png?alt=media\&token=2fd208ed-8690-400f-b277-3d985995aff5)

![](https://1604956922-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0-KLgOacVpbicrqehO%2F-M4AKdiPk-dOCGfRNTqC%2F-M4ALsao9eInRljjaSua%2FScreen%20Shot%202020-04-05%20at%2012.19.48%20PM.png?alt=media\&token=f32d8056-12b1-4b21-82e1-655be976b42d)

### Step 2 - Add Prefabs to Canvas in Scene

In the Prefabs Folder, find the **ISimple\_Inventory** and the **BtnAddDiamond** prefabs\
Drag both prefabs onto the Canvas.  Position the objects by setting the **Rect-Transform Anchors** so they are constrained and visible in the SceneView\
as shown in the image below

![](https://1604956922-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0-KLgOacVpbicrqehO%2F-M4AKdiPk-dOCGfRNTqC%2F-M4ANVxAFkeEdFkAGxQk%2FScreen%20Shot%202020-04-05%20at%2012.27.00%20PM.png?alt=media\&token=fb1159c2-705a-44b3-9a1e-a0b18d46896d)

### Edit ISimple\_Inventory Prefab: Attach InventoryDisplay.cs Script

**Edit the InventoryDisplay Prefab** by Attaching InventoryDisplay.cs to the Top-Level Panel of ISimple\_Inventory Prefab.  **Save Project and Scene.**  Note in the image below: the InventoryDisplay.cs component has been added.  Also note the use of a Grid Layout Group Component.

![](https://1604956922-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0-KLgOacVpbicrqehO%2F-M4AKdiPk-dOCGfRNTqC%2F-M4AOeoVlmpeS4pVM98m%2FScreen%20Shot%202020-04-05%20at%2012.31.37%20PM.png?alt=media\&token=37e42968-e29e-4654-99e0-be3739f44d2f)

### Play the Scene to Verify Installation / Configuration&#x20;

When playing the scene, you should be able to click the btnAddDiamond button and see items added to 1-cell of the ISimple\_Inventory prefab.  Clicking the item within the inventory should remove an item from the grid.  If you play the scene with GameData selected in the Hierarchy, you should be able to see the inventory scriptableObject dynamically changing to show items added and removed from the inventory display.
