• 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
0
Question by Ves · Jun 06, 2012 at 07:14 PM · gameobjectserializationserializable

UnityEngine.GameObject not marked as Serializable?

I'm getting this error, but I thought that all types derived from UnityEngine.Object were automatically serializable if made public, or using the [SerializeField] attribute?

Am I missing something?

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 Wolfram · Jun 06, 2012 at 07:58 PM

Are you trying to use your own serialization interface? Google your question, there are several answers, threads, and other topics dealing with problems when trying to do that.

Other than that, my wild guess would be, don't use [SerializeField] or other related attributes above objects that are already serialized by Unity, include a "using UnityEngine;" instead of accessing it via UnityEngine.GameObject, etc.

Comment
Add comment · Show 2 · 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 Ves · Jun 07, 2012 at 03:02 AM 0
Share

The serialization is an effort to do a deep copy using binary formatter and memory stream. It works perfect if the item I'm deep copying doesn't contain a reference to a GameObject. When it does, it throws the error that the GameObject is not marked as serializable.

avatar image Bunny83 · Jun 07, 2012 at 03:13 AM 1
Share

Unity doesn't use the C# serializer. They uses their own serialization method. $$anonymous$$ost UnityEngine classes have a counterpart in native code. They are more than the managed representation you can see from $$anonymous$$ono. Don't mess around with lowlevel stuff when it comes to build in classes of Unity.

They actually sealed all classes so you don't accidentally derive a class from a Unity class. The only classes that can and should be used as base class is $$anonymous$$onoBehaviour and ScriptableObject (and the editor classes that are ment to be derived like Editor, EditorWindow, AssetPostprocessor, ...)

If you want to deep copy a UnityEngine.Object derived object, use Instantiate. It works with most objects (i used it already for $$anonymous$$aterials, $$anonymous$$eshes and of course gameobject and components). $$anonymous$$eep in mind when you clone a component the owning gameobject is cloned as well along with all components and child objects.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to serialize a gameobject using binaryformatter? 0 Answers

Can a GameObject be serialized? 1 Answer

Method of determining if a field is serialized? 0 Answers

GameObject is not marked as serializable 0 Answers

Serialized data show information after load 0 Answers


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