• 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 DocteurCox · Jul 30, 2013 at 01:35 PM · c#editorserializedpropertythis

Get "this" SerializedProperty ?

Hello there,

I'm working on something to make my life easier with Editor scripts and for a matter of simplicity of my code I'm looking for a way to work the same way with both SerializedObject and SerializedProperty. I could use an adapter pattern, but before I do that, I would like to know if there's an easier way. :)

Unless I am mistaken, there's no way to use polymorphism to work the same way with SerializedObject and SerializedProperty when it comes to finding relative SerializedProperty. So I was wondering : is there a way to get a root SerializedProperty ? (that is to say a SerializedProperty that reflects its SerializedObject)

Thanks in advance for your answers :)

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

Answer by Bunny83 · Jul 30, 2013 at 02:35 PM

No, that's not possible. You should understand how the serialization actually works. If you have Unity pro, make sure you force text serialisation, then just open a prefab or a scene in a text editor.

A SerializedObject represents one object that is serialized on it's own. Only Components and build-in reference types are actually serialized on their own. "Normal" custom serializable classes are serialized along is an actual SerializedObject. All the members of the custom class or array become properties of the SerializedObject. Between real SerializedObject it only holds references. So each SerializedObject is on it's own but objects / values that are serializable but not SerializedObjects will become properties of the containing SerializedObject.

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 DocteurCox · Jul 30, 2013 at 02:44 PM 0
Share

Ok. I don't have Unity Pro so I never had a chance to look at how Unity's serialization works, but now I think I get it :) Thanks for those very clear explanations :)

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

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

Multiple Cars not working 1 Answer

Call a function from CustomPropertyDrawer of Arbitrary class 1 Answer

Distribute terrain in zones 3 Answers

How do i stop my Editor window values from reseting? 0 Answers

Editor Targets are updated but SerializedPropertys arent 1 Answer

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