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 Innovative · Sep 03, 2013 at 06:27 AM · gameobjectvector3serializationserializableserializefield

Can a GameObject be serialized?

Hi All,

I'm writing a custom editor window and have run into serialization issues, namely "Type UnityEngine.GameObject is not marked as Serializable."

The class that contains the GameObject is marked as [Serializable] and I've added [SerializeField] as an attribute to the GameObject public variable and get the error above.

The Unity documentation here says the following:

Your field will only serialize if it is of a type that Unity can serialize:

Serializable types are:

  • All classed inheriting from UnityEngine.Object, for example Gameobject, Commponent, MonoBehaviour, Texture2D, AnimationClip..

  • All basic data types like int, string, float, bool.

  • Some built in types like Vector2, Vector3, Vector4, Quaternion, Matrix4x4, Color, Rect, Layermask..

  • Arrays of a serializable type

  • List of a serializable type (new in Unity2.6)

  • Enums

I'm also getting the same error for other Unity types like Vector3 so I'd really appreciate any information about serialization of basic Unity types. Thanks.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by getyour411 · Sep 03, 2013 at 08:01 AM

You might want to look at this

http://whydoidoit.com/unityserializer/

If you must 'roll your own', you can probably learn from that.

Comment
Add comment · Show 1 · 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 Innovative · Sep 03, 2013 at 08:22 AM 0
Share

Thanks getyour411, that source is a godsend if I have to go that route, I have read nearly all of whydoidoit's tutorials and can see it helps for Lists, structs and other types but not the Unity types.

To be clear I am trying to use the save/load code by CJCurrie here which uses ISerializer and BinaryFormatter whereas I think the Unity types may only work with XmlSerializer. I'm in over my head now so I may be mixing two types of serialization.

The also ties in with another problem where I can't save my editor window state when the assembly reloads after play/exit is pressed in the editor.

I may have to keep re-reading the Serialization $$anonymous$$ega Post until this sinks in or my head explodes, which ever comes first.

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

16 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 avatar image avatar image

Related Questions

How to serialize a gameobject using binaryformatter? 0 Answers

SerializeField does not work when a value set using code 0 Answers

" Binary Save" Stuff - Workaround for Vector3 Serialization 3 Answers

UnityEngine.GameObject not marked as Serializable? 1 Answer

How am I supposed to use SetTile( ) on a GameObject's position if its x and y values aren't integers? , 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