Search Unity

Resolved 'class' is missing the class attribute 'ExtensionOfNativeClass'!

Discussion in 'Scripting' started by damdamien24, Jun 15, 2022.

  1. damdamien24

    damdamien24

    Joined:
    Jan 9, 2022
    Posts:
    14
    Hi,
    I'm trying to create a mobile game using sqlite as a database. To do this, I'm using SQLite4Unity3d (github here) with an existing database. His sample project works perfectly when I try to run it and when I build it on a phone. So I adapted his project to mine by creating a Note class like his Person class but when I go back to the unit editor an error appears, like below, even though the methods using this class work.

    upload_2022-6-15_10-10-43.png

    Searching the web it looked like another class called Note was also being used, which was true (and was a monobehavior) but I removed it and the error still appears. The list of my scripts in my project with Note in their name listed here:

    upload_2022-6-15_10-34-12.png

    I guess residuals from the old class could be a problem but I don't know how to know if there is some and so how to find and remove them.

    Here is my Note.cs :

    Code (CSharp):
    1. using SQLite4Unity3d;
    2.  
    3. public class Note
    4. {
    5.     [PrimaryKey, AutoIncrement]
    6.     public int Id { get; set; }
    7.     public int IdPartition { get; set; }
    8.     public double Midi { get; set; }
    9.     public double Mesure { get; set; }
    10.     public int Ticks { get; set; }
    11.     public int Duration { get; set; }
    12.     public int Time { get; set; }
    13. }
    14.  
    Here is the Person class from which I am inspired

    Code (CSharp):
    1. using SQLite4Unity3d;
    2.  
    3. public class Person  {
    4.  
    5.     [PrimaryKey, AutoIncrement]
    6.     public int Id { get; set; }
    7.     public string Name { get; set; }
    8.     public string Surname { get; set; }
    9.     public int Age { get; set; }
    10.  
    11.     public override string ToString ()
    12.     {
    13.         return string.Format ("[Person: Id={0}, Name={1},  Surname={2}, Age={3}]", Id, Name, Surname, Age);
    14.     }
    15. }
    16.  
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,496
    It's likely leftover in the "Library" folder. You can delete that folder and it'll be regenerated although depending on the size of your project, it might take some time. Obviously you'll need to ensure you've not got the project loaded at the time.
     
  3. damdamien24

    damdamien24

    Joined:
    Jan 9, 2022
    Posts:
    14
    Just tried but still not the solution.
    Maybe in fact there are some prefabs/scripts using the old Note.cs because they have the same name, but I don't know if there is a way to find them easily..
    I will try by changing the name
     
    sandolkakos and MelvMay like this.
  4. damdamien24

    damdamien24

    Joined:
    Jan 9, 2022
    Posts:
    14
    Update : Just tried by changing the name to NoteDB.cs but the error is still here when I build in .aab
     
  5. damdamien24

    damdamien24

    Joined:
    Jan 9, 2022
    Posts:
    14
    SOLUTION :

    Some of my game objects were having the old script.

    To find them easily, you can right click on your script and click on "find references in the scene". :)
     
  6. andywiecko

    andywiecko

    Joined:
    Nov 18, 2020
    Posts:
    3
    Another solution is (almost what @MelvMay mentioned) the following:
    1. Close Unity Editor.
    2. Remove the
      Library/
      folder.
    3. Remove meta files for the broken classes.
    4. Open Unity Editor (meta with new hash will be generated).
    The solution does not require any scene or prefab modification :)
     
  7. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    Assets > Reimport All worked for me
     
  8. spilat12

    spilat12

    Joined:
    Feb 10, 2015
    Posts:
    38
    Had the same error and it turned out that it's the old missing script that was causing it. Removing it fixed the issue.

    upload_2023-7-28_23-38-1.png
     
  9. GregAtMad

    GregAtMad

    Joined:
    Aug 15, 2023
    Posts:
    2
    This was my issue! Thank you!
     
    spilat12 likes this.
  10. distastee

    distastee

    Joined:
    Mar 25, 2014
    Posts:
    66
    This can also happen if you add a script to a gameobject and then (for whatever reason) that script no longer inherits from MonoBehavior. Just redefine your class as

    Code (CSharp):
    1. public class MYCLASS : MonoBehaviour {
    Happened to me when consolidating virtual classes with children and screwing up the class definition. good luck out there devs
     
    devorenge likes this.