- Home /
Question by
Enodman123 · Sep 20, 2013 at 09:33 PM ·
transform.var typeglobal array
Help on attachment script!
Basically I want to make an array of Transforms so that if a variable (activeMenu), that menu would be active and you could change the current active Attachment(activeChild). I can't really explain it well, but here's my script:
var attachments : Transform[];
var activeMenu : int = -1;
//var skin : GUISkin;
var activeChild = new Array();
var gunLogic : GameObject;
function OnGUI ()
{
var yOffset = 55;
for(a = 0; a < attachments.Length; a++)
{
activeChild[a].length = attachments[a].Length;
//var AttachmentPos[a] = new Vector2(Attachment[a].x, Attachment[a].y)
if (GUI.Button(new Rect(attachments[a].position.x, attachments[a].position.y, 500, 500), attachments[a].gameObject.name))
{
//activeMenu = a;
for(i = 0; i < attachments[activeMenu].childCount; i++)
{
if(GUI.Button(new Rect(0, 100+(yOffset*i), 100, 50), attachments[activeMenu].GetChild(i).name))
activeChild[activeMenu] = i;
}
}
}
I can get it to select the children in the selected Transform, but what I want is a varying transform array to choose from (E.X : SOPMOD M4A1 w/5 attachments vs ACR w/3 attachments). Any help on what I'm doing wrong?
Comment
why you that a "[a]" after activeChild? activeChild[a].length = attachments[a].Length; why thats var activeChild = new Array(); not var activeChild[] : int; ?