我正在尝试制作一个脚本,以便在按下按钮时粒子系统会更改为某种颜色,除了更改粒子颜色之外,它一切正常,当我尝试时会出现以下错误:
NullReferenceException:不要创建自己的模块实例,而是从 ParticleSystem 实例获取它们
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Attack : MonoBehaviour
{
public int MovementDirection = 0;
public int State = 0;
public GameObject attackOrb; //The prefab for our attack hitbox
public Transform Player; //Where the player is
public float R = 0.0F;
public float G = 0.0F;
public float B = 0.0F;
public float A = 1.0F;
private ParticleSystem attackEffect;
// Start is called before the first frame update
void Start()
{
attackEffect = gameObject.GetComponent<ParticleSystem>(); …Run Code Online (Sandbox Code Playgroud)