❔ ✅ Serializable attribute in Unity
I am creating a class selection menu right now for game character.
I have created two types:
now the Create Asset Menu is working, when i create a class of CharacterClassSelection the characterClasses array can be assigned via the Inspector. But serialization of CharacterClass seems to fail, when i add object i dont see fields characterClassName and characterClassSprite 😦
15 Replies
try putting the attribute on the fields directly
@Ero Assets\Scripts\ClassSelection\CharacterClass.cs(8,6): error CS0592: Attribute 'Serializable' is not valid on this declaration type. It is only valid on 'class, struct, enum, delegate' declarations.
I can't put the attribute on the fields
I have no idea what to try next or why it isnt working
[SerializeField]
?oh
same result
@Ero
no clue
this is so weird
i do exactly what tutorial tells me to do, maybe different versions cause this
would it be the Unity version or the C# version I care about?
what tutorial would that be?
change your character class to a regular class
also, scriptableobject when used as an Asset can't serialize scene objects so your Sprite there will lose the reference
Hooson
YouTube
Unity Character/Skin Selection Menu - Easy Unity Tutorial
In this unity tutorial, you'll be learning how to make a character and skin selection menu for your game.
You'll learn how to use scriptable objects to make a character database. Scriptable object is a data container that you can use to save large amounts of data.
Timestamps:
0:00 Intro
0:17 Character Selection UI Setup
1:32 Character Scripti...
ohhh I think that's it
CharacterClass shouldnt be a SciprtableObject, you're right. Tyvm
lemme see if it works now
its working, thx a lot @BadaBingBadaBoom
I don't really get yet when we use ScriptableObject or MonoBehavioru or none of it
very new to all this
aight, goodluck
!close
Closed!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.