/// <summary> /// Finds all specific merge conflicts between two sets of GameObjects, /// representing "our" scene and "their" scene. /// </summary> /// <param name="ourObjects">The GameObjects of "our" version of the scene.</param> /// <param name="theirObjects">The GameObjects of "their" version of the scene.</param> protected void BuildAllMergeActions(List <GameObject> ourObjects, List <GameObject> theirObjects) { allMergeActions = new List <GameObjectMergeActions>(); //Map "their" GameObjects to their respective ids var theirObjectsDict = new Dictionary <ObjectID, GameObject>(); foreach (var theirs in theirObjects) { theirObjectsDict.Add(ObjectID.GetFor(theirs), theirs); } foreach (var ours in ourObjects) { //Try to find "their" equivalent to "our" GameObjects var id = ObjectID.GetFor(ours); GameObject theirs; theirObjectsDict.TryGetValue(id, out theirs); //If theirs is null, mergeActions.hasActions will be false var mergeActions = new GameObjectMergeActions(ours, theirs); if (mergeActions.hasActions) { allMergeActions.Add(mergeActions); } //Remove "their" GameObject from the dict to only keep those new to us theirObjectsDict.Remove(id); } //Every GameObject left in the dict is a... foreach (var theirs in theirObjectsDict.Values) { //...new GameObject from them var mergeActions = new GameObjectMergeActions(null, theirs); if (mergeActions.hasActions) { allMergeActions.Add(mergeActions); } } }
/// <summary> /// Finds all specific merge conflicts between two sets of GameObjects, /// representing "our" scene and "their" scene. /// </summary> /// <param name="ourObjects">The GameObjects of "our" version of the scene.</param> /// <param name="theirObjects">The GameObjects of "their" version of the scene.</param> protected void BuildAllMergeActions(List<GameObject> ourObjects, List<GameObject> theirObjects) { allMergeActions = new List<GameObjectMergeActions>(); //Map "their" GameObjects to their respective ids var theirObjectsDict = new Dictionary<int, GameObject>(); foreach(var theirs in theirObjects) { theirObjectsDict.Add(ObjectIDFinder.GetIdentifierFor(theirs), theirs); } foreach(var ours in ourObjects) { //Try to find "their" equivalent to "our" GameObjects var id = ObjectIDFinder.GetIdentifierFor(ours); GameObject theirs; theirObjectsDict.TryGetValue(id, out theirs); //If theirs is null, mergeActions.hasActions will be false var mergeActions = new GameObjectMergeActions(ours, theirs); if(mergeActions.hasActions) { allMergeActions.Add(mergeActions); } //Remove "their" GameObject from the dict to only keep those new to us theirObjectsDict.Remove(id); } //Every GameObject left in the dict is a... foreach(var theirs in theirObjectsDict.Values) { //...new GameObject from them var mergeActions = new GameObjectMergeActions(null, theirs); if(mergeActions.hasActions) { allMergeActions.Add(mergeActions); } } }