Search Unity

Halo Pulse and disable/enable

Discussion in 'Scripting' started by mediamacros, Apr 6, 2009.

  1. mediamacros

    mediamacros

    Joined:
    Dec 14, 2006
    Posts:
    23
    I found a few posts on the forum related to this, but most seem to speculate that this may not be possible. Hoping someone from the mother ship can confirm/deny.

    I have a sphere with a Halo attached so it appears to glow. Looks good, works nicely, and even behaves well on iPhone. Woo hoo!

    Now I want to control it so that when I enable the item it goes from off to on and script the size so I can make the glow pulse. I can't seem to get access to the effect and I can't find a "type" for it.

    If I do this...

    var myHalo : Halo; --invalid type

    GetComponent does not seem to like "Halo" either.

    Is this really off limits/uncontrollable via scripting?
     
  2. amirebrahimi

    amirebrahimi

    Joined:
    Jan 27, 2008
    Posts:
    171
    Unfortunately, by a cursory look through the code it seems that Halo is a built-in component that is not exposed for scripting. However, you can treat it as a Behaviour for adding via code or for enabling/disabling. Since you won't be able to get at the individual color/size fields you probably could create a few discrete variations and store them on prefabs and instantiate specific prefabs.

    Here is an example of adding and controlling via code:
    Code (csharp):
    1.  
    2. function Start() {
    3.     var c : Behaviour = gameObject.AddComponent( "Halo" );
    4.     c.enabled = false;
    5. }
    6.  
    7. function Update () {   
    8.     var c : Behaviour = GetComponent( "Halo" );
    9.     c.enabled = true;
    10. }
    11.