- Home /
Remove Items and Item Tooltips
guys help me with these script, i tried making Tooltips for my items in this inventory system ive made but it doesnt show up, or shows up but not in a way i wanted it to be, also OnGUI doesnt support on LostFocus on a certain GUI Element, i would've wanted to implement those for item removal since i cant think of other ways to do it..
var itemArray:Texture[] = new Texture[16];
var itmNm:String[] = new String[16];
var itmDes:String[] = new String[16];
var bagCapacity:int = 16;
var bag:Rect;
var ScrollPosition:Vector2 = Vector2.zero;
var dcString:String;
var dsString:String;
var cString:String;
var sString:String;
var cmTex:Texture2D;
var smTex:Texture2D;
var dmTex:Texture2D;
var mX:float;
var mY:float;
var msX:int =32;
var msY:int =32;
var page:int=0;
var cPage:String[] = ["Equipments","Items","Misc"];
var toggleRemove:boolean = false;
var toggleBag:boolean = false;
var lostFocus:boolean = false;
function Start(){
cmTex = dmTex;
}
function Update()
{
if(Input.GetKeyDown("i"))
{
Togglebag();
}
}
function OnGUI()
{
mX = Input.mousePosition.x;
mY = Input.mousePosition.y;
GUI.DrawTexture(Rect((mX-msX/2),((Screen.height-mY)-msY/2+msY/2),msX,msY),cmTex);
if(toggleBag)
{
bag = GUI.Window(0,bag,bagWindow,cPage[page],"Box");
GUI.depth = 0;
}
}
function bagWindow(id:int)
{
GUI.BeginGroup(Rect(0,0,34,165));
if(GUI.Button(Rect(8,20,32,32),"B")){page = 0;}//main inventory for equipments
if(GUI.Button(Rect(8,55,32,32),"C")){page =1;}//items and consumables
if(GUI.Button(Rect(8,90,32,32),"D")){page =2;}//quest items and stuff..
GUI.EndGroup();
switch(page)
{
case 0:
ScrollPosition = GUI.BeginScrollView(Rect(35,20,115,215),ScrollPosition,Rect(0,0,0,430));
EquipmentGrid();
GUI.EndScrollView();
break;
case 1:
ScrollPosition = GUI.BeginScrollView(Rect(35,20,115,215),ScrollPosition,Rect(0,0,0,275));
//ItemGrid(); for consumables function
GUI.EndScrollView();
break;
case 2:
ScrollPosition = GUI.BeginScrollView(Rect(35,20,115,215),ScrollPosition,Rect(0,0,0,275));
//MiscGrid(); quest items function
GUI.EndScrollView();
break;
}
GUI.Label(Rect(5,230,120,25),"Gold:");
GUI.DragWindow();
}
function EquipmentGrid()
{
for (var i=0;i<itemArray.Length;i++)
{
if(GUI.Button(Rect(0,0+i*(25+2),100,25),GUIContent(itmNm[i],itemArray[i],itmDes[i]),"Box"))
{
if((itemArray[i]!= null)&&(Event.current.button == 0)&& toggleRemove == false)
{
useItem();
}
else if(Event.current.button == 1 && itemArray[i]!= null && toggleRemove ==false)
{
toggleRemove = true;
cString = itmNm[i];
sString = itmNm[i];
cmTex = itemArray[i];
smTex = itemArray[i];
dcString = itmDes[i];
dsString = itmDes[i];
itemArray[i]=null;
itmNm[i] = null;
itmDes[i] = null;
}
else if((itemArray[i]== null)&&(Event.current.button == 0)&&toggleRemove == true)
{
itemArray[i] = cmTex;
itmNm[i] = cString;
itmDes[i] =dcString;
cmTex = dmTex;
smTex = null;
sString = null;
dcString = null;
toggleRemove = false;
}
else if((itemArray[i]!=null)&&(Event.current.button==0)&&toggleRemove == true)
{
smTex = itemArray[i]; //Stored Texture = Texture Array [i]
itemArray[i] = cmTex; //Texture Array [i] get current Texture
cmTex = smTex; //set current Texture to stored Texture
sString = itmNm[i]; //Stored String = Equipment Description[i]
itmNm[i] = cString; //Equipment = current String
cString = sString; //current String = stored String
dsString = itmDes[i];
itmDes[i] = dsString;
dcString = dsString;
}
Debug.Log(toggleRemove);
}
}
}
function useItem()
{
Debug.Log("use functionality in imageArray[i]");
}
function Togglebag()
{
if(toggleBag)
{
toggleBag = false;
}else{
toggleBag = true;
}
}
thanks in advance :D
"nobody cares" (quotes because it's false) because it's really hard to read that code. I can't even find where you're trying to display the tooltip. Try showing us just the relevant code ins$$anonymous$$d of the entire thing double-spaced.
I just formatted your code (see we do care, or as FN$$anonymous$$ sang "We Care Alot"!), but I agree with Louis, you may want to just post the relevant code portions, as this is still quite a wall of text
=]