i am doing some testing on the compound control sliders. From the online documentation i am directly c+ping this script into a new java script and trying to run it;
/* RGB Label Slider Compound Control */
var myColor : Color;
function OnGUI () {
myColor = RGBLabelSlider (Rect (10,10,200,20), myColor);
}
function RGBLabelSlider (screenRect : Rect, rgb : Color) : Color {
rgb.r = CompoundControls.LabelSlider (screenRect, rgb.r, 1.0, "Red");
screenRect.y += 20; // <- Move the next control down a bit to avoid overlapping
rgb.g = CompoundControls.LabelSlider (screenRect, rgb.g, 1.0, "Green");
screenRect.y += 20; // <- Move the next control down a bit to avoid overlapping
rgb.b = CompoundControls.LabelSlider (screenRect, rgb.b, 1.0, "Blue");
return rgb;
}
Tip: when you include scripts/code in your posts, either use the Code button when drafting your post, or manually wrap the script chunk in a code block ([ code ]…[ /code ], without the spaces) for better formatting. I’ve edited your (Agent A’s) post so you can see an example.
I facing the exact issue as Agent A.
And renaming the .js to whichever reference I use (for simplicity) CompoundControls.LabelSlider doesnt work.
The filename is CompoundControls.js
I get the following error:
…/Scripts/CompoundControls.js(10,34): BCE0019: ‘LabelSlider’ is not a member of ‘CompoundControls’.
The following is the same code block
/* RGB Label Slider Compound Control */
var myColor : Color;
function OnGUI () {
myColor = RGBLabelSlider (Rect (10,10,200,20), myColor);
}
function RGBLabelSlider (screenRect : Rect, rgb : Color) : Color {
rgb.r = CompoundControls.LabelSlider (screenRect, rgb.r, 1.0, "Red");
screenRect.y += 20; // <- Move the next control down a bit to avoid overlapping
rgb.g = CompoundControls.LabelSlider (screenRect, rgb.g, 1.0, "Green");
screenRect.y += 20; // <- Move the next control down a bit to avoid overlapping
rgb.b = CompoundControls.LabelSlider (screenRect, rgb.b, 1.0, "Blue");
return rgb;
}