Search Unity

The referenced script on this Behaviour (Game Object '<null>') is missing!

Discussion in 'Visual Effect Graph' started by PixelPockets, Jun 27, 2022.

  1. PixelPockets

    PixelPockets

    Joined:
    Sep 7, 2020
    Posts:
    143
    OK this one is driving me nuts..

    I created a VFX Graph. Dragged the VFX Graph into the game hierarchy, which created a game object. I then made that game object a prefab. I deleted the prefab from the hierarchy.

    I created a script that is attached to this prefab. The script looks like this -

    Code (CSharp):
    1. public class ParticleEffect : MonoBehavior
    2. {
    3.   public VisualEffect vEffect;
    4.   private void Awake()
    5.   {
    6.     vEffect = GetComponent<VisualEffect>();
    7.     vEffect.playRate = 800;
    8.   }
    9. }
    The only thing I am doing with this visual effect is setting the play rate.

    Now, I can drag this prefab from the asset window into the game hierarchy and the particle effect works perfectly fine in the scene view. What I can't do is instantiate that prefab from another script. It gives me this warning -

    "The referenced script on this Behaviour (Game Object '<null>') is missing!"

    EDIT: It does, in fact, instantiate the object. It just doesn't spawn any particles. What's even weirder is that if I click on the game object in the hierarchy during gameplay, the particles will start to function properly. Shouldn't it start to play right away? I even tried using the
    Play()
    function in code, and it still won't play until I click on the game object..


    What am I doing wrong here? Why do I need to click on the game object that spawns in order to start the particle effect?
     
    Last edited: Jun 27, 2022
  2. jeremysmitherman

    jeremysmitherman

    Joined:
    May 28, 2017
    Posts:
    6
    For anyone googling and getting this as the first result, try closing the VFX graph editor when playing and this goes away. Nasty little bug.