MergeActionDeleteGameObject.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace GitMerge
  4. {
  5. /// <summary>
  6. /// The MergeAction that handles a GameObject which exists in "our" version but not "theirs".
  7. /// </summary>
  8. public class MergeActionDeleteGameObject : MergeActionExistence
  9. {
  10. private bool oursWasActive;
  11. public MergeActionDeleteGameObject(GameObject ours, GameObject theirs)
  12. : base(ours, theirs)
  13. {
  14. oursWasActive = ours.activeSelf;
  15. if (GitMergeWindow.automerge)
  16. {
  17. UseOurs();
  18. }
  19. }
  20. protected override void ApplyOurs()
  21. {
  22. ours.SetActiveForMerging(true);
  23. ours.SetActive(oursWasActive);
  24. }
  25. protected override void ApplyTheirs()
  26. {
  27. ours.SetActiveForMerging(false);
  28. SceneView.RepaintAll();
  29. }
  30. public override void EnsureExistence()
  31. {
  32. UseOurs();
  33. }
  34. public override void OnGUI()
  35. {
  36. var defaultOptionColor = merged ? Color.gray : Color.white;
  37. GUI.color = usingOurs ? Color.green : defaultOptionColor;
  38. if (GUILayout.Button("Keep GameObject"))
  39. {
  40. UseOurs();
  41. }
  42. GUI.color = usingTheirs ? Color.green : defaultOptionColor;
  43. if (GUILayout.Button("Delete GameObject"))
  44. {
  45. UseTheirs();
  46. }
  47. }
  48. }
  49. }