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 have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

The type or namespace name 'SerializedFieldAttribute' could not be found

Discussion in 'Scripting' started by Swagdos, Dec 9, 2021.

Thread Status:
Not open for further replies.
  1. Swagdos

    Swagdos

    Joined:
    Dec 9, 2021
    Posts:
    5
    Assets\Enemy.cs(5,6): error CS0246: The type or namespace name 'SerializedFieldAttribute' could not be found (are you missing a using directive or an assembly reference?)

    This is the error I have been receiving. It seems like when I add the [SerializedField] maybe my VScode isn't recognizing it. Can someone please take a look at my code and see if they can spot anything I could be missing. I have been following a tutorial all day and it has gone fine up until this point. I have rewritten the code from scratch and copied each line character by character and I still cannot get the particle system to function.


    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Enemy : MonoBehaviour
    4. {
    5.     [SerializedField] private GameObject _cloudParticlePrefab;
    6.  
    7.     private void OnCollisionEnter2D(Collision2D collision)
    8.     {
    9.         Bird bird = collision.collider.GetComponent<Bird>();
    10.         if (bird != null)
    11.         {
    12.             Instantiate(_cloudParticlePrefab, transform.position, Quaternion.identity);
    13.             Destroy(gameObject);
    14.             return;
    15.         }
    16.  
    17.         Enemy enemy = collision.collider.GetComponent<Enemy>();
    18.         if (enemy != null)
    19.         {
    20.             return;
    21.         }
    22.  
    23.         if( collision.contacts[0].normal.y < -0.5)
    24.         {
    25.             Instantiate(_cloudParticlePrefab, transform.position, Quaternion.identity);
    26.             Destroy(gameObject);
    27.         }
    28.     }
    29. }
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,016
    It's SerializeField, not SerializedField. No 'd'.
     
  3. Swagdos

    Swagdos

    Joined:
    Dec 9, 2021
    Posts:
    5
    Thank you I knew I was messing something up and I was just overlooking it! I really appreciate your help!
     
    Supr1me and Kurt-Dekker like this.
  4. s2020266050

    s2020266050

    Joined:
    Nov 16, 2022
    Posts:
    1
    its serializefield without d
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    Yes, as stated above last December already. Please don't necro posts.

    Thanks.
     
Thread Status:
Not open for further replies.