- Home /
Cannot reference "Halo" type in Javascript
I have a Halo component attached to a child GameObject, but trying to use the Javascript
var h = GetComponentInChildren(Halo);
Gives
Assets/Selection.js(8,42): BCE0005: Unknown identifier: 'Halo'.
On the child GameObject itself, I can do this:
var test : Component = GetComponent("Halo");
Debug.Log("direct type: " + test.GetType());
which prints
direct type: UnityEngine.Behaviour
I expected to get the specific Halo type back (like UnityEngine.BoxCollider) rather than the generic Behavior.
Is there something "special" about Halo, where it doesn't have its own type? If so, what's the proper method for referencing it in a similar manner to GetComponentInChildren?
Using Unity 3.5.0f5, MonoDevelop 2.8.2
Answer by Eric5h5 · Mar 25, 2012 at 09:02 PM
Not everything is exposed to scripting; Halo is one of those things that isn't.
Simple enough; is there any way to tell what is and isn't available, besides "just try it"? Looking in the docs for "Halo" and "Lens Flare" (another light effect), I couldn't see anything that would indicate one would be available, and another wouldn't.
Well, usually just look into the scripting reference. At the left side you get a complete alphabetically sorted list of all classes / structs available. Well there are some undocumented classes that can also be used, but you shouldn't rely on them since they could be removed at any time.
There's also a hierarchical list
Using the documentation search, "lensflare" comes up with results and "halo" doesn't, so that's a pretty clear indication.
Answer by Rodmanix · Nov 19, 2013 at 08:15 PM
Maybe this is new functionality since this question but it is now accessible.
var halo : Behaviour;
halo = GetComponent("halo");
Your answer
Follow this Question
Related Questions
How to change camera on trigger enter unity 5 1 Answer
how to disable a script component 1 Answer
[CLOSED] Halo position 0 Answers
Adjusting size of a halo in C# 0 Answers
Set a Prefab's variable when you instantiate it, but before it calls Awake? 2 Answers