Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 IgorAherne · Oct 31, 2014 at 01:31 AM · transformassetsave

Saving transform component into asset = destroys unity

I am struggling saving the transforms from the selected objects into an asset.

My main asset is a scriptable object with a dictionary in it. Granted that dictionary doesn't serialize properly, I help it with the serialization callbacks provided by Unity. Its keys and values are flushed into 2 lists and then the dictionary gets reconstructed from the data in those lists. More info on that here

Values of the dictionary are scriptable objects (Node), and the keys are the Transform objects.

As I am adding more values into the dictionary I am adding them to the main asset file. During serialization, I can see that the values are nicely buffered and then the dictionary is re-constructed just fine.

However, as I am trying to add transforms of the objects selected from the sceneview, into the main asset, it works ok. But as soon as I enter game mode - unity crashes. next time I enter Unity, I also receive an error "Transform component deleted: GameObject pointer is invalid". When I look into my asset file, it still encompasses those scriptable objects from previous time and the transform objects are gone, but their icons are still present (with no data shown in the inspector as I click on them). When I start to add new transforms (one transform per each gameObjects selected in the sceneview), it all seems to refresh, the icons of old transforms are gone and the new ones are seen in the main asset. If I click on those transform components, I can see appropriate transform data in the inspector. Then everything repeats - enter game - crash unity.

How to solve that issue? Maybe it's because of two consecutive "AddObjectToAsset"? Or is it because I need to save the whole gameObject which carries the transform component?

 EditorUtility.SetDirty(mainDictionary);
 AssetDatabase.AddObjectToAsset(selectedTransform, mainDictionary);
 AssetDatabase.AddObjectToAsset(transformNodeScriptObj, mainDictionary);
 AssetDatabase.SaveAssets();

EDIT:

If I store gameObjects instead of transforms (of course having modified Dictionary types and the code), I am getting several errors "Persistent object inconsistency" some info on that and then another ones: "Can't destroy Transform component of 'mainDictionary' If you want to destroy the gameObject please call 'Destroy' on the game object instead. Destroying the transform component is not allowed. "

Then "Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)"

EDIT:

I decided to create an asset which contains a transform of the object selected in the scene viewport. I can see that the Position, Rotation and Scale are displayed in the inspector if I select the asset. However, once again, Unity crashes once I enter the gameplay mode. When I come back I see that the transform asset is empty (only icon remains).

If I save the scene, so that the transform's gameObject remains in a scene, when I come back unity will crash before its open, so there is not way to get into the scene

(manually deleting the transform asset (the one we snatched from that gameObject) via Windows Explorer) doens't help loool :D. But deleting the scene does

We broke it )

Comment
Add comment · Show 1
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 IgorAherne · Oct 31, 2014 at 03:04 AM 0
Share

bump bump

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

25 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

Related Questions

Export Settings or custom files to release builds 1 Answer

Saving and loading scene specific data - (safe for scene renaming) 1 Answer

Can't load prefabs from resources into an array 1 Answer

Saving usermade content 2 Answers

Fastest Way To Save/Load a SkinnedMeshRenderer at Runtime 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