- Home /
Array with multiple variables in Inspector
First off, Hello everyone !
I am having problems generating a customizable field in the Inspector for an array with multiple types. Basically, this is the mental image: type | param1 | param2
type | param1 | param2
type | param1 | param2
If it helps more, think of the animation array, where the (guessed) pseudo code would be along the lines of:
public struct sAnimation { string Name; int FrameStart; int FrameEnd; };
public sAnimation[] AnimList;
anim1 | FrameStart1 | FrameEnd1 anim2 | FrameStart2 | FrameEnd2 anim3 | FrameStart3 | FrameEnd3
I am trying to make a manager-like-wrapper-thing for some GUI menus (basically simple implementation for game designers where they'd just blindly add scripts and edit some fields).
My code is as follows:
public enum eGUIClickEvent { GUIClickEvent_GoToPreviousMenu = 0, GUIClickEvent_GoToNextMenu = 1 };
public struct sGUIClickEvent
{
eGUIClickEvent ClickEvent;
string Parameter;
};
public sGUIClickEvent[] ClickEvents;
As you can guess, I am trying to use messaging to call functions specified in the 'Parameter' value. Depending on 'ClickEvent', it would either use different functions or params and such.
My problem ? The arrays (and implicitly the customizable array fields) don't show up in the Inspector. How can I "replicate" the animation array to use for such a case ?
Thanks in advance!
Answer by sharpshot124 · Apr 01, 2012 at 04:48 PM
the best answer i can give u is that u have 3 different arrays (for the pseudo code example) in java script it would be like:
var name : String[];
var frameStart : int[];
var frameEnd : int[];
var listNum : int = 0;
where listNum will be a counter integer variable that would be used such as:
function GetAnimLength (animName : String){
listNum = 0;
for(nameTest : String in name){
if(animName == nameTest)
return (frameStart[listNum] - frameEnd[listNum]);
listNum ++;
}
this means that so long as each element corresponds with the same element in the other variables then it should work fine meaning like name[0] and frameStart[0] and FrameEnd[0] will go together, and then name[1] and frameStart[1] and FrameEnd[1] will go together the 2, then 3 and so on