• 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 absameen · May 16, 2012 at 05:46 PM · serializationfieldinfo

Serialize FieldInfo and PropertyInfo

I am using FieldInfo and PropertyInfo variables. I need to serialize them, I tried:

 [SerializeField]
 public PropertyInfo propertyInfo;
 [SerializeField]
 public FieldInfo fieldInfo;

But the data is being lost when Unity exits. How can we serialize FieldInfo and PropertyInfo?

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
1
Best Answer

Answer by rutter · May 16, 2012 at 07:39 PM

You might want to check the official script reference, which briefly details the types Unity is able to serialize.

You may be able to use other serialization solutions. JsonFx and protobuf-net seem to be fairly popular, but you should definitely spend some time researching something that will work for your project's needs. There are plenty of threads discussing these, if you search around.

One caveat if you're building for Apple products: iOS doesn't allow any code which depends on JIT compilation, which will prevent you from using many of the robust serialization solutions available today.

If you really need to use Unity's built-in serialization, you can try to find ways to break your data down into types Unity can serialize (ints, floats, strings, bytes), and read/write from those. You might be able to use an array of bytes with binary serialization, for example.

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.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Serialization of GameObject 1 Answer

Save System Problems 0 Answers

Serialized data show information after load 0 Answers

How would I go about storing 3D object data into a database? 5 Answers

Storing data about an asset only in the editor 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges