Invo Problem (with error)

Okay so i added Angels invo and i am getting two errors shown below

InvalidCastExeption: cannot cast from source type
inv2.GUI() (at Assets/_scripts/inv2.js:59)

I have (3) of those errors it says all (3) are the SAME errors exact same

Thanks you and have a good day i help to get help soon :slight_smile:

Post the script too !

Okay

Inv2 Script

//Èíâåíòàðü
var inventory : Array;

var doWindow : boolean = false;

//Êàðòèíêà ïóñòîãî ñëîòà
public var emptyTex : Texture;

//Ðàçìåð èíâåíòàðÿ (êîë-âî ÿ÷ååê)
public var inventorySizeX = 4;
public var inventorySizeY = 5;

//Ðàçìåð ÿ÷åéêè ïî âûñîòå è øèðèíå
var iconWidthHeight = 40;

//Ïðîñòðàíñòâî ìåæäó ñëîòàìè (â X è Y)
var spacing = 4;

//Ïîçèöèÿ èíâåíòàðÿ
public var offSet = Vector2( 100, 100 );


// Íàçíà÷àþòñÿ ïî ÷åë÷êàì êíîïîê ìûøêè (ñì. Update())
private var itemImage : Texture2D;


//êëàññ è ïðåäìåòàõ èíâåíòàðÿ
class InventoryItem
{
   //Ýòîò ïóíêò îòíîñèòñÿ ê Ãåéìîáúåêòó
   var worldObject : GameObject;
   //Òî, êàê ìû áóäåì âèäåòü åãî â èíâåíòàðå
   var texRepresentation : Texture2D;
}

// Ñîçäàåì èíâåíòàðü
function Awake()
{
   inventory = new Array(inventorySizeX);
   
    for( var i = 0; i < inventory.length; i ++ )
    {
        inventory[i] = new Array(inventorySizeY);
    }
}


function OnGUI() {

   var texToUse : Texture2D;
   var currentInventoryItem : InventoryItem;

    //Ïåðåõîä ÷åðåç êàæäóþ ñòðîêó
    for( var i = 0; i < inventory.length; i ++ )
    {
        // è êàæäûé ñòîëáåö
        for( var k = 0; k < inventory[i].length; k ++ )
        {
           texToUse = emptyTex;
           currentInventoryItem = inventory[i][k];
           
            //Åñëè åñòü ïóíêò â I-é ñòðîêè è K-ãî ñòîëáöà, íàðèñîâàòü
            if( inventory[i][k] != null )
            {
                texToUse = currentInventoryItem.texRepresentation;
            }
           
			var it = GUI.Button( new Rect( offSet.x+k*(iconWidthHeight+spacing), offSet.y+i*(iconWidthHeight+spacing), iconWidthHeight, iconWidthHeight ), texToUse );
            GUI.Button( new Rect( offSet.x+k*(iconWidthHeight+spacing), offSet.y+i*(iconWidthHeight+spacing), iconWidthHeight, iconWidthHeight ), texToUse );
			var w : int = 0;
	        var h : int = 0;
			if (it){// (inventory[i][k]==!null){

			//òóò áóäåò äðîï
			Debug.Log("YES!!!!!!!!!!!!!!!!!!!");
			}
        }
    }
}

function AddItem( item : InventoryItem )
{
    //Ïðîõîä ïî êàæäîé ñòðîêå
    for( var i = 0; i < inventory.length; i ++ )
    {
        // è êàæäîìó ñòîëáöó
        for( var k = 0; k < inventory[i].length; k ++ )
        {
           //Åñëè ïîçèöèÿ ïóñòàÿ, äîáàâèòü íîâûé ïóíêò è âûõîä èç ôóíêöèè
           if( inventory[i][k] == null )
            {
                inventory[i][k] = item;
                return;
            }
        }
    }   
   
    //Åñëè èíâåíòàðü ïîëîí, òóò ÷òî-íèòü äåëàåì  
}

function AddItem( worldObject : GameObject, texRep : Texture2D )
{
   var newItem = new InventoryItem();

	newItem.worldObject = worldObject;
	newItem.texRepresentation = texRep;
      
   AddItem( newItem );   
}

[END CODE][/COLOR][/COLOR]

[COLOR="navy"]
Item Script

[COLOR="blue"][CODE]

public var InventoryIcon :  Texture2D;
public var ItemDescription : String;
public var ItemClass : String;
public var defence : int;
public var damage : int;

var doWindow : boolean = false;

function OnMouseOver() {
doWindow=true;
}
function OnMouseExit() {
doWindow=false;
}

function OnGUI() {

if (doWindow)
GUI.Window (0, Rect (110,10,200,80), DoWindow, "Info");
}

function OnMouseDown() {
	var inv = FindObjectOfType(inv2);
	inv.AddItem( gameObject, InventoryIcon );
	Destroy(this.gameObject);
	Debug.Log("item picked");
}

	function DoWindow (windowID : int) {
	GUI.Label (new Rect(5, 15, 200, 25), "Item:" + ItemDescription);
	GUI.Label (new Rect(5, 30, 90, 25), "Class:" + ItemClass);
	GUI.Label (new Rect(5, 45, 90, 25), "Defence:" + defence);
	GUI.Label (new Rect(5, 60, 90, 25), "Damage:" + damage);
	}
	

