Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Resources.Load and animations

Discussion in 'Scripting' started by vtchalakov, May 15, 2017.

  1. vtchalakov

    vtchalakov

    Joined:
    Nov 9, 2013
    Posts:
    13
    Hello all, I have a question regarding Resources.Load with prefabs. I have a prefab that has a particle system on it, and underneath there is a point light. This prefab also has an animator where I am controlling that point light (by changing the light's intensity from 0 to 8 for a create animation, and 8 to 0 for a destroy animation).

    I load this prefab using Resources.Load, however I immediately get the following warnings from Unity when I try to instantiate it:
    • The referenced script on this Behaviour (Game Object '<null>') is missing!
    • The referenced script on this Behaviour (Game Object 'Point Light') is missing! (I get this twice)
    I can't seem to understand exactly what is going on. Is this an issue with loading the prefab? Or with instantiating the asset. I will note that while I do get these warnings, everything functions without issue.

    My thoughts were that perhaps the animation is trying to access the Point Light before it is created?
     
  2. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,572
    Are there any missing components on your prefab. Like an unassigned MonoBehaviour?
     
  3. vtchalakov

    vtchalakov

    Joined:
    Nov 9, 2013
    Posts:
    13
    No missing components on the prefab, and no missing components on the children. When I click on the console warning, it points me directly to my instantiate call. I'm going to try setting these objects up in an object pool to see if the same happens.