Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Modify Halo By Script

Discussion in 'Scripting' started by Nice2k, Feb 12, 2015.

  1. Nice2k

    Nice2k

    Joined:
    Oct 28, 2014
    Posts:
    2
    Hi,

    As far as I know is there no Halo class available.

    I can get the component by String, e.g.

    Code (CSharp):
    1. Component halo = gameObject.GetComponent( "Halo" );
    How can I modify the parameters of the Component by String, like the "size" or the "color" of the halo?

    Best Regards,
    Patrick
     
  2. Megolas

    Megolas

    Joined:
    Apr 6, 2013
    Posts:
    25
    Halo is more than a component - it is an object type of its own (If you wish to understand this completely, learn inheritance).
    So, if you write:
    Code (CSharp):
    1. Halo haloVariable = GetComponent<Halo>();
    You can then access haloVariable as a halo as well, and not just a component, by writing haloVariable.Color = whatever
     
  3. Nice2k

    Nice2k

    Joined:
    Oct 28, 2014
    Posts:
    2
    do I need some imports (usings), because Halo as class is not present. (This is the reason why I'm accessing this component by String. All components as far as I know are inherted from Component)