Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Opening a Scene on Mac removes some references

Discussion in 'Editor & General Support' started by LinkoVitch, Aug 19, 2021.

  1. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    15
    I am opening our game on a Mac as I am looking at iOS builds for the game. The scene is saved properly and stored in GIT, I can build and run the game fine on the Windows machine. I can even clone the repo to a different Windows machine and all works well. However, when I clone to Mac, opening that same scene results in various prefab references and some other settings reverting to None!? for prefabs throughout the scene!

    I have confirmed this by having the scene open on the Mac and Windows side by side and checking the values, I am able to correct them on the Mac, and resave the scene. Initially I thought perhaps something is getting mangled when I am switching from main to development branches (quite a large project), and have performed a `git reset --hard` to ensure all is as it should be, as soon as I open the scene on the Mac, settings nuked!

    Both Windows and Mac are running 2019.4.5f1

    I have also tried saving the scene on the Mac to then use git to diff the file against the repo, but git sees no changes! So it looks like the file is 100% as it should be but for some reason Unity on the Mac is just not de-serializing the data correctly?

    Any thoughts? solutions?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,779
    It sounds like you are not properly source controlling ALL meta files.
     
    Joe-Censored likes this.
  3. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    15
    If that were the case I would expect to see a modified or untracked meta file when running `git status` there isn't. Also cloning it to different Windows machines would cause a similar issue, it doesn't.

    What you say makes sense, but I don't think that is the issue. I did find the following older post about similar, and suspect it might be a similar issue?

    https://forum.unity.com/threads/scenes-work-in-windows-break-in-mac.151073/
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,779
    Except when someone sticks *.meta in the gitignore file (or the global gitignore).

    I'm simply observing that the behavior you report precisely matches the behavior of failing to source control meta files, or alternately, something on the second computer sharing the same meta GUIDs, causing Unity to reassign them.

    If you're confident that's not the case, move onto other options, but I've never seen other options for this issue.
     
    Joe-Censored likes this.
  5. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    15
    Yup that is certainly NOT the case, there are meta files that have popped up in the status (for a folder I created in the repo for example).. All Meta files are being correctly stored in the repo. This is not related to missing meta files (which I would also expect to cause issues on any other machine other than the one that generated them, and this has been worked on by numerous people and released, so there would be a lot more issues if that were the case).
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    What happens when you check out a fresh copy of the project from source control on the same computer which it is working correctly but into a different folder, and then open it? Do you see any similar issues?
     
  7. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    15
    Nope.

    My checkout was initially to Mac, which has the issues I mentioned. Other people on windows had no issues, so I also then checked it out onto my Windows machine, and also had no issues, I was then able to compare the scene on both machines.

    Neither machine had it installed on before this, and both have fresh clones of the same repo, both on the same branches and at the same commits. GIT sees no difference between the file on the Mac and the repo.
     
    Joe-Censored likes this.
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,779
    Fix one broken reference, look at the source control diff. Did it change a GUID? Then you know it's a GUID / meta problem. If not, whatever the diff is, perhaps that can give you more intel.
     
    Joe-Censored likes this.
  9. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    15
    Good thinking and an interesting find.

    The element I chose to fix was a property called eventSystem which is a serialized field in the associated class. When I added the Rewired prefab back in as it should be, and saved the scene, the same GUID as on the windows build was used, so the GUIDs are correct, however in the scene file the eventSystem property was added and set (along with all the other GameObject related m_pivot.x type properties. This doesn't exist on the windows machines file for the scene and it seems perfectly happy to make the leap and assign the correct value to the property.

    Making a simple change (like moving a GameObject position) and forcing a save of the scene on Windows does not populate this additional field. If I set it to None, and then back again, when I save the scene this then adds the missing property on the Windows machines scene file too!

    I suspect that when this scene was built that attribute may not have existed with that name or in some other form which has been changed, and the Windows build of the Unity Editor is happy to accept the GUID associated with the rest of the property also applies to that and fills in the missing value, but on Mac Editor it is 100% literal and won't complete missing values.

    Ah the wonderful consistency (or complete lack of it) and Unity :/

    At least now I know what is going on and it is the Editor behaving differently between platforms. Now does anyone know a way to force a full re-serialization of a scene without having to change each property by hand? :D

    Thanks for the idea
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,779
    My experience is that touching ANYTHING in a scene then saving it causes Unity to write all the new properties out for ALL objects in the scene... now obviously they'd be wrong on the target you're having issues with, but it seems they should get filled out on the target you are not having issues with.

    Otherwise I would write an editor script if I had more than a dozen or so of these to do. Otherwise, eh, just hammer them out by hand. Never know, you might even find a bug or improve something while you're looking around if it's only a dozen things. :)

    You're welcome! Hard to understate the value of the source control diff for all kinds of troubleshooting.