public static Merge ( AssetList assets, MergeMethod method ) : |
||
assets | AssetList | The list of conflicting assets to be merged. |
method | MergeMethod | How to merge the assets. |
Résultat |
void OnGUI() { cancelled = false; GUILayout.Label("Conflicting files to resolve", EditorStyles.boldLabel); GUILayout.FlexibleSpace(); // I would use GUIUtility.GetLastRect() here after the box but that seems to have wierd side effects. Rect r1 = new Rect(6, 40, position.width - 12, position.height - 112); // 82 GUILayout.BeginArea(r1); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUILayout.EndArea(); bool repaint = resolveList.OnGUI(new Rect(r1.x + 2, r1.y + 2, r1.width - 4, r1.height - 4), true); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUI.enabled = assetList.Count > 0; GUILayout.Label("Resolve selection by:"); if (GUILayout.Button("using local version")) { SimpleMerge(ResolveMethod.UseMine); } if (GUILayout.Button("using incoming version")) { SimpleMerge(ResolveMethod.UseTheirs); } MergeMethod mergeMethod = MergeMethod.MergeNone; if (GUILayout.Button("merging")) { mergeMethod = MergeMethod.MergeAll; } if (mergeMethod != MergeMethod.MergeNone) { Task t = Provider.Merge(resolveList.SelectedAssets, mergeMethod); t.Wait(); if (t.success) { t = Provider.Resolve(t.assetList, ResolveMethod.UseMerged); t.Wait(); if (t.success) { // Check that there are not more conflicts for the specified // asset. This is possible in e.g. perforce where you handle // one version conflict at a time. t = Provider.Status(assetList); t.Wait(); DoOpen(t.assetList); if (t.success && assetList.Count == 0) { Close(); } // The view will be updated with the new conflicts } else { EditorUtility.DisplayDialog("Error resolving", "Error during resolve of files. Inspect log for details", "Close"); AssetDatabase.Refresh(); } } else { EditorUtility.DisplayDialog("Error merging", "Error during merge of files. Inspect log for details", "Close"); AssetDatabase.Refresh(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(12); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("Cancel")) { cancelled = true; Close(); } GUILayout.EndHorizontal(); GUILayout.Space(12); if (repaint) { Repaint(); } }
private void OnGUI() { this.cancelled = false; GUILayout.Label("Conflicting files to resolve", EditorStyles.boldLabel, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); Rect screenRect = new Rect(6f, 40f, base.position.width - 12f, base.position.height - 112f); GUILayout.BeginArea(screenRect); GUILayout.Box(string.Empty, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); GUILayout.EndArea(); bool flag = this.resolveList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = (this.assetList.Count > 0); GUILayout.Label("Resolve selection by:", new GUILayoutOption[0]); if (GUILayout.Button("using local version", new GUILayoutOption[0])) { AssetList selectedAssets = this.resolveList.SelectedAssets; Provider.Resolve(selectedAssets, ResolveMethod.UseMine).Wait(); AssetDatabase.Refresh(); base.Close(); } if (GUILayout.Button("using incoming version", new GUILayoutOption[0])) { AssetList selectedAssets2 = this.resolveList.SelectedAssets; Provider.Resolve(selectedAssets2, ResolveMethod.UseTheirs).Wait(); AssetDatabase.Refresh(); base.Close(); } MergeMethod mergeMethod = MergeMethod.MergeNone; if (GUILayout.Button("merging", new GUILayoutOption[0])) { mergeMethod = MergeMethod.MergeAll; } if (mergeMethod != MergeMethod.MergeNone) { Task task = Provider.Merge(this.resolveList.SelectedAssets, mergeMethod); task.Wait(); if (task.success) { task = Provider.Resolve(task.assetList, ResolveMethod.UseMerged); task.Wait(); if (task.success) { task = Provider.Status(this.assetList); task.Wait(); this.DoOpen(task.assetList); if (task.success && this.assetList.Count == 0) { base.Close(); } } else { EditorUtility.DisplayDialog("Error resolving", "Error during resolve of files. Inspect log for details", "Close"); AssetDatabase.Refresh(); } } else { EditorUtility.DisplayDialog("Error merging", "Error during merge of files. Inspect log for details", "Close"); AssetDatabase.Refresh(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(12f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("Cancel", new GUILayoutOption[0])) { this.cancelled = true; base.Close(); } GUILayout.EndHorizontal(); GUILayout.Space(12f); if (flag) { base.Repaint(); } }