[END CODE][/COLOR][/COLOR]


[COLOR="magenta"]DraggableGUIElement script

[CODE]

using UnityEngine;

using System.Collections;

public class DraggableGUIElement : MonoBehaviour
{
    [System.Serializable]
    public class Border
    {
        public float minX, maxX, minY, maxY;
    }

    public Border border;

    Vector3 lastMousePosition;

    void OnMouseDown()
    {
        lastMousePosition = GetClampedMousePosition();
    }

    Vector3 GetClampedMousePosition()
    {
        Vector3 mousePosition = Input.mousePosition;
        mousePosition.x = Mathf.Clamp(mousePosition.x, 0f, Screen.width);
        mousePosition.y = Mathf.Clamp(mousePosition.y, 0f, Screen.height);

        return mousePosition;
    }

    void OnMouseDrag()
    {
        Vector3 delta = GetClampedMousePosition() - lastMousePosition;

        delta = Camera.main.ScreenToViewportPoint(delta);

        transform.position += delta;

        Vector3 position = transform.position;
        position.x = Mathf.Clamp(position.x, border.minX, border.maxX);
        position.y = Mathf.Clamp(position.y, border.minY, border.maxY);

        transform.position = position;

        lastMousePosition = GetClampedMousePosition();
    }
}

[END CODE][/COLOR]

Legand - sorry for the reply to the PM. It was a little terse. Recently, I have had a few people that have been asking for help and were not listening to my suggestions or solutions. I answered that PM on my iPhone and misunderstood who it was from. This system works, (tho’ admittedly it’s a bit stale), but it does need to added into your game’s system by you. If I really get enough interest, I can put it up higher on my priority list to get something that can be put up on the asset store and is more useable and standalone.

Take a look at this thread here on the Unity3D forums:

And this thread on my site:
http://theantranch.com/Unity/Entries/2010/5/17_Basic_Inventory_%26_Looting_System.html

If you get this:

This is the answer:

Frankly, I should fix that line of code for 3.0, or at least mention is on the site… I’ll try to get to it Monday.

PPS: Code tags on this forum are [ code ] and [ / code ] without the spaces. Or the # icon in the advanced posting page.

What text editor are you using? I’m curious about all of the:
//Åñëè åñòü ïóíêò â I-é ñòðîêè è K-ãî ñòîëáöà, íàðèñîâàòü

Are these your notes in non-roman characters?

oh okay :slight_smile: btw its still saying it and i jhave No club at all why it is lol

I am just opening it in Unitsite or whatever you call it

Are you renaming anything?

I should have no elements names Inv2:

Could you be mixing two sets of code by accident?

I’ll send you a new updated package tomorrow or Tuesday with the correction to the casting error:

lootTable = FindObjectOfType (LootTable) as LootTable;	//	Create a reference to the Loot Table

Or you can correct the lines that error out with the above line of code.

I’ll also have to admit that I’m not looking incredibly close at your errors, as the only casting errors in my Unity-iPhone 1.7 code was this line:
lootTable = FindObjectOfType (LootTable);

… which in 3.x, oddly, needed to be cast to a type with:
lootTable = FindObjectOfType (LootTable) as LootTable;

Your case of:
InvalidCastExeption: cannot cast from source type
inv2.GUI() (at Assets/_scripts/inv2.js:59)

… doesn’t make sense in the context of my code.

There must be some other issue going on.

Could you be mixing two sets of code by accident? Or have you re-written or renamed anything?

Give me the link to RE download it please something must have happend

This page:
http://theantranch.com/Unity/Entries/2010/5/17_Basic_Inventory_%26_Looting_System.html

Has this link:
http://theantranch.com/tutorialsupport/downloads/InventoryAndLoot/InventoryAndLootSystem.zip

And you must change this line of code in LootableObject.js:
Line 23 lootTable = FindObjectOfType (LootTable); // Create a reference to the Loot Table

to:
Line 23 lootTable = FindObjectOfType (LootTable) as LootTable; // Create a reference to the Loot Table

This should work.

kk ill try it

the package wont import…

Try these steps:

The scripts should also be importable on their own… You can ignore the graphics, models, textures and materials.

like i said it WONT let me import it it makes a Ping sound and no windows open nothing…

Dunno then… You got me! That was a fresh download from the site. And it imported fine and worked as expected.

The new version 2.0 will be available on the asset store soon. There will be free textures, models and materials to go along with the project. There will be comprehensive tutorial videos as well. That might help.

isn’t that the one you were gonna have me beta test?

Yes, but if you can’t import this package, you won’t be able to import the beta.

Okay i got it imported and when press I a invo window opens but not will like a grid like thing and when i dragged a chest onto the screen and click on it it dont loot it :frowning: