Well I’ve tried every thing I know (which isn’t much considering I’m a noobie) to fix this. Can some one help me fix the Error. Here is my code ItemClass:
public class ItemClass
{
public var name : String;
public var description : String;
public var icon : Texture2D;
public var itemType : ItemType;
enum ItemType{None, Weapon, Other}
}`
Inventory Script
import System.Collections.Generic;
var playerInventory : List. = new List.();
var scrollView : Vector2;
var Weapon : ItemClass;
var equipped : boolean = false;
function Update () {
}
function OnGUI ()
{
GUILayout.BeginArea(Rect(Screen.width - 100,0,100,100));
scrollView = GUILayout.BeginScrollView(scrollView, GUILayout.Width(100), GUILayout.Height(100));
for(var x = 0; x < playerInventory.Count; x++)
{
GUILayout.BeginHorizontal();
if(GUILayout.Button(playerInventory[x].icon))
{
playerInventory.RemoveAt(x);
return;
}
GUILayout.Box(playerInventory[x].name);
GUILayout.EndHorizontal();
GUILayout.Box(playerInventory[x].description);
}
GUILayout.EndScrollView();
GUILayout.EndArea();
if(GUI.Button(Rect(Screen.width/2 - 25, Screen.height - 50,50,50), Weapon.icon)){
}
}`
AddItem Script:
import System.Collections.Generic;
var loot : ItemClass[];
var Inventory : Inventory;
function Start () {
Inventory = GetComponent("Inventory") as Inventory;
}
function OnGUI () {
GUILayout.BeginArea(Rect(0,0,60,60));
if(GUILayout.Button("loot"))
{
giveloot();
}
GUILayout.EndArea();
}
function giveloot() {
for(var x = 0; x < loot.length; x++)
Inventory.playerInventory.Add(loot[x]);
}
These are the three scripts I am using to make an Inventory. Any help would be appreciated. Thanks in Advanced.