- Home /
Question by
dapa5678 · May 19, 2015 at 09:03 AM ·
javascriptprogramminginventorycodepageinventory system
Inventory code not working [JS]
Hey guys I have been following this tutorial on how to make a simple inventory https://www.youtube.com/watch?v=QlF6t5gI5es . Everything works fine on my end except the texture doesn't change when I pick up an item. Like it does on the video my code
var gridpos : Vector2 = new Vector2(10,2);
var gridsize : Vector2 = new Vector2(323,410);
var wood : int = 0;
var inventoryskin : Texture;
var showgui : boolean = false;
var inventoryopen : AudioClip;
var grid : Texture[];
var myGUI :GUISkin;
private var gridvalue:float= -1;
static var itemid : String[]=["wood"];
static var itemAmount : int[] =[0];
var itemtexture = new Texture[inventory.itemid.Length];
function Start(){
var textures : Object[] = Resources.LoadAll("itemicons",Texture2D);
for(var i =0; i <textures.Length; i++)
{
itemtexture[i]=textures[i];
}
}
function Update () {
var theinventory :inventoryadditem =GetComponent(inventoryadditem);
var textures :inventoryadditem =GetComponent(inventoryadditem);
if(Input.GetKeyDown("i")){
showgui = !showgui;
if(showgui == true)
GameObject.Find("player").GetComponent("FirstPersonController").enabled = false;
if(showgui == false)
GameObject.Find("player").GetComponent("FirstPersonController").enabled = true;
}
if(Input.GetKeyDown("i"))
theinventory.NewItem();
textures.NewItem();
}
function OnGUI () {
if(showgui == true)
{
GUI.skin = myGUI;
GUI.BeginGroup(Rect(50,200,600,500),inventoryskin);
gridvalue = GUI.SelectionGrid(Rect(gridpos.x,gridpos.y,gridsize.x,gridsize.y),gridvalue,grid,3);
GUI.EndGroup();
}
}
how do I fix this thx
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Inventory Drop Function Problem 1 Answer
How to optimize this script and add items imediately without grids 0 Answers
GetItemByID error 0 Answers
Having scripts interact 1 Answer