Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 bourriquet · Apr 03, 2018 at 07:22 AM · editorserializationassetsreimport

Force reimporting scriptable object from text-based asset file

I have scriptable objects that contain references to prefabs' MonoBehaviours. These referenced prefabs sometimes get rebuilt by code using ReplacePrefab, so the MonoBehaviour reference get lost because the MonoBehaviour get a new fileID assigned in the Prefab file.

I then added some code that:

  1. save the assets (so that the new fileID gets written in the prefab file)

  2. write in the prefab text file directly to replace the new fileID back with the old one that is still referenced in the scriptable object.

That works, the prefab is all good and has the old fileID on the MonoBehaviour BUT for some reason the scriptable object still sees the referenced MonoBehaviour as missing, even though it has the correct fileID when I open the text-serialized asset. There are 2 ways I found that will bring back the reference.

  • Delete the Library folder and re open the project...

  • Add a random empty change to the ScriptableObject text file from an external text editor (say a space at the end), then when back in Unity, the reference is back.

So I need any way to bring back the reference automatically. So basically just a way to make sure that the ScriptableObject will get reimported from the text file for real would work.

Reimport, Refresh, AssetDatabase.ImportAsset with ForceUpdate, all don't work). Also adding this final space in the text file from editor code doesn't work, probably because it needs to be done while Unity is not on focus?

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 vinilly · Apr 03, 2018 at 08:32 AM

What kind of asset file are you using? is it XML?

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 bourriquet · Apr 03, 2018 at 09:09 AM 0
Share

It's just a ScriptableObject with Asset Serialization $$anonymous$$ode to Force Text. So it's not X$$anonymous$$L, it's Unity's Text-Based Serialization format. Not sure if it has a name.

avatar image bourriquet · Apr 03, 2018 at 09:10 AM 0
Share

Oh yeah, it's YA$$anonymous$$L.

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

108 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 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

Auto-refresh assets after changing scriptable object 0 Answers

Access or remove background color of AssetPreview 2 Answers

Implementing AForge into unity 0 Answers

Asset variables needs [SerializeField] to be saved when reopening Unity. 1 Answer

How to assign object reference to ObjectField knowing the object's name? 2 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