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
6
Question by yoyo · Jan 27, 2011 at 07:21 PM · editorprefabassetassetdatabaseversion-control

Can I safely put a prefab asset into version control with Unity Free?

I would like to use prefab assets to store a bunch of project-wide settings, similar in concept to a GUISkin. Will the .prefab files play nicely with version control?

More specifically, are my .prefab files fully self-contained, with no dependencies on the contents of the Library folder?


Feb 7, 2011 -- Thanks to tertle and DaveA for your thoughts on this. I'm going to carry on with putting prefabs into version control and see how it goes. So far so good.

Note that I up-voted both answers, but didn't actually mark either as correct, since there's still no definitive answer beyond what I originally suspected. (tertle's answer was auto-accepted by the bounty engine.)


More details ...

I don't need to be able to merge file revisions, but what I'm worried about is that a prefab may have hidden dependencies on the contents of the scene database -- all that opaque stuff in the Library\cache and Library\metadata folders.

On our project, we have two git repositories -- one for the Assets folder (art and code) and one for the Unity scene database (Library folder and friends). The Assets repository is used normally -- we all check stuff in and out throughout the day. The scene repository is "special" -- one person at a time owns it, and must get latest before making changes (which is a pain, but lets us carry on with Unity Free a while longer).

We currently have a GUISkin asset that sits in the Assets repository. This seems to be working fine. Looking at the .guiskin file and a .prefab file with a hex editor, it appears they use the same serialization mechanics, so I'm hoping that they would also both work fine in our git repository.

Being able to use prefabs more extensively would be useful, as it would let us move more design activities out of the scene repository and into the Assets repository.

I did search Answers for relevant info, and found some concerns with version control and prefabs in particular cases, but no general description of the issues. Info and advice appreciated.

Comment
Add comment · Show 3
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 yoyo · Feb 01, 2011 at 12:12 AM 0
Share

And related to prefab assets -- I've noticed that if I have a reference from a component in the Hierarchy to a prefab component in the Project, then Awake is never called on the prefab component. Is that expected?

avatar image Bunny83 · Feb 01, 2011 at 03:32 AM 1
Share

You will run into troubles if you use newer or older versions of scripts. Prefabs that contains script components have external dependencies. The script is not included in the prefab because it can be used on other prefabs/gameobjects and every class/script have to be unique. If you setup references to other assets (assigning them to script variables) they are also external. If they aren't present in an older version you will get a missing reference.

avatar image yoyo · Feb 01, 2011 at 05:14 PM 0
Share

In that case the dependency is from one asset to the other -- does the dependency relationship get stored in the Unity database (Library folder) or in the prefab itself?

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by tertle · Feb 01, 2011 at 12:28 AM

codinghero posted a method of using SVN on free here: http://forum.unity3d.com/threads/43876-can-I-use-subversion-to-manage-my-unity-files?p=279261&viewfull=1#post279261 The whole thread is a good read though.

That all said I don't think you'll have issues other than really long rebuild times to update metadata from assets.

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 yoyo · Feb 01, 2011 at 02:01 AM 1
Share

Thanks for the link. The thread suggests that it ought to work, and amounts to what I said in my answer to this question -- http://answers.unity3d.com/questions/11075/how-does-unity-free-source-control-go-wrong. I guess my question is really whether a .prefab file is independent of the Library folder. I'll edit my question to clarify.

avatar image
3

Answer by DaveA · Feb 04, 2011 at 01:19 AM

We have taken to exporting packages (along with the source), and putting them in SVN. Then import the package as needed. In theory that would wrap up any dependencies that the Library might be storing, right?

Comment
Add comment · Show 4 · 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 yoyo · Feb 04, 2011 at 01:27 AM 0
Share

DaveA, I'm not familiar with packages, but selecting Assets > Export Package... it appears this just exports assets from the project folder, not game objects from the scene. $$anonymous$$y question is really about getting data (and its dependencies) out of the scene (and its Library folder) into the assets folder. Assu$$anonymous$$g all dependencies have been severed then revision control should work fine (ok, not merging, but that's a different problem). (Sorry if the question isn't quite clear.)

avatar image DaveA · Feb 04, 2011 at 02:05 AM 0
Share

Ah, sorry I forgot the important step: $$anonymous$$ake a new scene, call it like 'Settings'. Load Additive from your main scene. Delete everything but the gameobject(s) you need (say, an instance of your prefab). Then export that scene as a package.

avatar image yoyo · Feb 04, 2011 at 04:52 PM 0
Share

Hmm, ok. And then you import the package back into your scene to get the data back. Do you have a bunch of automation wrapped around your process? I can't quite imagine making our artists and designers do that manually.

avatar image DaveA · Feb 04, 2011 at 05:46 PM 0
Share

At this point, no automation (we're all geeks), but we've considered it for sure. I was thinking about doing that and putting it on the script wiki, have not gotten to it, don't know if/where pitfalls lie.

avatar image
2

Answer by yoyo · Mar 04, 2011 at 07:58 AM

I've confirmed that dependencies between prefabs, or from a prefab to any asset, are stored in the Library. You can see this by examining a .prefab file with a hex editor (such as hxd), and you will see paths to Library files, with those great long GUID-like file names.

A prefab containing "pure data" components (numbers, strings, vectors, basic types) is fully self-contained and plays nicely with version control, but prefabs containing asset references do not.

Darn.

I've got some ideas for a solution to this, but further experimentation is required.

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 manavkataria · Mar 07, 2012 at 09:07 PM 0
Share

Could you write a howto?

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

1 Person is following this question.

avatar image

Related Questions

Generate a connected list consisting of scriptable objects. 1 Answer

AssetDatabase.AddObjectToAsset is not persistent? 0 Answers

Getting properties on 'missing' things in Editor Scripts? 4 Answers

Why do my prefabs not have an Asset Preview? 1 Answer

A event on deletion of asset in the asset database? 1 Answer


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