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 /
  • Help Room /
avatar image
0
Question by rzer · Jul 23, 2019 at 10:25 AM · buginspectorgitreloading

Inspector loose data after git branch switch

I have two git branches. At first i have no some serializable fields in object. So when i chekout to second branch where these fields are present (hot project reloads happend), inspector not shown their values (like they are empty) and in play Mode they are empty too. But if i checkout this branch and after it load unity app - everything is normal. I think project reloading works incorrect. But maybe i'm doing something bad? Its very annoing because you might loose your data. If you change something in this object after hot reload.

 public WorkerLimits workerLimits;
 
 [Serializable]
     public struct WorkerLimits
     {
         public int freeWorkers;
 
         [ArrayElementNaming(elementText = "Additional worker", offset = 1)]
         public AdditionalWorker[] additionalWorkers;
     }
 
     [Serializable]
     public struct AdditionalWorker
     {
         public ItemStack[] cost;
     }
Comment
Add comment · Show 5
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 Dragate · Jul 23, 2019 at 11:09 AM 0
Share

What does your ".gitignore" file look like?

avatar image rzer Dragate · Jul 23, 2019 at 11:46 AM 0
Share
 /.temp
 /.sdk
 /.dart.user.options.json
 .DS_Store
 .idea
 __pycache__
 ImportSetting.asset*
 *.DotSettings
 Server/obj
 Server/bin
 Project/StaticData
 Project/*.plantuml
 Version$$anonymous$$anager/obj
 Version$$anonymous$$anager/bin
 Project/Bundles
 tools/edart/obj
 tools/edart/bin
 *.user
 Version$$anonymous$$anager.zip
 Version$$anonymous$$anager/vm
 /Server/.vs
 /Version$$anonymous$$anager/.vs
 Project/Assets/BuildReports
 BuildReports.meta
 
avatar image Dragate · Jul 23, 2019 at 02:42 PM 0
Share

That's expected behaviour. Changes you do in one branch shouldn't apply to other branches by default. The changes you describe are saved in seperate files Unity makes (e.g. .unity , .meta) and git seems to be tracking their states (one with the assigned fields you speak of and another with no data). Solutions are:
- You could just re-assign your empty fields in your other branch and commit/stash them.
- You could have these assignments in the Inspector as staged changes (don't commit them) and as you switch branch the staged changes can be carried over. This methods does seem to attract conflicts, so be careful.
- You could add the file to .gitignore, forcing git to stop tracking it and thus, any changes in that file will be same for all branches (since it's not under version control anymore). For scene-specific changes on gameobjects (e.g. assigning reference of one gameobject to a component of another in the scene) the data is likely to be saved in the .unity file of the scene. The rule in .gitignore would look like /[Aa]ssets/**/*.unity. Do take note that you might need to run git rm --cached [file] after adding the rule.

avatar image rzer Dragate · Jul 23, 2019 at 03:19 PM 0
Share

I will try to explain other way. I added some fields with values in my working branch and commit them: working branch initial state After that i switch to main branch to do some work and return back to working branch and see: Working branch after return back from other branch

In Asset file i see:

   workerLimits:
     freeWorkers: 1
     additionalWorkers:
     - cost:
       - stackType: 1
         itemId: 0
         index: 0
         amount: 50

It's the same branch, but in Inspector these values are reseted. (Hot project reloading find new fields , but not read values which set in asset file) If i will restart Unity app everything will restore like on a First screenshoot.

Sorry for my English.

avatar image Dragate rzer · Jul 23, 2019 at 03:34 PM 0
Share

Ok, I didn't get that you return to your working branch from your original post. It seems odd that you have to restart Unity to brink the Inspector values back after returning to your initial branch. I do not seem to have such issue using this manual and this .gitignore (if you haven't checked them out already). Unfortunately, I'm not able to help you anymore and hopefully, someone more knowledgeable will be able to.

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

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

How do I fix broken inspector in unity? 1 Answer

Animator StateMachineBehaviour scripts are collapsed in inspector 0 Answers

Inspector overlapping component problem 2 Answers

Unity not Version Controlling Inspector Settings for GameObjects 1 Answer

Inspector assigned variables not assigning in build 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