Im Trying to make a inventory System But the Texture Does Not Want To Change
#pragma strict
var arrayGrid = 0;
static var inventoryNewItemAdded = -1;
var theInventory : Inventory_GUI;
var theTextures : Player_Inventory;
//Icons
var blankIcon : Texture;
var theNewItem : Texture;
function Start () {
theInventory = GetComponent(Inventory_GUI);
theTextures = GetComponent(Player_Inventory);
}
function newItem () {
if (Inventory_Add_Item.inventoryNewItemAdded> -1) {
theNewItem = theTextures.itemTexture(Inventory_Add_Item.inventoryNewItemAdded);
if (arrayGrid < theInventory.gridsTexture.length) {
if (theInventory.gridsTexture[arrayGrid].image == blankIcon) {
//adding Item
theInventory.gridsTexture[arrayGrid].image = theNewItem;
arrayGrid = 0;
Inventory_Add_Item.inventoryNewItemAdded = -1;
}
else if (theInventory.gridsTexture[arrayGrid].image != blankIcon) {
arrayGrid += 1;
}
}
}
}
#pragma strict
// Items
static var itemID : String[] = ["9mm Ammo", "9mm Pistol", "Arrow", "Baton", "Battery", "Long Bow","Boxers",
"Cross Bow", "File", "Flash Light", "Hat", "ID Badge", "Jumper", "Knife",
"M4 Ammo", "M4", "Metal", "Rock", "Shiv", "Shoes", "Shotgun", "Shotgun Shells",
"Socks", "Spoon", "String", "Gards Knife", "Uniform", "Police Uniform", "Wire",
"Wood", "Can"];
static var itemsPlayerAmount : int[] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var itemTexture = new Texture [Player_Inventory.itemID.length];
function Start () {
var textures : Object[] = Resources.LoadAll("Item_Icons", Texture2D);
for (var i = 0; i < textures.length; i++)
{
itemTexture _= textures*;*_
* }*
* }*
Please format this using 10101 button
– getyour411Dont Know What That Means
– GoGamingJoeI did it. Next time, select your code when you're writing your question, and hit the button with 1 and 0 in the toolbar.
– BerengerThanks do you know what's wrong with the code
– GoGamingJoeYou don't even say what line is causing the error, it should be written in the logs window. I suppose it is : var itemTexture = new Texture [Player_Inventory.itemID.length]; And I think the problem is because of Player_Inventory.itemID.length, try to put "10" instead for example and see if there still is the error.
– KiraSensei