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’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

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,548
    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.