Search Unity

getComponent

Discussion in 'Scripting' started by dacloo, Jun 13, 2006.

  1. dacloo

    dacloo

    Joined:
    Jun 30, 2005
    Posts:
    469
    I have a character.
    A child object of this character is a pivot containing a particle emitter.

    Code (csharp):
    1. private var pe : particleEmitter = GetComponentInChildren(particleEmitter);
    2.  
    Why does type "particleEmitter" not denote a valid type?
    I guess I am interpreting it wrong.

    Where do I enter the name of the child object it needs to look in?
    And what type should it be?

    Thanks
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    ParticleEmitter is with a capital 'P'.
     
  3. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    The thing to get used to is when you are referring to a type or class, it is uppercase (ParticleEmitter) but, as it looks like you were thinking, when you are referring to a component of your object directly, it is lowercase because it is technically a variable of your object(myObject.particleEmitter).

    But making any GetComponent calls or any type declarations require the uppercase frist letter.

    Hope that made sense. ;-)
    -Jeremy
     
  4. dacloo

    dacloo

    Joined:
    Jun 30, 2005
    Posts:
    469
    doh! That was stupid of me :)
    Must be the hot weather.

    Thanks for the tips!