2

I'm currently working on a project where we use scritpable objects to store all configs on the game. The problem comes using git since sometimes we lose references stored on those SO.

For example I have a Config called A with a GameObject variable. On my branch "Branch1" the variable is null and on my branch "Branch2" is assigned to a prefab. I'm working on Branch1 and I move to Branch2 but the SO is not updated and the variable is still null although on Branch2 that variable actually had a value.

We have tried to reimport the asset but does not solve anything. The only thing that seems to work is a weird process. If we make a change to the SO after moving to BranchB, we save and then discard changes from git (we use sourcetree) the SO config now is fine as it should be on the current branch.

It's a weird behaviour and more weird solution we have that is leading to a lot of time lost and several errors.

Anyone has an idea of what is happening and knows how to solve it??

We are using Unity2019.1.14f1 and we use Odin for a custom inspector of the SO (maybe is relevant).

Josef21296
  • 21
  • 4
  • You want changes in your scriptableobjects to be across 2 branches in git? – BugFinder Dec 18 '19 at 13:28
  • Do you have the asset's .meta file added to your `.gitignore`, or .meta files ignored in general? If that's the case then remove the meta file(s) from your gitignore, as these are used to track references – Remy Dec 18 '19 at 13:29
  • No, metas are not ignored – Josef21296 Dec 18 '19 at 14:57
  • @BugFinder I don't really understand your question. What I want is what I think is expected. When I change my branch I see on the Unity editor the correct data on the inspector. On BranchA see null reference and when I swap to BranchB se a reference to the prefab. – Josef21296 Dec 18 '19 at 14:59
  • If you arent talking git branches what is a branch? – BugFinder Dec 18 '19 at 15:28
  • @BugFinder I'm talking about git branches. What I understood about your first question is that I want to mantain changes between branches and that's exactly what is happening and I don't want since, as far I understand about git, that's not what it should happen. The main problem does not come from git rather than Unity as is explained on the issue. – Josef21296 Dec 18 '19 at 16:26
  • After switching the branch, delete the library folder and see if the references show up. We once ran into a similar bug, which feels like a unity issue, but we could only resolve it by this workaround. – JeanLuc Dec 23 '19 at 09:22

1 Answers1

0

For anyone stumbling upon this question:

Save the project, under File->Save Project, and you will see your SO opening up for a commit in your preferred sourcecontrol software.

Kurt-Dekker (Thread linked below) goes into detail as to why just "Save as" and "Save" don't work, but "Save Project" does.

First answer by Kurt-Dekker in this thread: https://forum.unity.com/threads/scriptableobjects-are-not-updating-when-changed-on-the-filesystem-via-git.834109/