public override IEnumerator Refresh()
{
//This is where we initiate the merge for the first time
var root = this.root;
root.components.Clear();
root.attributes.Clear();
var children = root.children;
if (children != null)
{
children.Clear();
}
var rootMine = root.mine;
var rootTheirs = root.theirs;
if (!rootMine || !rootTheirs)
{
yield break;
}
#if !Unity3
//Check if the objects are prefabs
switch (PrefabUtility.GetPrefabType(rootMine))
{
case PrefabType.ModelPrefab:
case PrefabType.Prefab:
switch (PrefabUtility.GetPrefabType(rootTheirs))
{
case PrefabType.ModelPrefab:
case PrefabType.Prefab:
if (EditorUtility.DisplayDialog("Instantiate prefabs?",
"In order to merge prefabs, you must instantiate them and merge the instances. Then you must apply the changes.",
"Instantiate", "Cancel"))
{
root.SetGameObjects(
PrefabUtility.InstantiatePrefab(rootMine) as GameObject,
PrefabUtility.InstantiatePrefab(rootTheirs) as GameObject);
}
else
{
root.SetGameObjects(null, null);
}
break;
default:
Debug.LogWarning("Sorry, you must compare a prefab with a prefab");
break;
}
break;
case PrefabType.DisconnectedPrefabInstance:
case PrefabType.PrefabInstance:
case PrefabType.ModelPrefabInstance:
case PrefabType.None:
switch (PrefabUtility.GetPrefabType(rootTheirs))
{
case PrefabType.DisconnectedPrefabInstance:
case PrefabType.PrefabInstance:
case PrefabType.ModelPrefabInstance:
case PrefabType.None:
break;
default:
Debug.LogWarning("Sorry, this prefab type is not supported");
break;
}
break;
default:
Debug.LogWarning("Sorry, this prefab type is not supported");
break;
}
#endif
updateType = RefreshType.Updating;
update = root.Refresh();
}