Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by mythraend · Sep 01, 2012 at 06:42 PM · errorserializable

namespace error with [Serializable]

I receive this error with the code below:

"The type or namespace 'Serializable' could not be found (are you missing a using directive or an assembly reference?)

Any help would be greatly appreciated. I've been stuck for a couple hours.

 using UnityEngine;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.IO;
 using System.Collections.Generic;

 public class Test_DataMgr : MonoBehaviour {

     [Serializable]
     public class TestClass
     {
         int TestInt;
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
24
Best Answer

Answer by mythraend · Sep 01, 2012 at 09:50 PM

Nevermind. After 4 hours of pulling hair I've found out you just put System.Serializable and it works.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dbanfield · Sep 03, 2013 at 07:02 PM 3
Share

In case this confuses anyone else - spent a while thinking this meant

using System.Serializable;

which barfs. Just put

using System;

avatar image Fattie · Dec 09, 2014 at 02:33 PM 0
Share

a priceless tip! :)

avatar image Psychonerd · Nov 20, 2018 at 07:17 AM 0
Share

Every Upvote here is a soul saved

avatar image megabrobro · Dec 17, 2018 at 06:45 PM 0
Share

you're the greatest

PS. Thanks Unity documentation (not!!) https://docs.unity3d.com/$$anonymous$$anual/JSONSerialization.html

should say using System; at the top of the example really

avatar image GabrielMachadoGomes · Apr 28, 2020 at 11:25 AM 0
Share

"4 hours of pulling hair" - You've saved me from going bald, thanks

avatar image
7

Answer by GeneralV · Oct 07, 2013 at 12:40 AM

Alternatively, you can add the System tag to the attribute itself. I.E.

 public class Test_DataMgr : MonoBehaviour {
  
    [System.Serializable]
     public class TestClass
     {
         int TestInt;
     }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Symbxlz · Jun 05, 2020 at 10:48 PM

More alternatively, add using System so that you can just type [Serializable]. I removed the using System directive when I thought I didn't need it. Lesson learned, don't remove directives until you're done, so, probably never.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unsupported type Generic Mono when using Serializable 2 Answers

How to serialize a gameobject using binaryformatter? 0 Answers

Can't run build-in script editor 0 Answers

Photon PUN offline mode didn't work 2 Answers

Unity Serializer scripting error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges