Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by dCalle · Oct 29, 2017 at 12:48 PM · scenescriptableobjectsavingpersistence

Get Reliable Instance ID

Hi, I just figured that Instance IDs of MonoBehaviours are created on Scene construction, if you'd call it that way. The issue now is, that I make personalisable Scriptable Objects, which do only have 1 owner and the owner's ID is its InstanceID...


So, when saving and loading the Scene. The InstanceIDs change and aren't reliable. So I have to come up with something else.

Does anyone have something in mind? I'm trying to figure if I can rely on a transform's InstanceID and work with that one. like GetTransfrom(ownerTransformID).GetComponents<ownerComponentType>()[ownerComponentIndex]

That would be more complex than I'd want it to be. Is there an easier solution out there?

Comment
Add comment · Show 4
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 pako · Oct 29, 2017 at 01:13 PM 0
Share

Why don't you add an ID field to each owner, and assign it with whatever unique value you want?

avatar image dCalle pako · Oct 29, 2017 at 02:39 PM 0
Share

I didn't want to write owner classes that derive from $$anonymous$$onobehaviour or ScriptableObject. anyhow, InstanceID's aren't consistent outside the current SceneSession. So I have to do a freaking huge workaround, because the whole process was built on that... ... ... ... alright onto it ;-) thanks for the joining thought buddy ;-)

avatar image pako dCalle · Oct 29, 2017 at 02:54 PM 0
Share

Even if your owner classes don't derive from $$anonymous$$onobehaviour or ScriptableObject, they can have their own ID field (not InstanceID), which you can make as unique as you like (and persistent), as I already said. Or alternatively, you can get an InstanceID that is unique for a scene, and have the owner assign it to whatever he owns, when the scene loads.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Scriptable objects become volatile on android 1 Answer

Saving players progress in ScriptableObject asset 1 Answer

Handling change in Class variables with saving ScriptableObject 2 Answers

serialized file version is higher than what this version of Unity supports 1 Answer

Scene wont Save 4 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