Missing the class attribute 'ExtensionOfNativeClass'
After updating unity to the version 2018.3.7f1 I have tihs error in my released project:
'Saves' is missing the class attribute 'ExtensionOfNativeClass'!
'SavesForAllSlots' is missing the class attribute 'ExtensionOfNativeClass'!
'Saves' is missing the class attribute 'ExtensionOfNativeClass'!
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
'SavesForAllSlots' is missing the class attribute 'ExtensionOfNativeClass'!
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
...
Why is tihs happening?
Saves.cs
[System.Serializable]
public class Saves
{
public string dateTime;
public float transformPositionX;
public float transformPositionY;
public float transformPositionZ;
public int latestSaveSlot;
public int actNumber;
public string sceneName;
public int slotImage;
public int currentActiveSlot;
public int stepNumber;
}
SavesForAllSlots.cs
[System.Serializable]
public class SavesForAllSlots
{
public int latestSaveSlotForAll;
}
Answer by snar1sburg · May 24, 2019 at 11:35 PM
@dmitry-kozyr this was happening to me earlier today. What was happening is that I changed a script from inheriting MonoBehaviour to being a static class. After doing this I started to get errors. Turns out the original prefab object that was in my screen was still referencing this MonoBehaviour script. So I went to my prefab, deleted the script from it and it fixed these errors. I believe that static scripts don't need to be attached to GameObjects. If this doesn't work I am not sure what is wrong, I am also not an expert just an avid learner!
In order to have a script as a component, it has to inherit $$anonymous$$onoBehavior. But just like you, the prefab was still having the script as a component while I had removed it in the gameObject in the scene. It sounds more like a bug from Unity, even if, in the end, it's probably cleaner to force us to remove it from the Prefab (a more explicit error would be helpful) It also happens with non-static classes
Answer by MrBalin · Jan 20, 2021 at 02:58 AM
PFF Wouldn't you know it, all I did was restart Unity and the error went away. No deleting neccesary.
Answer by Tosineben · Dec 10, 2019 at 08:42 PM
You have to create your save script in the script editor be it rider or android studio then copy input all the Data’s you want to save int it. After that you can add serializable to the class. Make sure you don’t create the class in unity or else it will create an inheritance of mono behavior with it.
Answer by JesterGameCraft · Dec 18, 2021 at 10:54 PM
In my case I had a script that was added as a component to a Transform. I later changed this script from MonoBehaviour to just a generic class. I started to see the errors.
The solution was to remove the dead reference to the script in the GameObject that was referencing it. I just did a search in the Hierarchy using the offending script/class name and found the missing reference. Once removed, the errors were gone.