How can I be solving these Errors in Unity 5 and adding these components?

1
using UnityEngine;
using System.Collections;

public class RandomParticlePoint : MonoBehaviour
{
    [Range(0f, 1f)]
    public float normalizedTime;

    void OnValidate()
    { 
        particleSystem.Simulate(normalizedTime, true, true);
    }
}

The Error also appears when I start the program

    
asked by anonymous 07.04.2015 / 03:51

1 answer

1

How to resolve the error

This error occurs because you did not convert when you opened this project in Unity 5.

When you open a project from an older version of Unity, it will say that there are some obsolete things and ask if you want to convert to the latest version. When it does not convert it maintains the old structure, which eventually results in error in some cases.

The error you have marked is how to work with the particle system.

In the past you could make a call from him directly as you marked in yellow, now you need to call GetComponent.

  

link

Your code would look like this

using UnityEngine;
using System.Collections;

public class RandomParticlePoint : MonoBehaviour 
{
    [Range(0f, 1f)]
    public float normalizedTime;


    void OnValidate()
    {
        GetComponent<ParticleSystem>().Simulate (normalizedTime, true, true);
    }
}

Adding the component

For your code to work GetComponent the object you hung your script on must also have the component you are requesting.

Here is a video teaching how to work with the Particle System link

    
08.04.2015 / 15:19