compound control sliders not working for me

hello,

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;
}

however, i am getting the following errors;

Assets/NewBehaviourScript.js(12,17): BCE0005: Unknown identifier: ‘CompoundControls’.

i cannot get any of the default generic out of the box slider scripts to work in my Unity. I was wondering if it was because i had trial version?

any clues to help me discover the problem would be great!

thanks in advance

AA

You have to rename the script to CompoundControls, then you should be good.

As-is now, lines like:
CompoundControls.LabelSlider (screenRect, rgb.r, 1.0, “Red”);

Would have to read:
NewBehaviorScript.LabelSlider (screenRect, rgb.r, 1.0, “Red”);

Hope that clears things up for you, just so happens I ran into the same problem last night.

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.

sorry for the tardy reply but thanks so much for the help!

thanks for the tip about the code /code formatting, will use from now on.


AA

I hope reviving this thread ain’t an issue.

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;
}

Welcome to the forum, EternaSky!

The text you need to put in CompoundControls.js is the second code sample on this manual page.

oh i see where I read wrongly.
Thanks :slight_smile: