+ All Categories
Home > Engineering > Unity scene file collaboration

Unity scene file collaboration

Date post: 16-Jul-2015
Category:
Upload: noam-gat
View: 7,441 times
Download: 5 times
Share this document with a friend
Popular Tags:
28
Unity scene file collaboration Simpler than rocket surgery™ Noam Gat 19/4/2015 @noamgat
Transcript
Page 1: Unity scene file collaboration

Unity scene file collaboration

Simpler than rocket surgery™

Noam Gat19/4/2015

@noamgat

Page 2: Unity scene file collaboration

Hello!

Noam Gat

CTO @ Tacticsoft

Past - JoyTunes, Omek Interactive, OGRE

Page 3: Unity scene file collaboration

The scene file is the place that integrates the work of all people working on a project

- Programmers add logic- Artists add assets and control lighting- Level designers build levels- Game designers control balance

For a team member to be able to complete a loop on their own, they often need to modify the scene file

Why collaborate?

Page 4: Unity scene file collaboration

Whats the problem?

Two team members start working on the scene at the same time, make different changes and try to commit.

What is the resulting scene file? How do we get there?

Page 5: Unity scene file collaboration

Previous Work

Some popular workarounds :

- Lock scenes when working on them- Separate the scenes into several prefabs,

lock prefabs when working on them

Both methods work, but they come with their problems (hard to scale, need to decide prefab split, unable to use prefabs for what they were meant to be)

Page 6: Unity scene file collaboration

Related Unity Milestones

Why were those workarounds created?

Unity 1.0 - Scenes are binary, can’t merge

Unity 3.0 - Textual version in Pro

Unity 3.5 - Textual version in Free

Unity 4.6.1 - Random IDs for documents

Unity 5 - UnityYAMLMerge

Page 7: Unity scene file collaboration

Tools required for collaboration

A. Version Control

B. Conflict merging tool

C. Understanding of scene file conflicts

Page 8: Unity scene file collaboration

Tools required for collaboration

A. Version Control git, SourceTree

B. Conflict merging tool P4Merge, UnityYAMLMerge

C. Understanding of scene file conflictsToday =)

Page 9: Unity scene file collaboration

Simple test case

Base Change 1 Change 2

Page 10: Unity scene file collaboration

Simple?

Page 11: Unity scene file collaboration

Simple? :(

Page 12: Unity scene file collaboration

Unity scene files

In order to read, understand and solve conflicts, we should first understand how Unity stores scene files.

The files are based on the YAML format

Page 13: Unity scene file collaboration

YAML

--- !invoicereceipt: Oz-Ware Purchase Invoicedate: 2012-08-06customer: given: Dorothy family: Gale

Document separator + identifier(Multiple documents can exist in one file)

Key value based storage

Indentation for hierarchy

Page 14: Unity scene file collaboration

Unity scene YAML

--- !u!1 &1280541007GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} serializedVersion: 4 m_Component: - 4: {fileID: 1280541011} - 33: {fileID: 1280541010} - 65: {fileID: 1280541009} - 23: {fileID: 1280541008} m_Layer: 0 m_Name: Box1

Object type (1 = GameObject), ID

Links to component types + document IDs (they are also linked back to it via m_GameObject field)

Page 15: Unity scene file collaboration

Unity scene properties

- The file is just a flat list of Component / GameObject documents

- Order of documents is irrelevant (!)- Hierarchy is maintained by two sided

connections (parent points to children, child points to parent).

--- !u!4 &1280541011Transform: m_GameObject: {fileID: 1280541007} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 2, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1949811455} m_Father: {fileID: 0} m_RootOrder: 3

Page 16: Unity scene file collaboration

Understanding .unity conflicts

The common tool to solve conflicts is a “3 way merge” tool, where you see the Base file, and two conflicting changesets made to it.

Page 17: Unity scene file collaboration

Simple test case 3-way-merge

Page 18: Unity scene file collaboration

Simple test case 3-way-merge

Both changesets tried to insert new lines in the same position in the file

BaseChange 1 Change 2

Page 19: Unity scene file collaboration

Simple test case 3-way-merge

In this case, the solution is simple :

Just put one of them after the other

Page 20: Unity scene file collaboration

Simple test case 3-way-merge

Success!

(But why is Box1 before Box2?)

Page 21: Unity scene file collaboration

Why does auto-merge fail?

It does not know what we know :

- That a “---” line with different IDs means that they are two different objects. It suspects that the lines are the same change with slightly different values.

- That the order of the documents in the .scene file is irrelevant. Who should be before who in the text file?

Page 22: Unity scene file collaboration

Smart auto-merge

A suggestion for an algorithm to smartly merge .scene files :

- Break down the scene file into separate objects (based on the document identifiers)

- Merge each document separately- Dump back into .scene file

Page 23: Unity scene file collaboration

(Inside .gitconfig)

[merge] tool = unityyamlmerge

[mergetool "unityyamlmerge"] trustExitCode = false cmd = '<path to UnityYAMLMerge> ' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"

UnityYAMLMerge

In Unity 5, a tool called “UnityYAMLMerge” was introduced.

It can be integrated as a pre-merge step in source control tools :

Page 24: Unity scene file collaboration

UnityYAMLMerge

(Demonstration on actual computer if possible)

Page 25: Unity scene file collaboration

Related Unity Milestones

Why were those workarounds created?

Unity 1.0 - Scenes are binary, can’t merge

Unity 3.0 - Textual version in Pro

Unity 3.5 - Textual version in Free

Unity 4.6.1 - Random IDs for documents

Unity 5 - UnityYAMLMerge

Page 26: Unity scene file collaboration

Not 100% automatic

In some cases, conflicts are real:

- Different changes are made to same components

- Child ordering is not always resolved in the diff. Manual fixups may be necessary.

- One changeset deletes an object, the other modifies it

These are real conflicts, and need to be solved like code conflicts.

Page 27: Unity scene file collaboration

Summary

- Unity .scene conflicts are scary if not understood

- Understanding the file format allows technical conflicts to be easily resolved (UnityYAMLMerge)

- Once they are solved, the real conflicts are easier to read and manage

Page 28: Unity scene file collaboration

Thank You!

(We’re hiring! [email protected] )

@noamgat


Recommended