Search Unity

Resolved Build Error > The type or namespace name 'VisualEffect' could not be found

Discussion in 'Visual Effect Graph' started by LunarFuror, Oct 31, 2020.

  1. LunarFuror

    LunarFuror

    Joined:
    Jan 18, 2018
    Posts:
    2
    Hello, I've been learning VFX Graph and I love it, but I'm having issues trying to manipulate it in code. However It seems like something in my project is off? Any help would be greatly appreciated. I've been googling for a good 2 hours now and am at wits end :(

    I'm using:
    Unity 2020.1.6f1
    VFX Graph 8.2.0
    Universal RP 8.2.0 (not sure if relevant?)

    Heres the error I get:
    Code (CSharp):
    1. Assets\Resources\Scripts\Controllers\Spells\FireballController.cs(17,12): error CS0246: The type or namespace name 'VisualEffect' could not be found (are you missing a using directive or an assembly reference?)
    Here's the snippet at issue:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Experimental.VFX;
    5.  
    6. public class FireballController : DamagingObjectController
    7. {  
    8.     public override float totalPower {
    9.         get {
    10.             return power;
    11.         }
    12.         set {
    13.             power = value;
    14.         }
    15.     }
    16.  
    17.     public VisualEffect effect;
    18.     private float movementSpeed = 20.0f;
    19.  
    20.     void DetatchParticles(){
    21.         effect.transform.partent = null;
    22.         effect.Stop();
    23.         effect.Destroy(effect.gameObject, 1f); //would be better to get lifetime dynamically.
    24.     }
    25.  
    26.     void DestroySelf(float time = 0f){
    27.         DetatchParticles();
    28.         Destroy(gameObject, time);
    29.     }
    30.  
    31.     public void Start(){
    32.         DestroySelf(1f);
    33.     }
    34.  
    35.     void Update()
    36.     {
    37.         transform.position += transform.forward * Time.deltaTime * movementSpeed;
    38.     }
    39.  
    40.     void OnTriggerEnter(Collider col) {
    41.         if(col.gameObject.tag == "Destructable") {
    42.             Destroy(col.gameObject);
    43.             DestroySelf();
    44.         }
    45.         if(col.gameObject.tag == "Environment") {
    46.             DestroySelf();
    47.         }
    48.     }
    49.  
    50.     void OnDestroy() {
    51.         //create explosion object here
    52.     }
    53. }
    54.  
     
  2. PaulDemeulenaere

    PaulDemeulenaere

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    154
    Hello,

    The VisualEffect component has been moved from the namespace UnityEngine.Experimental.VFX to UnityEngine.VFX with Unity version 2019.1.

    You have to replace :
    Code (CSharp):
    1. using UnityEngine.Experimental.VFX;
    to
    Code (CSharp):
    1. using UnityEngine.VFX;
    I hope that helps.
     
    Alidsf likes this.
  3. LunarFuror

    LunarFuror

    Joined:
    Jan 18, 2018
    Posts:
    2
    Absolute hero. After reading this I went to look where I was getting experimental from. Looks like google likes the 2018 api reference. If anyone else has this issue/ sees this thread, here's the latest (at the time) api reference
    https://docs.unity3d.com/2019.3/Documentation/ScriptReference/VFX.VisualEffect.html