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. Dismiss Notice

Build error on script AddComponent . Help!

Discussion in 'Scripting' started by CoCoNutti, Mar 23, 2015.

  1. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Hi,

    Forum not accepting this post in the help section for some reason.

    Anyway, only when I go to build, I receive the following error:
    The error points to the following line in AdComponent.cs found in Scripts>Actions:

    Code (csharp):
    1.  
    2. store.Value = UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent (((GameObject)gameObject.Value), "Assets/State Machine/Scripts/Actions/GameObject/AddComponent.cs (29,19)", className.Value);
    3.  
    I'm not sure how to fix it and would appreciate any help.

    Thanks.
     
  2. Fajlworks

    Fajlworks

    Joined:
    Sep 8, 2014
    Posts:
    344
    CoCoNutti likes this.
  3. GeorGios1

    GeorGios1

    Joined:
    Aug 10, 2016
    Posts:
    3
    I use this.AddComponent<Rigidbody>(); which I have no Idea why it doesnt work. Maybe unity removed that feature
     
  4. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    "this" is the current class or MonoBehaviour. It's a component. You want to use "gameObject" to reference the owning GameObject.