1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    Dismiss Notice

GetComponent(TrailRenderer).active ??? HELP :)

Discussion in 'Scripting' started by AgentChaos, Apr 13, 2012.

  1. AgentChaos

    AgentChaos

    Joined:
    Jan 10, 2011
    Messages:
    33
    this.GetComponent(TrailRenderer).active=false;

    why its deactivate my player and not the trail ??
    Thanks..:D
     
  2. diablo

    diablo

    Joined:
    Jan 3, 2011
    Messages:
    736
    Post some more of your code so we can get a better picture.
     
  3. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Messages:
    1,217
    Because you are ignoring compiler warnings.

    Component.active is deprecated and should not be used with COMPONENTS. Component.active is/was a shortcut for "GameObject.active", hence if you have read the documentation (or MonoDevelop tooltips or the compiler warnings) you would know that this property is not listed in the docs and deprecated in MonoDevelop.

    Only "Component.enable" is documented and the only one which should be used, but that's something that the warning tells you too iirc.
     
  4. AgentChaos

    AgentChaos

    Joined:
    Jan 10, 2011
    Messages:
    33
    Thanks. So I can activate..How can I deactivate the trail?
     
  5. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Messages:
    1,217
    Did you even read what I said? Component.active should not be used with Components, only with GameObjects. It's deprecated.

    To enable/disable a component, you must use Component.enable (set it to true to enable and false to disable)