recognize a gui object?

I’ve got an array of objects…

some are meshes, and some are gui objects

how can I tell what kind of objects they are?

I need to manipulate the color so will need to do it differently depending on what they are

thanks!

Check if the object is of a given class.

yes, that was my thought- I just haven’t been able to figure out the function/method/syntax is needed to get what class the object is in - still too much of a noob :frowning:

the closest thing I’ve found so far is GetClassName(object), but it is an editor class function, so no luck so far

less cryptic help would be GREATLY appreciated :slight_smile:

How are you storing references to “GUI objects”? I ask that as UnityGUI doesn’t offer UI elements themselves as “objects” you can reference so I’m not clear on how you’d do that or what you’re storing in your array. Or is it that you’re storing references to GUIText and/or GUITexture objects?

And when you say you’re storing a “mesh” what do you mean by that? An in-scene mesh (aka a GameObject)? Or is it a prefab mesh? Other?

Less cryptic information about how/what you’re doing would greatly help! :wink: :stuck_out_tongue: :slight_smile:

For what you want to attempt, you need to check out the Mono / MSDN documentation as that is where the class stuff etc comes from.
Unity builds upon that base for its specific UnityEngine and UnityEditor functionality.

In this specific case, the answer should the operator is, found at http://msdn.microsoft.com/en-us/library/scekt9xw(VS.71).aspx

you need to copy the url manually, the board is incapable to handle ( ) in urls and url tags :frowning:

arrrrghhh! terminology is half the battle, isn’t it!

at this point, my array is just the names of objects- just strings

when I fetch them, I use GameObject.Find to turn the names into GameObjects that I can use generic functions on

so I might have a box change colors, prompting the user to pick it, then a sphere change colors, prompting the user to pick it, then an image (a GUITexture) change colors, prompting the user to pick it, etc
the array tells me which object is next

since geometry has materials and GUI controls don’t, I have to know which script/function to call to make the color changes happen on the next object as soon as the current object was picked

I suppose I could make another array storing the object type, or use a naming convention on the GUI controls, but half the purpose of the exercise is to learn how to script with JavaScript, so I may be attempting to do things that are best done differently- all part of my learning process

(so far I’m not using any prefabs)

Then only you can figure out how you want to sift out “meshes” from “GUI objects”, all you have are strings and we don’t know what those are in your world. You can do a GameObject.Find() but that will only tell you if a GameObject exists in the world with that name, that may or may not reference a “GUI object” (a particular UI control drawn by a script attached to a game object where that script has an OnGUI function defined).

Use the names as GameObject look-ups. From there you can look for your own custom script component that draws UI elements (GameObject.Find() to get the GameObject, then GetComponent() off the GO to look for the script). If you find a game object, and it has your GUI script (or some flavor of it), then you know it’s a “GUI control” in your world. If not you can assume it’s a mesh/model.

Or something like that… :stuck_out_tongue: Am I making enough sense there? If not then let us know and we’ll keep at it!

ok, I think I’m beginning to get a feel for this… using a GUITexture object had me side-tracked, because it is an object I can see in the hierarchy- but as you reminded me, something like a button only exists as a few lines of script.

So I think I’ll try making empty GOs to represent non-mesh “objects” and put my generic script on them as well as the meshes. In that script, I’ll have a var that tells me what kind of “object” it represents so it will know which version of the functions to use. :slight_smile:

thanks so much for your patience and help!