diff --git a/Angels and Demons/Assets/Editor.meta b/Angels and Demons/Assets/Editor.meta new file mode 100644 index 0000000..4a7481e --- /dev/null +++ b/Angels and Demons/Assets/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 13c149b5679992c4aad3260153c5f7ae +folderAsset: yes +DefaultImporter: + userData: diff --git a/Angels and Demons/Assets/Editor/GameObjectExtensions.cs b/Angels and Demons/Assets/Editor/GameObjectExtensions.cs new file mode 100644 index 0000000..dc2e74a --- /dev/null +++ b/Angels and Demons/Assets/Editor/GameObjectExtensions.cs @@ -0,0 +1,67 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; + +namespace GitMerge +{ + public static class GameObjectExtensions + { + /// + /// Adds the copy of a Component to a GameObject. + /// + /// The GameObject that will get the new Component + /// The original component to copy + /// The reference to the newly added Component copy + public static Component AddComponent(this GameObject go, Component original) + { + var c = go.AddComponent(original.GetType()); + + var originalSerialized = new SerializedObject(original).GetIterator(); + var nso = new SerializedObject(c); + var newSerialized = nso.GetIterator(); + + if(originalSerialized.Next(true)) + { + newSerialized.Next(true); + + while(originalSerialized.NextVisible(true)) + { + newSerialized.NextVisible(true); + newSerialized.SetValue(originalSerialized.GetValue()); + } + } + + nso.ApplyModifiedProperties(); + + return c; + } + + /// + /// Activates/deactivates the GameObjct, and hides it when it is disabled. + /// This is used for "their" objects to hide them while merging. + /// + /// The object do enable/disable + /// Enable or disable the object? + public static void SetActiveForMerging(this GameObject go, bool active) + { + go.SetActive(active); + go.hideFlags = active ? HideFlags.None : HideFlags.HideAndDontSave; + } + + /// + /// Ping the GameObject in the hierarchy, select it, and center it in the scene view. + /// + /// The GameObject of interest + public static void Highlight(this GameObject go) + { + Selection.activeGameObject = go; + EditorGUIUtility.PingObject(go); + + var view = SceneView.lastActiveSceneView; + if(view) + { + view.FrameSelected(); + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/GameObjectExtensions.cs.meta b/Angels and Demons/Assets/Editor/GameObjectExtensions.cs.meta new file mode 100644 index 0000000..cdab8fe --- /dev/null +++ b/Angels and Demons/Assets/Editor/GameObjectExtensions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 327c0f7ed6330514791026c2d1ba5a5c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/GameObjectMergeActions.cs b/Angels and Demons/Assets/Editor/GameObjectMergeActions.cs new file mode 100644 index 0000000..3c079aa --- /dev/null +++ b/Angels and Demons/Assets/Editor/GameObjectMergeActions.cs @@ -0,0 +1,362 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GitMerge +{ + /// + /// One instance of this class represents one GameObject with relevance to the merge process. + /// Holds all MergeActions that can be applied to the GameObject or its Components. + /// Is considered as "merged" when all its MergeActions are "merged". + /// + public class GameObjectMergeActions + { + /// + /// Reference to "our" version of the GameObject. + /// + public GameObject ours { private set; get; } + /// + /// Reference to "their" versoin of the GameObject. + /// + public GameObject theirs { private set; get; } + + private string name; + public bool merged { private set; get; } + public bool hasActions + { + get { return actions.Count > 0; } + } + /// + /// All actions available for solving specific conflicts on the GameObject. + /// + private List actions; + + + public GameObjectMergeActions(GameObject ours, GameObject theirs) + { + actions = new List(); + + this.ours = ours; + this.theirs = theirs; + GenerateName(); + + if(theirs && !ours) + { + actions.Add(new MergeActionNewGameObject(ours, theirs)); + } + if(ours && !theirs) + { + actions.Add(new MergeActionDeleteGameObject(ours, theirs)); + } + if(ours && theirs) + { + FindPropertyDifferences(); + FindComponentDifferences(); + } + + //Some Actions have a default and are merged from the beginning. + //If all the others did was to add GameObjects, we're done with merging from the start. + CheckIfMerged(); + } + + /// + /// Generate a title for this object + /// + private void GenerateName() + { + name = ""; + if(ours) + { + name = "Your[" + GetPath(ours) + "]"; + } + if(theirs) + { + if(ours) + { + name += " vs. "; + } + name += "Their[" + GetPath(theirs) + "]"; + } + } + + /// + /// Finds the differences between properties of the two GameObjects. + /// That means the name, layer, tag... everything that's not part of a Component. Also, the parent. + /// + private void FindPropertyDifferences() + { + CheckForDifferentParents(); + FindPropertyDifferences(ours, theirs); + } + + /// + /// Since parenting is quite special, here's some dedicated handling. + /// + private void CheckForDifferentParents() + { + var transform = ours.GetComponent(); + var ourParent = transform.parent; + var theirParent = theirs.GetComponent().parent; + if(ourParent != theirParent) + { + actions.Add(new MergeActionParenting(transform, ourParent, theirParent)); + } + } + + /// + /// Check for Components that one of the sides doesn't have, and/or for defferent values + /// on Components. + /// + private void FindComponentDifferences() + { + var ourComponents = ours.GetComponents(); + var theirComponents = theirs.GetComponents(); + + //Map "their" Components to their respective ids + var theirDict = new Dictionary(); + foreach(var theirComponent in theirComponents) + { + //Ignore null components + if(theirComponent != null) + { + theirDict.Add(ObjectIDFinder.GetIdentifierFor(theirComponent), theirComponent); + } + } + + foreach(var ourComponent in ourComponents) + { + //Ignore null components + if(ourComponent == null) continue; + + //Try to find "their" equivalent to our Components + var id = ObjectIDFinder.GetIdentifierFor(ourComponent); + Component theirComponent; + theirDict.TryGetValue(id, out theirComponent); + + if(theirComponent) //Both Components exist + { + FindPropertyDifferences(ourComponent, theirComponent); + //Remove "their" Component from the dict to only keep those new to us + theirDict.Remove(id); + } + else //Component doesn't exist in their version, offer a deletion + { + actions.Add(new MergeActionDeleteComponent(ours, ourComponent)); + } + } + + //Everything left in the dict is a... + foreach(var theirComponent in theirDict.Values) + { + //...new Component from them + actions.Add(new MergeActionNewComponent(ours, theirComponent)); + } + } + + /// + /// Find all the values different in "our" and "their" version of a component. + /// + private void FindPropertyDifferences(Object ourObject, Object theirObject) + { + var ourSerialized = new SerializedObject(ourObject); + var theirSerialized = new SerializedObject(theirObject); + + var ourProperty = ourSerialized.GetIterator(); + if(ourProperty.NextVisible(true)) + { + var theirProperty = theirSerialized.GetIterator(); + theirProperty.NextVisible(true); + while(ourProperty.NextVisible(false)) + { + theirProperty.NextVisible(false); + + if(ourObject is GameObject) + { + if(MergeManager.isMergingPrefab) + { + //If merging a prefab, ignore the gameobject name. + if(ourProperty.GetPlainName() == "Name") + { + continue; + } + } + } + + if(DifferentValues(ourProperty, theirProperty)) + { + //We found a difference, accordingly add a MergeAction + actions.Add(new MergeActionChangeValues(ours, ourObject, ourProperty.Copy(), theirProperty.Copy())); + } + } + } + } + + /// + /// Returns true when the two properties have different values, false otherwise. + /// + private static bool DifferentValues(SerializedProperty ourProperty, SerializedProperty theirProperty) + { + if(!ourProperty.IsRealArray()) + { + //Regular single-value property + if(DifferentValuesFlat(ourProperty, theirProperty)) + { + return true; + } + } + else + { + //Array property + if(ourProperty.arraySize != theirProperty.arraySize) + { + return true; + } + + var op = ourProperty.Copy(); + var tp = theirProperty.Copy(); + + op.Next(true); + op.Next(true); + tp.Next(true); + tp.Next(true); + + for(int i = 0; i < ourProperty.arraySize; ++i) + { + op.Next(false); + tp.Next(false); + + if(DifferentValuesFlat(op, tp)) + { + return true; + } + } + } + + return false; + } + + private static bool DifferentValuesFlat(SerializedProperty ourProperty, SerializedProperty theirProperty) + { + var our = ourProperty.GetValue(true); + var their = theirProperty.GetValue(true); + + return !object.Equals(our, their); + } + + /// + /// Get the path of a GameObject in the hierarchy. + /// + private static string GetPath(GameObject g) + { + var t = g.transform; + var sb = new StringBuilder(t.name); + while(t.parent != null) + { + t = t.parent; + sb.Insert(0, t.name + "/"); + } + return sb.ToString(); + } + + private void CheckIfMerged() + { + merged = actions.TrueForAll(action => action.merged); + } + + /// + /// Use "our" version for all conflicts. + /// This is used on all GameObjectMergeActions objects when the merge is aborted. + /// + public void UseOurs() + { + foreach(var action in actions) + { + action.UseOurs(); + } + merged = true; + } + + /// + /// Use "their" version for all conflicts. + /// + public void UseTheirs() + { + foreach(var action in actions) + { + action.UseTheirs(); + } + merged = true; + } + + //If the foldout is open + private bool open; + public void OnGUI() + { + if(open) + { + GUI.backgroundColor = new Color(0, 0, 0, .8f); + } + else + { + GUI.backgroundColor = merged ? new Color(0, .5f, 0, .8f) : new Color(.5f, 0, 0, .8f); + } + GUILayout.BeginVertical(Resources.styles.mergeActions); + GUI.backgroundColor = Color.white; + + GUILayout.BeginHorizontal(); + open = EditorGUILayout.Foldout(open, new GUIContent(name)); + + if(ours && GUILayout.Button("Focus", EditorStyles.miniButton, GUILayout.Width(100))) + { + //Highlight the instance of the prefab, not the prefab itself + //Otherwise, "ours". + var objectToHighlight = MergeManager.isMergingPrefab ? MergeManagerPrefab.ourPrefabInstance : ours; + objectToHighlight.Highlight(); + } + GUILayout.EndHorizontal(); + + if(open) + { + //Display all merge actions. + foreach(var action in actions) + { + if(action.OnGUIMerge()) + { + CheckIfMerged(); + } + } + } + else + { + GUILayout.BeginHorizontal(); + if(GUILayout.Button("Use ours >>>", EditorStyles.miniButton)) + { + UseOurs(); + } + + if(GUILayout.Button("<<< Use theirs", EditorStyles.miniButton)) + { + UseTheirs(); + } + GUILayout.EndHorizontal(); + } + + //If "ours" is null, the GameObject doesn't exist in one of the versions. + //Try to get a reference if the object exists in the current merging state. + //If it exists, the new/gelete MergeAction will have a reference. + if(!ours) + { + foreach(var action in actions) + { + ours = action.ours; + } + } + + GUILayout.EndVertical(); + + GUI.backgroundColor = Color.white; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/GameObjectMergeActions.cs.meta b/Angels and Demons/Assets/Editor/GameObjectMergeActions.cs.meta new file mode 100644 index 0000000..d5271c8 --- /dev/null +++ b/Angels and Demons/Assets/Editor/GameObjectMergeActions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfa76c0e71adc0f439476432ffe37fa3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/GitMergeWindow.cs b/Angels and Demons/Assets/Editor/GitMergeWindow.cs new file mode 100644 index 0000000..d200368 --- /dev/null +++ b/Angels and Demons/Assets/Editor/GitMergeWindow.cs @@ -0,0 +1,255 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; + +namespace GitMerge +{ + /// + /// The window that lets you perform merges on scenes and prefabs. + /// + public class GitMergeWindow : EditorWindow + { + private VCS vcs = new VCSGit(); + + //EditorPrefs keys for settings + private const string epAutomerge = "GitMerge_automerge"; + private const string epAutofocus = "GitMerge_autofocus"; + + //Settings + public static bool automerge { private set; get; } + public static bool autofocus { private set; get; } + + //The MergeManager that has the actual merging logic + private MergeManager manager; + + public bool mergeInProgress + { + get + { + return manager != null; + } + } + + private Vector2 scrollPosition = Vector2.zero; + private int tab = 0; + + + [MenuItem("Window/GitMerge")] + static void OpenEditor() + { + var window = EditorWindow.GetWindow(typeof(GitMergeWindow), false, "GitMerge"); + //In case we're merging and the scene becomes edited, + //the shown SerializedProperties should be repainted + window.autoRepaintOnSceneChange = true; + window.minSize = new Vector2(500, 100); + } + + void OnEnable() + { + LoadSettings(); + } + + private static void LoadSettings() + { + if(EditorPrefs.HasKey(epAutomerge)) + { + automerge = EditorPrefs.GetBool(epAutomerge); + } + else + { + automerge = true; + } + if(EditorPrefs.HasKey(epAutofocus)) + { + autofocus = EditorPrefs.GetBool(epAutofocus); + } + else + { + autofocus = true; + } + } + + void OnHierarchyChange() + { + //Repaint if we changed the scene + this.Repaint(); + } + + //Always check for editor state changes, and abort the active merge process if needed + void Update() + { + if(MergeAction.inMergePhase + && (EditorApplication.isCompiling + || EditorApplication.isPlayingOrWillChangePlaymode)) + { + ShowNotification(new GUIContent("Aborting merge due to editor state change.")); + AbortMerge(); + } + } + + private void AbortMerge() + { + manager.AbortMerge(); + manager = null; + } + + void OnGUI() + { + Resources.DrawLogo(); + DrawTabButtons(); + + switch(tab) + { + case 0: + OnGUISceneTab(); + break; + + case 1: + OnGUIPrefabTab(); + break; + + default: + OnGUISettingsTab(); + break; + } + } + + /// + /// Tab that offers scene merging. + /// + private void OnGUISceneTab() + { + GUILayout.Label("Open Scene: " + EditorApplication.currentScene); + if(EditorApplication.currentScene != "" + && !mergeInProgress + && GUILayout.Button("Start merging this scene", GUILayout.Height(80))) + { + var mm = new MergeManagerScene(this, vcs); + if(mm.InitializeMerge()) + { + manager = mm; + } + } + + DisplayMergeProcess(); + } + + /// + /// Tab that offers prefab merging. + /// + private void OnGUIPrefabTab() + { + GameObject prefab; + if(!mergeInProgress) + { + GUILayout.Label("Drag your prefab here to start merging:"); + if(prefab = EditorGUILayout.ObjectField(null, typeof(GameObject), false, GUILayout.Height(60)) as GameObject) + { + var mm = new MergeManagerPrefab(this, vcs); + if(mm.InitializeMerge(prefab)) + { + manager = mm; + } + } + } + + DisplayMergeProcess(); + } + + /// + /// Tab that offers various settings for the tool. + /// + private void OnGUISettingsTab() + { + var vcsPath = vcs.exe(); + var vcsPathNew = EditorGUILayout.TextField("Path to git.exe", vcsPath); + if(vcsPath != vcsPathNew) + { + vcs.SetPath(vcsPathNew); + } + + var amNew = EditorGUILayout.Toggle("Automerge", automerge); + if(automerge != amNew) + { + automerge = amNew; + EditorPrefs.SetBool(epAutomerge, automerge); + } + GUILayout.Label("(Automerge new/deleted GameObjects/Components upon merge start)"); + + var afNew = EditorGUILayout.Toggle("Auto Highlight", autofocus); + if(autofocus != afNew) + { + autofocus = afNew; + EditorPrefs.SetBool(epAutofocus, autofocus); + } + GUILayout.Label("(Highlight GameObjects when applying a MergeAction to it)"); + } + + /// + /// If no merge is in progress, draws the buttons to switch between tabs. + /// Otherwise, draws the "abort merge" button. + /// + private void DrawTabButtons() + { + if(!mergeInProgress) + { + string[] tabs = { "Merge Scene", "Merge Prefab", "Settings" }; + tab = GUI.SelectionGrid(new Rect(72, 36, 300, 22), tab, tabs, 3); + } + else + { + GUI.backgroundColor = new Color(1,0.4f,0.4f,1); + if(GUI.Button(new Rect(72, 36, 300, 22), "Abort merge")) + { + manager.AbortMerge(); + manager = null; + } + GUI.backgroundColor = Color.white; + } + } + + /// + /// Displays all MergeActions and the "apply merge" button if a merge is in progress. + /// + private void DisplayMergeProcess() + { + if(mergeInProgress) + { + var done = DisplayMergeActions(); + GUILayout.BeginHorizontal(); + if(done && GUILayout.Button("Apply merge")) + { + manager.CompleteMerge(); + manager = null; + } + GUILayout.EndHorizontal(); + } + } + + /// + /// Displays all GameObjectMergeActions. + /// + /// True, if all MergeActions are flagged as "merged". + private bool DisplayMergeActions() + { + scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true); + GUILayout.BeginVertical(GUILayout.MinWidth(480)); + + var textColor = GUI.skin.label.normal.textColor; + GUI.skin.label.normal.textColor = Color.black; + + var done = true; + foreach(var actions in manager.allMergeActions) + { + actions.OnGUI(); + done = done && actions.merged; + } + + GUI.skin.label.normal.textColor = textColor; + + GUILayout.EndVertical(); + GUILayout.EndScrollView(); + return done; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/GitMergeWindow.cs.meta b/Angels and Demons/Assets/Editor/GitMergeWindow.cs.meta new file mode 100644 index 0000000..53ddc40 --- /dev/null +++ b/Angels and Demons/Assets/Editor/GitMergeWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aaa504546605b3a479405bee3c11cd04 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeAction.cs b/Angels and Demons/Assets/Editor/MergeAction.cs new file mode 100644 index 0000000..4df45a4 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeAction.cs @@ -0,0 +1,154 @@ +using UnityEngine; +using UnityEditor; +using System.Collections; + +namespace GitMerge +{ + /// + /// Each MergeAction represents a single, specific merge conflict. + /// This can be a GameObject added or deleted in one of the versions, + /// a Component added or deleted on a GameObject, + /// or a single property changed on a Component. + /// + public abstract class MergeAction + { + //Don't highlight objects if not in merge phase. + //Prevents highlighting while automerging. + public static bool inMergePhase; + + //A MergeAction is considere "merged" when, at some point, + //"our", "their" or a new version has been applied. + public bool merged { protected set; get; } + + public GameObject ours { protected set; get; } + public GameObject theirs { protected set; get; } + + //Flags that indicate how this MergeAction has been resolved. + protected bool usingOurs; + protected bool usingTheirs; + protected bool usingNew; + //True when this action has been automatically resolved + protected bool automatic; + + + public MergeAction(GameObject ours, GameObject theirs) + { + this.ours = ours; + this.theirs = theirs; + } + + public void UseOurs() + { + try + { + ApplyOurs(); + } + catch + { + return; + } + merged = true; + usingOurs = true; + usingTheirs = false; + usingNew = false; + + automatic = !inMergePhase; + + if(GitMergeWindow.autofocus) + { + HighlightObject(); + } + + RefreshPrefabInstance(); + } + public void UseTheirs() + { + try + { + ApplyTheirs(); + } + catch + { + return; + } + merged = true; + usingOurs = false; + usingTheirs = true; + usingNew = false; + + automatic = !inMergePhase; + + if(GitMergeWindow.autofocus) + { + HighlightObject(); + } + + RefreshPrefabInstance(); + } + public void UsedNew() + { + merged = true; + usingOurs = false; + usingTheirs = false; + usingNew = true; + + automatic = !inMergePhase; + + RefreshPrefabInstance(); + } + + /// + /// Refreshes the prefab instance, if there is any. + /// We change the prefab directly, so we have to do this to see the changes in the scene view. + /// + private static void RefreshPrefabInstance() + { + if(MergeManager.isMergingPrefab) + { + PrefabUtility.ResetToPrefabState(MergeManagerPrefab.ourPrefabInstance); + } + } + + //The implementations of these methods conatain the actual merging steps + protected abstract void ApplyOurs(); + protected abstract void ApplyTheirs(); + + /// + /// Displays the MergeAction. + /// + /// True when the represented conflict has now been merged. + public bool OnGUIMerge() + { + var wasMerged = merged; + if(merged) + { + GUI.backgroundColor = automatic ? new Color(.9f, .9f, .3f, 1) : new Color(.2f, .8f, .2f, 1); + } + else + { + GUI.backgroundColor = new Color(1f, .25f, .25f, 1); + } + GUILayout.BeginHorizontal(Resources.styles.mergeAction); + GUI.backgroundColor = Color.white; + OnGUI(); + GUI.color = Color.white; + GUILayout.EndHorizontal(); + return merged && !wasMerged; + } + + //The actual UI of the MergeAction depends on the actual type + public abstract void OnGUI(); + + private void HighlightObject() + { + //Highlight the instance of the prefab, not the prefab itself + //Otherwise, "ours". + var objectToHighlight = MergeManager.isMergingPrefab ? MergeManagerPrefab.ourPrefabInstance : ours; + + if(objectToHighlight && inMergePhase && objectToHighlight.hideFlags == HideFlags.None) + { + objectToHighlight.Highlight(); + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeAction.cs.meta b/Angels and Demons/Assets/Editor/MergeAction.cs.meta new file mode 100644 index 0000000..8befe59 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d9583c639208c1e49b6cc77e128f7ccb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionChangeValues.cs b/Angels and Demons/Assets/Editor/MergeActionChangeValues.cs new file mode 100644 index 0000000..84f217a --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionChangeValues.cs @@ -0,0 +1,268 @@ +using UnityEngine; +using UnityEditor; +using System.Collections; +using System.Linq; + +namespace GitMerge +{ + /// + /// The MergeAction allowing to merge the value of a single property of a Component. + /// + public class MergeActionChangeValues : MergeAction + { + protected SerializedProperty ourProperty; + protected SerializedProperty theirProperty; + protected object ourInitialValue; + protected object theirInitialValue; + protected readonly string ourString; + protected readonly string theirString; + protected readonly string fieldname; + protected Object ourObject; + + public MergeActionChangeValues(GameObject ours, Object ourObject, SerializedProperty ourProperty, SerializedProperty theirProperty) + : base(ours, null) + { + this.ourObject = ourObject; + + this.ourProperty = ourProperty; + this.theirProperty = theirProperty; + + fieldname = ourObject.GetPlainType() + "." + ourProperty.GetPlainName(); + + ourInitialValue = ourProperty.GetValue(); + theirInitialValue = theirProperty.GetValue(); + + ourString = SerializedValueString(ourProperty); + theirString = SerializedValueString(theirProperty); + } + + protected override void ApplyOurs() + { + ourProperty.SetValue(ourInitialValue); + ourProperty.serializedObject.ApplyModifiedProperties(); + } + + protected override void ApplyTheirs() + { + var value = theirInitialValue; + + //If we're about references here, get "our" version of the object. + if(ourProperty.propertyType == SerializedPropertyType.ObjectReference) + { + var id = ObjectIDFinder.GetIdentifierFor(theirInitialValue as Object); + var obj = ObjectDictionaries.GetOurObject(id); + + //If we didn't have our own version of the object before, it must be new + if(!obj) + { + //Get our copy of the new object if it exists + obj = ObjectDictionaries.GetOurInstanceOfCopy(value as Object); + } + + value = obj; + } + + ourProperty.SetValue(value); + ourProperty.serializedObject.ApplyModifiedProperties(); + } + + public override void OnGUI() + { + GUILayout.BeginVertical(); + GUILayout.Label(fieldname + ": " + ourProperty.propertyType); + + GUILayout.BeginHorizontal(); + + GUILayout.BeginVertical(); + GUILayout.Label(ourString, GUILayout.Width(100)); + DisplayArray(ourInitialValue); + GUILayout.EndVertical(); + + if(MergeButton(">>>", usingOurs)) + { + UseOurs(); + } + + var c = GUI.backgroundColor; + GUI.backgroundColor = Color.white; + + //GUILayout.Label(ourProperty.propertyType + "/" + ourProperty.type + ": " + ourProperty.GetValue()); + PropertyField(ourProperty); + + GUI.backgroundColor = c; + + if(MergeButton("<<<", usingTheirs)) + { + UseTheirs(); + } + + GUILayout.BeginVertical(); + GUILayout.Label(theirString, GUILayout.Width(100)); + DisplayArray(theirInitialValue); + GUILayout.EndVertical(); + + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + } + + private void DisplayArray(object value) + { + if(ourProperty.IsRealArray() && ourProperty.isExpanded) + { + var values = (object[])value; + for(int i = 0; i < values.Length; ++i) + { + GUILayout.Label(ValueString(values[i]), GUILayout.Width(100)); + } + } + } + + /// + /// Displays the property field in the center of the window. + /// This method distinguishes between certain properties. + /// The GameObject tag, for example, shouldn't be displayed with a regular string field. + /// + /// The SerializedProerty to display + /// The width of the whole thing in the ui + private void PropertyField(SerializedProperty p, float width = 170) + { + if(p.IsRealArray()) + { + DisplayArrayProperty(p, width); + } + else + { + var oldValue = p.GetValue(); + if(fieldname == "GameObject.TagString") + { + var oldTag = oldValue as string; + var newTag = EditorGUILayout.TagField("", oldTag, GUILayout.Width(width)); + if(newTag != oldTag) + { + p.SetValue(newTag); + } + } + else if(fieldname == "GameObject.StaticEditorFlags") + { + DisplayStaticFlagChooser(p, width); + } + else + { + EditorGUILayout.PropertyField(p, new GUIContent(""), GUILayout.Width(width)); + } + if(!object.Equals(p.GetValue(), oldValue)) + { + p.serializedObject.ApplyModifiedProperties(); + UsedNew(); + } + } + } + + private void DisplayArrayProperty(SerializedProperty p, float width) + { + GUILayout.BeginVertical(); + GUILayout.BeginHorizontal(GUILayout.Width(170)); + EditorGUILayout.PropertyField(p, new GUIContent("Array"), GUILayout.Width(80)); + if(p.isExpanded) + { + var copy = p.Copy(); + var size = copy.arraySize; + + copy.Next(true); + copy.Next(true); + + PropertyField(copy, 70); + GUILayout.EndHorizontal(); + + for(int i = 0; i < size; ++i) + { + copy.Next(false); + PropertyField(copy); + } + } + else + { + GUILayout.EndHorizontal(); + } + GUILayout.EndVertical(); + } + + /// + /// Displays Toggles that let the user set the static flags of the object. + /// + /// The StaticEditorFlags SerializedProperty to display + /// The width of the whole thing in the ui + private void DisplayStaticFlagChooser(SerializedProperty p, float width) + { + var flags = (StaticEditorFlags)p.intValue; + GUILayout.BeginVertical(GUILayout.Width(width)); + + p.isExpanded = EditorGUILayout.Foldout(p.isExpanded, SerializedValueString(p)); + var allOn = true; + if(p.isExpanded) + { + foreach(var flag in System.Enum.GetValues(typeof(StaticEditorFlags)).Cast()) + { + var wasOn = (flags & flag) != 0; + var on = EditorGUILayout.Toggle(flag + "", wasOn); + if(wasOn != on) + { + flags = flags ^ flag; + } + if(!on) + { + allOn = false; + } + } + } + if(allOn) + { + flags = (StaticEditorFlags)(-1); + } + p.intValue = (int)flags; + + GUILayout.EndVertical(); + } + + private string SerializedValueString(SerializedProperty p) + { + if(fieldname == "GameObject.StaticEditorFlags") + { + switch(p.intValue) + { + case 0: + return "Not static"; + case -1: + return "Static"; + default: + return "Mixed static"; + } + } + else if(p.IsRealArray()) + { + return "Array[" + p.arraySize + "]"; + } + return ValueString(p.GetValue()); + } + + private static string ValueString(object o) + { + if(o == null) + { + return "[none]"; + } + return o.ToString(); + } + + private static bool MergeButton(string text, bool green) + { + if(green) + { + GUI.color = Color.green; + } + bool result = GUILayout.Button(text, GUILayout.ExpandWidth(false)); + GUI.color = Color.white; + return result; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionChangeValues.cs.meta b/Angels and Demons/Assets/Editor/MergeActionChangeValues.cs.meta new file mode 100644 index 0000000..7c65940 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionChangeValues.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9a327ed62a5572a459e54869df134f42 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionDeleteComponent.cs b/Angels and Demons/Assets/Editor/MergeActionDeleteComponent.cs new file mode 100644 index 0000000..d080ee1 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionDeleteComponent.cs @@ -0,0 +1,71 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + /// + /// The MergeAction that handles a Component which exists in "their" version but not "ours". + /// + public class MergeActionDeleteComponent : MergeActionExistence + { + protected Component ourComponent; + protected Component copy; + + public MergeActionDeleteComponent(GameObject ours, Component ourComponent) + : base(ours, null) + { + this.ourComponent = ourComponent; + + var go = new GameObject("GitMerge Object"); + go.SetActiveForMerging(false); + + copy = go.AddComponent(ourComponent); + + if(GitMergeWindow.automerge) + { + UseOurs(); + } + } + + protected override void ApplyOurs() + { + if(ourComponent == null) + { + ourComponent = ours.AddComponent(copy); + ObjectDictionaries.SetAsOurObject(ourComponent); + } + } + + protected override void ApplyTheirs() + { + if(ourComponent != null) + { + ObjectDictionaries.RemoveOurObject(ourComponent); + Object.DestroyImmediate(ourComponent, true); + } + } + + public override void EnsureExistence() + { + UseOurs(); + } + + public override void OnGUI() + { + GUILayout.Label(copy.GetPlainType()); + + var defaultOptionColor = merged ? Color.gray : Color.white; + + GUI.color = usingOurs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Keep Component")) + { + UseOurs(); + } + GUI.color = usingTheirs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Delete Component")) + { + UseTheirs(); + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionDeleteComponent.cs.meta b/Angels and Demons/Assets/Editor/MergeActionDeleteComponent.cs.meta new file mode 100644 index 0000000..b8a5cb9 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionDeleteComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6414ac2f8bebc8b4bb33597977332630 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionDeleteGameObject.cs b/Angels and Demons/Assets/Editor/MergeActionDeleteGameObject.cs new file mode 100644 index 0000000..316cc9b --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionDeleteGameObject.cs @@ -0,0 +1,57 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + /// + /// The MergeAction that handles a GameObject which exists in "our" version but not "theirs". + /// + public class MergeActionDeleteGameObject : MergeActionExistence + { + private bool oursWasActive; + + public MergeActionDeleteGameObject(GameObject ours, GameObject theirs) + : base(ours, theirs) + { + oursWasActive = ours.activeSelf; + + if(GitMergeWindow.automerge) + { + UseOurs(); + } + } + + protected override void ApplyOurs() + { + ours.SetActiveForMerging(true); + ours.SetActive(oursWasActive); + } + + protected override void ApplyTheirs() + { + ours.SetActiveForMerging(false); + SceneView.currentDrawingSceneView.Repaint(); + } + + public override void EnsureExistence() + { + UseOurs(); + } + + public override void OnGUI() + { + var defaultOptionColor = merged ? Color.gray : Color.white; + + GUI.color = usingOurs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Keep GameObject")) + { + UseOurs(); + } + GUI.color = usingTheirs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Delete GameObject")) + { + UseTheirs(); + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionDeleteGameObject.cs.meta b/Angels and Demons/Assets/Editor/MergeActionDeleteGameObject.cs.meta new file mode 100644 index 0000000..24955ab --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionDeleteGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 627176a0f25069f46919f6e3489eb8c3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionExistence.cs b/Angels and Demons/Assets/Editor/MergeActionExistence.cs new file mode 100644 index 0000000..7c3a4ba --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionExistence.cs @@ -0,0 +1,23 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + /// + /// The abstract base MergeAction for all MergeActions that manage whether or not an object exists + /// + public abstract class MergeActionExistence : MergeAction + { + public MergeActionExistence(GameObject ours, GameObject theirs) + : base(ours, theirs) + { + ObjectDictionaries.AddToSchroedingersObjects(ours ?? theirs, this); + } + + /// + /// Apply whatever version that has the object existing, since it might be needed somewhere. + /// When overriding, call either UseOurs or UseTheirs to make sure to trigger the side effects. + /// + public abstract void EnsureExistence(); + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionExistence.cs.meta b/Angels and Demons/Assets/Editor/MergeActionExistence.cs.meta new file mode 100644 index 0000000..bb9395f --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionExistence.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f94b44d1572d0d14ea949190ef678a3a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionNewComponent.cs b/Angels and Demons/Assets/Editor/MergeActionNewComponent.cs new file mode 100644 index 0000000..ca6c760 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionNewComponent.cs @@ -0,0 +1,66 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + /// + /// The MergeAction that handles Components that exist in "our" version but not in "theirs". + /// + public class MergeActionNewComponent : MergeActionExistence + { + protected Component ourComponent; + protected Component theirComponent; + + public MergeActionNewComponent(GameObject ours, Component theirComponent) + : base(ours, null) + { + this.theirComponent = theirComponent; + + if(GitMergeWindow.automerge) + { + UseOurs(); + } + } + + protected override void ApplyOurs() + { + if(ourComponent) + { + ObjectDictionaries.RemoveCopyOf(theirComponent); + Object.DestroyImmediate(ourComponent, true); + } + } + + protected override void ApplyTheirs() + { + if(!ourComponent) + { + ourComponent = ours.AddComponent(theirComponent); + ObjectDictionaries.SetAsCopy(ourComponent, theirComponent); + } + } + + public override void EnsureExistence() + { + UseTheirs(); + } + + public override void OnGUI() + { + GUILayout.Label(theirComponent.GetPlainType()); + + var defaultOptionColor = merged ? Color.gray : Color.white; + + GUI.color = usingOurs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Don't add Component")) + { + UseOurs(); + } + GUI.color = usingTheirs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Add new Component")) + { + UseTheirs(); + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionNewComponent.cs.meta b/Angels and Demons/Assets/Editor/MergeActionNewComponent.cs.meta new file mode 100644 index 0000000..69410cd --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionNewComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6c13706c0946b934a95c41957ce759f5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionNewGameObject.cs b/Angels and Demons/Assets/Editor/MergeActionNewGameObject.cs new file mode 100644 index 0000000..1459aab --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionNewGameObject.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + /// + /// The MergeAction that handles GameObjects that exist in "their" version but not in "ours". + /// + public class MergeActionNewGameObject : MergeActionExistence + { + public MergeActionNewGameObject(GameObject ours, GameObject theirs) + : base(ours, theirs) + { + if(GitMergeWindow.automerge) + { + UseTheirs(); + } + } + + protected override void ApplyOurs() + { + if(ours) + { + ObjectDictionaries.RemoveCopyOf(theirs); + GameObject.DestroyImmediate(ours, true); + } + } + + protected override void ApplyTheirs() + { + if(!ours) + { + ours = ObjectDictionaries.InstantiateFromMerging(theirs); + ObjectDictionaries.SetAsCopy(ours, theirs); + } + } + + public override void EnsureExistence() + { + UseTheirs(); + } + + public override void OnGUI() + { + var defaultOptionColor = merged ? Color.gray : Color.white; + + GUI.color = usingOurs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Don't add GameObject")) + { + UseOurs(); + } + GUI.color = usingTheirs ? Color.green : defaultOptionColor; + if(GUILayout.Button("Add new GameObject")) + { + UseTheirs(); + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionNewGameObject.cs.meta b/Angels and Demons/Assets/Editor/MergeActionNewGameObject.cs.meta new file mode 100644 index 0000000..012ff36 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionNewGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb60feef4712bcc4a9f2d266c289a2d7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeActionParenting.cs b/Angels and Demons/Assets/Editor/MergeActionParenting.cs new file mode 100644 index 0000000..eef3bea --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionParenting.cs @@ -0,0 +1,97 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + /// + /// The MergeAction that handles a differing parents for a Transform. + /// + public class MergeActionParenting : MergeAction + { + private Transform transform; + private Transform ourParent; + private Transform theirParent; + + public MergeActionParenting(Transform transform, Transform ourParent, Transform theirParent) + : base(transform.gameObject, null) + { + this.transform = transform; + this.ourParent = ourParent; + this.theirParent = theirParent; + } + + protected override void ApplyOurs() + { + transform.parent = ourParent; + } + + protected override void ApplyTheirs() + { + var ourVersion = ObjectDictionaries.GetOurCounterpartFor(theirParent) as Transform; + if(theirParent && !ourVersion) + { + if(EditorUtility.DisplayDialog("The chosen parent currently does not exist.", "Do you want do add it?", "Yes", "No")) + { + ObjectDictionaries.EnsureExistence(theirParent.gameObject); + ourVersion = ObjectDictionaries.GetOurCounterpartFor(theirParent) as Transform; + + transform.parent = ourVersion; + } + else + { + throw new System.Exception("User Abort."); + } + } + else + { + transform.parent = ourVersion; + } + } + + public override void OnGUI() + { + GUILayout.BeginVertical(); + GUILayout.Label("Parent"); + + GUILayout.BeginHorizontal(); + + GUILayout.Label(ourParent ? ourParent.ToString() : "None", GUILayout.Width(100)); + + if(MergeButton(">>>", usingOurs)) + { + UseOurs(); + } + + var c = GUI.backgroundColor; + GUI.backgroundColor = Color.white; + var newParent = EditorGUILayout.ObjectField(transform.parent, typeof(Transform), true, GUILayout.Width(170)) as Transform; + if(newParent != transform.parent) + { + transform.parent = newParent; + UsedNew(); + } + GUI.backgroundColor = c; + + if(MergeButton("<<<", usingTheirs)) + { + UseTheirs(); + } + + GUILayout.Label(theirParent ? theirParent.ToString() : "None", GUILayout.Width(100)); + + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + } + + private static bool MergeButton(string text, bool green) + { + if(green) + { + GUI.color = Color.green; + } + bool result = GUILayout.Button(text, GUILayout.ExpandWidth(false)); + GUI.color = Color.white; + return result; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeActionParenting.cs.meta b/Angels and Demons/Assets/Editor/MergeActionParenting.cs.meta new file mode 100644 index 0000000..6e45544 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeActionParenting.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29139dc665a42db45b67df932a04c810 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeManager.cs b/Angels and Demons/Assets/Editor/MergeManager.cs new file mode 100644 index 0000000..edefe88 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeManager.cs @@ -0,0 +1,123 @@ +using UnityEngine; +using System.IO; +using System.Diagnostics; +using System.ComponentModel; +using System.Collections.Generic; + +namespace GitMerge +{ + public abstract class MergeManager + { + protected VCS vcs { private set; get; } + protected GitMergeWindow window { private set; get; } + + internal List allMergeActions; + + protected static string fileName; + protected static string theirFilename; + + public static bool isMergingScene { protected set; get; } + public static bool isMergingPrefab { get { return !isMergingScene; } } + + + public MergeManager(GitMergeWindow window, VCS vcs) + { + this.window = window; + this.vcs = vcs; + allMergeActions = new List(); + } + + /// + /// Creates "their" version of the file at the given path, + /// named filename--THEIRS.unity. + /// + /// The path of the file, relative to the project folder. + protected void GetTheirVersionOf(string path) + { + fileName = path; + + string basepath = Path.GetDirectoryName(path); + string sname = Path.GetFileNameWithoutExtension(path); + string extension = Path.GetExtension(path); + + string ours = Path.Combine(basepath, sname + "--OURS" + extension); + theirFilename = Path.Combine(basepath, sname + "--THEIRS" + extension); + + File.Copy(path, ours); + try + { + vcs.GetTheirs(path); + } + catch(VCSException e) + { + File.Delete(ours); + throw e; + } + File.Move(path, theirFilename); + File.Move(ours, path); + } + + /// + /// Finds all specific merge conflicts between two sets of GameObjects, + /// representing "our" scene and "their" scene. + /// + /// The GameObjects of "our" version of the scene. + /// The GameObjects of "their" version of the scene. + protected void BuildAllMergeActions(List ourObjects, List theirObjects) + { + allMergeActions = new List(); + + //Map "their" GameObjects to their respective ids + var theirObjectsDict = new Dictionary(); + 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); + } + } + } + + public abstract void CompleteMerge(); + + public virtual void AbortMerge() + { + MergeAction.inMergePhase = false; + + foreach(var actions in allMergeActions) + { + actions.UseOurs(); + } + ObjectDictionaries.DestroyTheirObjects(); + ObjectDictionaries.Clear(); + allMergeActions = null; + + window.ShowNotification(new GUIContent("Merge aborted.")); + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeManager.cs.meta b/Angels and Demons/Assets/Editor/MergeManager.cs.meta new file mode 100644 index 0000000..9ccaa2a --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7759967878514e4aace05e726704e8f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeManagerPrefab.cs b/Angels and Demons/Assets/Editor/MergeManagerPrefab.cs new file mode 100644 index 0000000..8b614d5 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeManagerPrefab.cs @@ -0,0 +1,149 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; + +namespace GitMerge +{ + public class MergeManagerPrefab : MergeManager + { + //Stuff needed for prefab merging + public static GameObject ourPrefab { private set; get; } + private static GameObject theirPrefab; + public static GameObject ourPrefabInstance { private set; get; } + private static string previouslyOpenedScene; + + + public MergeManagerPrefab(GitMergeWindow window, VCS vcs) + : base(window, vcs) + { + + } + + public bool InitializeMerge(GameObject prefab) + { + if(!EditorApplication.SaveCurrentSceneIfUserWantsTo()) + { + return false; + } + + isMergingScene = false; + MergeAction.inMergePhase = false; + + ObjectDictionaries.Clear(); + + //checkout "their" version + GetTheirVersionOf(AssetDatabase.GetAssetOrScenePath(prefab)); + AssetDatabase.Refresh(); + + ourPrefab = prefab; + + //Open a new Scene that will only display the prefab + previouslyOpenedScene = EditorApplication.currentScene; + EditorApplication.NewScene(); + + //make the new scene empty + Object.DestroyImmediate(Camera.main.gameObject); + + //instantiate our object in order to view it while merging + ourPrefabInstance = PrefabUtility.InstantiatePrefab(prefab) as GameObject; + + //find all of "our" objects in the prefab + var ourObjects = GetAllObjects(prefab); + + theirPrefab = AssetDatabase.LoadAssetAtPath(theirFilename, typeof(GameObject)) as GameObject; + theirPrefab.hideFlags = HideFlags.HideAndDontSave; + var theirObjects = GetAllObjects(theirPrefab); + + //create list of differences that have to be merged + BuildAllMergeActions(ourObjects, theirObjects); + + if(allMergeActions.Count == 0) + { + AssetDatabase.DeleteAsset(theirFilename); + OpenPreviousScene(); + window.ShowNotification(new GUIContent("No conflict found for this prefab.")); + return false; + } + MergeAction.inMergePhase = true; + ourPrefabInstance.Highlight(); + return true; + } + + /// + /// Recursively find all GameObjects that are part of the prefab + /// + /// The prefab to analyze + /// The list with all the objects already found. Pass null in the beginning. + /// The list with all the objects + private static List GetAllObjects(GameObject prefab, List list = null) + { + if(list == null) + { + list = new List(); + } + + list.Add(prefab); + foreach(Transform t in prefab.transform) + { + GetAllObjects(t.gameObject, list); + } + return list; + } + + /// + /// Completes the merge process after solving all conflicts. + /// Cleans up the scene by deleting "their" GameObjects, clears merge related data structures, + /// executes git add scene_name. + /// + public override void CompleteMerge() + { + MergeAction.inMergePhase = false; + + //ObjectDictionaries.Clear(); + + allMergeActions = null; + + //TODO: Could we explicitly just save the prefab? + AssetDatabase.SaveAssets(); + + //Mark as merged for git + vcs.MarkAsMerged(fileName); + + //directly committing here might not be that smart, since there might be more conflicts + + ourPrefab = null; + + //delete their prefab file + AssetDatabase.DeleteAsset(theirFilename); + + OpenPreviousScene(); + window.ShowNotification(new GUIContent("Prefab successfully merged.")); + } + + /// + /// Aborts merge by using "our" version in all conflicts. + /// Cleans up merge related data. + /// + public override void AbortMerge() + { + base.AbortMerge(); + + //delete prefab file + AssetDatabase.DeleteAsset(theirFilename); + OpenPreviousScene(); + ourPrefab = null; + } + + /// + /// Opens the previously opened scene, if there was any. + /// + private static void OpenPreviousScene() + { + if(!string.IsNullOrEmpty(previouslyOpenedScene)) + { + EditorApplication.OpenScene(previouslyOpenedScene); + previouslyOpenedScene = ""; + } + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeManagerPrefab.cs.meta b/Angels and Demons/Assets/Editor/MergeManagerPrefab.cs.meta new file mode 100644 index 0000000..74223b5 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeManagerPrefab.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f8db1a549c01168468790b325c85f3c1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/MergeManagerScene.cs b/Angels and Demons/Assets/Editor/MergeManagerScene.cs new file mode 100644 index 0000000..5ebc825 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeManagerScene.cs @@ -0,0 +1,118 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; + +namespace GitMerge +{ + public class MergeManagerScene : MergeManager + { + public MergeManagerScene(GitMergeWindow window, VCS vcs) + : base(window, vcs) + { + + } + + public bool InitializeMerge() + { + isMergingScene = true; + + //Ask if the scene should be saved, because... + if(!EditorApplication.SaveCurrentSceneIfUserWantsTo()) + { + return false; + } + //...we are reloading it to prevent objects from not having a scene id. + EditorApplication.OpenScene(EditorApplication.currentScene); + + MergeAction.inMergePhase = false; + + ObjectDictionaries.Clear(); + + //checkout "their" version + GetTheirVersionOf(EditorApplication.currentScene); + AssetDatabase.Refresh(); + + //find all of "our" objects + var ourObjects = GetAllSceneObjects(); + ObjectDictionaries.SetAsOurObjects(ourObjects); + + //add "their" objects + EditorApplication.OpenSceneAdditive(theirFilename); + + //delete scene file + AssetDatabase.DeleteAsset(theirFilename); + + //find all of "their" objects + var addedObjects = GetAllNewSceneObjects(ourObjects); + ObjectDictionaries.SetAsTheirObjects(addedObjects); + + //create list of differences that have to be merged + BuildAllMergeActions(ourObjects, addedObjects); + + if(allMergeActions.Count == 0) + { + window.ShowNotification(new GUIContent("No conflict found for this scene.")); + return false; + } + MergeAction.inMergePhase = true; + return true; + } + + private static List GetAllSceneObjects() + { + var objects = (GameObject[])Object.FindObjectsOfType(typeof(GameObject)); + return new List(objects); + } + + /// + /// Finds all GameObjects in the scene, minus the ones passed. + /// + private static List GetAllNewSceneObjects(List oldObjects) + { + var all = GetAllSceneObjects(); + var old = oldObjects; + + foreach(var obj in old) + { + all.Remove(obj); + } + + return all; + } + + /// + /// Completes the merge process after solving all conflicts. + /// Cleans up the scene by deleting "their" GameObjects, clears merge related data structures, + /// executes git add scene_name. + /// + public override void CompleteMerge() + { + MergeAction.inMergePhase = false; + + ObjectDictionaries.DestroyTheirObjects(); + ObjectDictionaries.Clear(); + EditorApplication.SaveScene(); + + allMergeActions = null; + + //Mark as merged for git + vcs.MarkAsMerged(fileName); + + //directly committing here might not be that smart, since there might be more conflicts + + window.ShowNotification(new GUIContent("Scene successfully merged.")); + } + + /// + /// Aborts merge by using "our" version in all conflicts. + /// Cleans up merge related data. + /// + public override void AbortMerge() + { + base.AbortMerge(); + + //Save scene + EditorApplication.SaveScene(); + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/MergeManagerScene.cs.meta b/Angels and Demons/Assets/Editor/MergeManagerScene.cs.meta new file mode 100644 index 0000000..37afd02 --- /dev/null +++ b/Angels and Demons/Assets/Editor/MergeManagerScene.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2143b0a739488bb4698c51777c4863fc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/ObjectDictionaries.cs b/Angels and Demons/Assets/Editor/ObjectDictionaries.cs new file mode 100644 index 0000000..f76fa08 --- /dev/null +++ b/Angels and Demons/Assets/Editor/ObjectDictionaries.cs @@ -0,0 +1,262 @@ +using UnityEngine; +using System.Collections.Generic; + +namespace GitMerge +{ + /// + /// Dictionaries that categorize the scene's objects into our objects, their objects, and temporary + /// copies of their objects that have been instantiated while merging. + /// + public static class ObjectDictionaries + { + //This dict holds all of "our" objects + //Needed for Reference handling + // + private static Dictionary ourObjects = new Dictionary(); + + //This dict maps our instances of their objects + //Whenever we instantiate a copy of "their" new object, they're both added here + private static Dictionary ourInstances = new Dictionary(); + + //This dict holds all of "their" GameObjects + //Needed for scene cleaning after merge + // + private static Dictionary theirObjects = new Dictionary(); + + //This dict holds all GameObjects that might or might not exist, + //depending on the current merge state. The referenced objects are the versions that will definitely exist throughout the merge. + //Also maps the MergeActions responsible for their existence to them. + private static Dictionary schroedingersObjects = new Dictionary(); + + + public static void SetAsOurObjects(List objects) + { + foreach(var obj in objects) + { + SetAsOurObject(obj); + } + } + + public static void SetAsTheirObjects(List objects) + { + foreach(var obj in objects) + { + SetAsTheirs(obj, false); + } + } + + + public static void SetAsOurObject(GameObject go) + { + AddOurObject(go); + foreach(var c in go.GetComponents()) + { + AddOurObject(c); + } + } + + public static void SetAsOurObject(Component c) + { + AddOurObject(c); + } + + private static void AddOurObject(Object o) + { + if(o == null) + return; + + ourObjects.Add(ObjectIDFinder.GetIdentifierFor(o), o); + } + + public static void RemoveOurObject(GameObject go) + { + foreach(var c in go.GetComponents()) + { + RemoveOurSingleObject(c); + } + RemoveOurSingleObject(go); + } + + public static void RemoveOurObject(Component c) + { + RemoveOurSingleObject(c); + } + + private static void RemoveOurSingleObject(Object o) + { + if(o == null) + return; + + ourObjects.Remove(ObjectIDFinder.GetIdentifierFor(o)); + } + + public static Object GetOurObject(int id) + { + Object result = null; + ourObjects.TryGetValue(id, out result); + return result; + } + + /// + /// Returns: + /// * the given object if it is "ours" + /// * "our" counterpart of obj if it is "theirs" + /// * null if the object is deleted for some reason + /// The returned object can be an instance of "their" object temporarily added for the merge + /// + /// the original object + /// the counterpart of the object in "our" version + public static Object GetOurCounterpartFor(Object obj) + { + var result = obj; + if(IsTheirs(obj)) + { + result = GetOurObject(ObjectIDFinder.GetIdentifierFor(obj)); + if(!result) + { + result = GetOurInstanceOfCopy(obj); + } + } + return result; + } + + public static void Clear() + { + ourObjects.Clear(); + theirObjects.Clear(); + ourInstances.Clear(); + schroedingersObjects.Clear(); + } + + /// + /// Mark o as an instance of theirs + /// + public static void SetAsCopy(GameObject o, GameObject theirs) + { + ourInstances.Add(theirs, o); + var instanceComponents = o.GetComponents(); + var theirComponents = theirs.GetComponents(); + for(int i = 0; i < instanceComponents.Length; ++i) + { + SetAsCopy(instanceComponents[i], theirComponents[i]); + } + } + + public static void SetAsCopy(Component c, Component theirs) + { + if(c == null) + return; + + ourInstances.Add(theirs, c); + } + + public static void RemoveCopyOf(GameObject theirs) + { + ourInstances.Remove(theirs); + foreach(var c in theirs.GetComponents()) + { + if(c != null) + { + ourInstances.Remove(c); + } + } + } + + public static void RemoveCopyOf(Component theirs) + { + ourInstances.Remove(theirs); + } + + /// + /// Returns: + /// * the given object if it is "ours" + /// * "our" instance of obj if it is "theirs" + /// * null if there is no such instance + /// + /// the original object + /// the instance of the original object + public static Object GetOurInstanceOfCopy(Object obj) + { + var result = obj; + if(IsTheirs(obj)) + { + ourInstances.TryGetValue(obj, out result); + } + return result; + } + + private static bool IsTheirs(Object obj) + { + var go = obj as GameObject; + if(go) + { + return theirObjects.ContainsKey(go); + } + var c = obj as Component; + if(c) + { + return theirObjects.ContainsKey(c.gameObject); + } + return false; + } + + public static void SetAsTheirs(GameObject go, bool active) + { + if(!theirObjects.ContainsKey(go)) + { + theirObjects.Add(go, go.activeSelf); + } + go.SetActiveForMerging(false); + } + + /// + /// Copy an object that has been disabled and hidden for merging into the scene, + /// enable and unhide the copy. + /// + /// The original GameObject. + /// The copy GameObject. + public static GameObject InstantiateFromMerging(GameObject go) + { + var copy = GameObject.Instantiate(go) as GameObject; + + //Destroy children + foreach(Transform t in copy.GetComponent()) + { + Object.DestroyImmediate(t.gameObject); + } + + bool wasActive; + if(!theirObjects.TryGetValue(go, out wasActive)) + { + wasActive = go.activeSelf; + } + + //Apply some special properties of the GameObject + copy.SetActive(wasActive); + copy.hideFlags = HideFlags.None; + copy.name = go.name; + copy.GetComponent().parent = GetOurCounterpartFor(go.GetComponent().parent) as Transform; + + return copy; + } + + public static void DestroyTheirObjects() + { + foreach(var obj in theirObjects.Keys) + { + Object.DestroyImmediate(obj); + } + theirObjects.Clear(); + } + + public static void AddToSchroedingersObjects(GameObject go, MergeActionExistence mergeAction) + { + schroedingersObjects.Add(go, mergeAction); + } + + public static void EnsureExistence(GameObject go) + { + schroedingersObjects[go].EnsureExistence(); + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/ObjectDictionaries.cs.meta b/Angels and Demons/Assets/Editor/ObjectDictionaries.cs.meta new file mode 100644 index 0000000..3a634d5 --- /dev/null +++ b/Angels and Demons/Assets/Editor/ObjectDictionaries.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e2d4344037c6c7c4ca962a1e4037b6fe +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/ObjectExtensions.cs b/Angels and Demons/Assets/Editor/ObjectExtensions.cs new file mode 100644 index 0000000..24ba0c8 --- /dev/null +++ b/Angels and Demons/Assets/Editor/ObjectExtensions.cs @@ -0,0 +1,24 @@ +using UnityEngine; + +namespace GitMerge +{ + public static class ObjectExtensions + { + /// + /// Get a fine, readable type string. Doesn't really need to be a Component extension method. + /// Example: UnityEngine.BoxCollider => BoxCollider + /// + /// The object whose type we want to display + /// The well readable type string + public static string GetPlainType(this object o) + { + var s = o.GetType().ToString(); + var i = s.LastIndexOf('.'); + if(i >= 0) + { + s = s.Substring(i + 1); + } + return s; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/ObjectExtensions.cs.meta b/Angels and Demons/Assets/Editor/ObjectExtensions.cs.meta new file mode 100644 index 0000000..5d3f534 --- /dev/null +++ b/Angels and Demons/Assets/Editor/ObjectExtensions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0ee0303a3ea013b4eaa610e764182b3a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/ObjectIDFinder.cs b/Angels and Demons/Assets/Editor/ObjectIDFinder.cs new file mode 100644 index 0000000..8f09442 --- /dev/null +++ b/Angels and Demons/Assets/Editor/ObjectIDFinder.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using UnityEditor; +using System.Reflection; + +namespace GitMerge +{ + public static class ObjectIDFinder + { + //soooo hacky + //credits to thelackey3326 + //http://forum.unity3d.com/threads/how-to-get-the-local-identifier-in-file-for-scene-objects.265686/ + + public static int GetIdentifierFor(Object o) + { + if(o == null) + { + return -1; + } + + var inspectorModeInfo = typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance); + + SerializedObject serializedObject = new SerializedObject(o); + inspectorModeInfo.SetValue(serializedObject, InspectorMode.Debug, null); + + SerializedProperty localIdProp = + serializedObject.FindProperty("m_LocalIdentfierInFile"); //note the misspelling! + + return localIdProp.intValue; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/ObjectIDFinder.cs.meta b/Angels and Demons/Assets/Editor/ObjectIDFinder.cs.meta new file mode 100644 index 0000000..aab28ab --- /dev/null +++ b/Angels and Demons/Assets/Editor/ObjectIDFinder.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 03c68a8557b31bf45a299c6f3be7bf10 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/Resources.cs b/Angels and Demons/Assets/Editor/Resources.cs new file mode 100644 index 0000000..2b1e260 --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources.cs @@ -0,0 +1,35 @@ +using UnityEngine; + +namespace GitMerge +{ + public class Resources : ScriptableObject + { + public static Resources styles { private set; get; } + private static Texture2D _logo; + public static Texture2D logo + { + get + { + if(!_logo) + { + _logo = UnityEngine.Resources.Load("GitMergeLogo"); + } + return _logo; + } + } + + public void OnEnable() + { + styles = UnityEngine.Resources.Load("GitMergeStyles"); + } + + public GUIStyle mergeActions; + public GUIStyle mergeAction; + + public static void DrawLogo() + { + GUI.DrawTexture(new Rect(5, 5, logo.width, logo.height), logo); + GUILayout.Space(logo.height + 15); + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/Resources.cs.meta b/Angels and Demons/Assets/Editor/Resources.cs.meta new file mode 100644 index 0000000..71d4115 --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 67422f4e577bb17409644dcfe6bf75c8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/Resources.meta b/Angels and Demons/Assets/Editor/Resources.meta new file mode 100644 index 0000000..47d1d08 --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 718f5b21123c36448b66c0e2ec52031c +folderAsset: yes +DefaultImporter: + userData: diff --git a/Angels and Demons/Assets/Editor/Resources/GitMergeBox.psd b/Angels and Demons/Assets/Editor/Resources/GitMergeBox.psd new file mode 100644 index 0000000..a001acd Binary files /dev/null and b/Angels and Demons/Assets/Editor/Resources/GitMergeBox.psd differ diff --git a/Angels and Demons/Assets/Editor/Resources/GitMergeBox.psd.meta b/Angels and Demons/Assets/Editor/Resources/GitMergeBox.psd.meta new file mode 100644 index 0000000..a3b4cf3 --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources/GitMergeBox.psd.meta @@ -0,0 +1,46 @@ +fileFormatVersion: 2 +guid: be9ca0515e031fb4c86b12a6b9ba2410 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Angels and Demons/Assets/Editor/Resources/GitMergeLogo.psd b/Angels and Demons/Assets/Editor/Resources/GitMergeLogo.psd new file mode 100644 index 0000000..ab8bfb7 Binary files /dev/null and b/Angels and Demons/Assets/Editor/Resources/GitMergeLogo.psd differ diff --git a/Angels and Demons/Assets/Editor/Resources/GitMergeLogo.psd.meta b/Angels and Demons/Assets/Editor/Resources/GitMergeLogo.psd.meta new file mode 100644 index 0000000..a47f32e --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources/GitMergeLogo.psd.meta @@ -0,0 +1,46 @@ +fileFormatVersion: 2 +guid: e18ddd74b76685d46a46ca56a3f6380f +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Angels and Demons/Assets/Editor/Resources/GitMergeStyles.asset b/Angels and Demons/Assets/Editor/Resources/GitMergeStyles.asset new file mode 100644 index 0000000..a9c1397 Binary files /dev/null and b/Angels and Demons/Assets/Editor/Resources/GitMergeStyles.asset differ diff --git a/Angels and Demons/Assets/Editor/Resources/GitMergeStyles.asset.meta b/Angels and Demons/Assets/Editor/Resources/GitMergeStyles.asset.meta new file mode 100644 index 0000000..2c5da3e --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources/GitMergeStyles.asset.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: a88667aa2092d4b46aa3ad92e778e994 +NativeFormatImporter: + userData: diff --git a/Angels and Demons/Assets/Editor/Resources/Licenses.txt b/Angels and Demons/Assets/Editor/Resources/Licenses.txt new file mode 100644 index 0000000..ce779dd --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources/Licenses.txt @@ -0,0 +1 @@ +Git Logo by Jason Long [used in GitMergeLogo.psd] is licensed under the Creative Commons Attribution 3.0 Unported License. \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/Resources/Licenses.txt.meta b/Angels and Demons/Assets/Editor/Resources/Licenses.txt.meta new file mode 100644 index 0000000..f2c1918 --- /dev/null +++ b/Angels and Demons/Assets/Editor/Resources/Licenses.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: fcbbf2375e3889c4398c97d289eab2ac +TextScriptImporter: + userData: diff --git a/Angels and Demons/Assets/Editor/SerializedPropertyExtensions.cs b/Angels and Demons/Assets/Editor/SerializedPropertyExtensions.cs new file mode 100644 index 0000000..5ce3099 --- /dev/null +++ b/Angels and Demons/Assets/Editor/SerializedPropertyExtensions.cs @@ -0,0 +1,181 @@ +using UnityEngine; +using UnityEditor; + +namespace GitMerge +{ + public static class SerializedPropertyExtensions + { + public static object GetValue(this SerializedProperty p, bool forComparison = false) + { + switch(p.propertyType) + { + case SerializedPropertyType.AnimationCurve: + return p.animationCurveValue; + case SerializedPropertyType.ArraySize: + return p.intValue; + case SerializedPropertyType.Boolean: + return p.boolValue; + case SerializedPropertyType.Bounds: + return p.boundsValue; + case SerializedPropertyType.Character: + return p.stringValue; //TODO: might be bullshit + case SerializedPropertyType.Color: + return p.colorValue; + case SerializedPropertyType.Enum: + return p.enumValueIndex; + case SerializedPropertyType.Float: + return p.floatValue; + case SerializedPropertyType.Generic: //(arrays) + if(p.isArray) + { + var arr = new object[p.arraySize]; + for(int i = 0; i < arr.Length; ++i) + { + arr[i] = p.GetArrayElementAtIndex(i).GetValue(); + } + return arr; + } + else + { + return null; + } + case SerializedPropertyType.Gradient: + return 0; //TODO: erm + case SerializedPropertyType.Integer: + return p.intValue; + case SerializedPropertyType.LayerMask: + return p.intValue; + case SerializedPropertyType.ObjectReference: + if(forComparison) + { + return ObjectIDFinder.GetIdentifierFor(p.objectReferenceValue); + } + else + { + return p.objectReferenceValue; + } + case SerializedPropertyType.Quaternion: + return p.quaternionValue; + case SerializedPropertyType.Rect: + return p.rectValue; + case SerializedPropertyType.String: + return p.stringValue; + case SerializedPropertyType.Vector2: + return p.vector2Value; + case SerializedPropertyType.Vector3: + return p.vector3Value; + case SerializedPropertyType.Vector4: + return p.vector4Value; + default: + return 0; + } + } + + public static void SetValue(this SerializedProperty p, object value) + { + switch(p.propertyType) + { + case SerializedPropertyType.AnimationCurve: + p.animationCurveValue = value as AnimationCurve; + break; + case SerializedPropertyType.ArraySize: + //TODO: erm + p.intValue = (int)value; + break; + case SerializedPropertyType.Boolean: + p.boolValue = (bool)value; + break; + case SerializedPropertyType.Bounds: + p.boundsValue = (Bounds)value; + break; + case SerializedPropertyType.Character: + p.stringValue = (string)value; //TODO: might be bullshit + break; + case SerializedPropertyType.Color: + p.colorValue = (Color)value; + break; + case SerializedPropertyType.Enum: + p.enumValueIndex = (int)value; + break; + case SerializedPropertyType.Float: + p.floatValue = (float)value; + break; + case SerializedPropertyType.Generic: //(arrays) + if(p.isArray) + { + //var size = p.arraySize; + //var resetPath = p.propertyPath; + var values = (object[])value; + /* + for(int i = 0; i < p.arraySize; ++i) + { + Debug.Log(i + ": " + p.GetArrayElementAtIndex(i).GetValue()); + } + */ + p.ClearArray(); + for(int i = 0; i < values.Length; ++i) + { + p.InsertArrayElementAtIndex(i); + //Debug.Log(i + ": " + pv.GetArrayElementAtIndex(i).GetValue()); + p.GetArrayElementAtIndex(i).SetValue(values[i]); + } + + //p.FindPropertyRelative(resetPath); + } + else + { + //p.stringValue = (string)value; + } + break; + case SerializedPropertyType.Gradient: + //TODO: erm + break; + case SerializedPropertyType.Integer: + p.intValue = (int)value; + break; + case SerializedPropertyType.LayerMask: + p.intValue = (int)value; + break; + case SerializedPropertyType.ObjectReference: + p.objectReferenceValue = value as Object; //TODO: what about non-UnityEngine objects? + break; + case SerializedPropertyType.Quaternion: + p.quaternionValue = (Quaternion)value; + break; + case SerializedPropertyType.Rect: + p.rectValue = (Rect)value; + break; + case SerializedPropertyType.String: + p.stringValue = (string)value; + break; + case SerializedPropertyType.Vector2: + p.vector2Value = (Vector2)value; + break; + case SerializedPropertyType.Vector3: + p.vector3Value = (Vector3)value; + break; + case SerializedPropertyType.Vector4: + p.vector4Value = (Vector4)value; + break; + default: + break; + } + } + + public static string GetPlainName(this SerializedProperty p) + { + var s = p.name; + var i = s.IndexOf('_'); + if(i >= 0) + { + s = s.Substring(i + 1); + } + return s; + } + + public static bool IsRealArray(this SerializedProperty p) + { + return p.propertyType == SerializedPropertyType.Generic && p.isArray; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/SerializedPropertyExtensions.cs.meta b/Angels and Demons/Assets/Editor/SerializedPropertyExtensions.cs.meta new file mode 100644 index 0000000..cce9a73 --- /dev/null +++ b/Angels and Demons/Assets/Editor/SerializedPropertyExtensions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e055732d013ee174fb764659113f8ea9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/VCS.cs b/Angels and Demons/Assets/Editor/VCS.cs new file mode 100644 index 0000000..4de8548 --- /dev/null +++ b/Angels and Demons/Assets/Editor/VCS.cs @@ -0,0 +1,71 @@ +using UnityEditor; +using System.Diagnostics; +using System.ComponentModel; + +namespace GitMerge +{ + /// + /// This abstract class represents a vcs interface. + /// It manages saving and retrieving the exe path from/to the EditorPrefs + /// and offers a small set of actions using the vcs. + /// + public abstract class VCS + { + protected abstract string GetDefaultPath(); + protected abstract string EditorPrefsKey(); + + //The two important methods + public abstract void GetTheirs(string path); + public abstract void MarkAsMerged(string path); + + //This one's for experimental three-way merging + public abstract void GetBase(string path); + + public string exe() + { + if(EditorPrefs.HasKey(EditorPrefsKey())) + { + return EditorPrefs.GetString(EditorPrefsKey()); + } + + return GetDefaultPath(); + } + + public void SetPath(string path) + { + EditorPrefs.SetString(EditorPrefsKey(), path); + } + + /// + /// Executes the VCS as a subprocess. + /// + /// The parameters passed. Like "status" for "git status" + /// Whatever the call returns. + protected string Execute(string args) + { + var process = new Process(); + var startInfo = new ProcessStartInfo(); + startInfo.WindowStyle = ProcessWindowStyle.Hidden; + startInfo.FileName = exe(); + startInfo.Arguments = args; + startInfo.UseShellExecute = false; + startInfo.RedirectStandardOutput = true; + startInfo.CreateNoWindow = true; + process.StartInfo = startInfo; + + try + { + process.Start(); + } + catch(Win32Exception) + { + throw new VCSException(); + } + + string output = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + + return output; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/VCS.cs.meta b/Angels and Demons/Assets/Editor/VCS.cs.meta new file mode 100644 index 0000000..402389d --- /dev/null +++ b/Angels and Demons/Assets/Editor/VCS.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a08026e2ac14c0446a85134863995fd0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/VCSException.cs b/Angels and Demons/Assets/Editor/VCSException.cs new file mode 100644 index 0000000..14c33c0 --- /dev/null +++ b/Angels and Demons/Assets/Editor/VCSException.cs @@ -0,0 +1,10 @@ + +namespace GitMerge +{ + public class VCSException : System.Exception + { + public VCSException(string message = "Could not find the VCS executable. Please enter the path to your VCS in the settings.") : base(message) + { + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/VCSException.cs.meta b/Angels and Demons/Assets/Editor/VCSException.cs.meta new file mode 100644 index 0000000..f146267 --- /dev/null +++ b/Angels and Demons/Assets/Editor/VCSException.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 339de811f43309449914e314f1366850 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/Editor/VCSGit.cs b/Angels and Demons/Assets/Editor/VCSGit.cs new file mode 100644 index 0000000..5912f35 --- /dev/null +++ b/Angels and Demons/Assets/Editor/VCSGit.cs @@ -0,0 +1,57 @@ +using UnityEngine; +using System.Text.RegularExpressions; + +namespace GitMerge +{ + public class VCSGit : VCS + { + protected override string GetDefaultPath() + { + if(Application.platform == RuntimePlatform.WindowsEditor) + { + return @"C:\Program Files (x86)\Git\bin\git.exe"; + } + return @"/usr/bin/git"; + } + + protected override string EditorPrefsKey() + { + return "GitMerge_git"; + } + + public override void GetTheirs(string path) + { + Execute("checkout --theirs \"" + path + "\""); + } + + public override void MarkAsMerged(string path) + { + Execute("add \"" + path + "\""); + } + + public override void GetBase(string path) + { + var head = GetCommitID(Execute("show head")); + var mergeHead = GetCommitID(Execute("show merge_head")); + var mergeBase = Execute("merge-base "+head+" "+mergeHead); + + Execute("checkout " + mergeBase + " \"" + path + "\""); + } + + /// + /// Filters the commit id from the string printed by "git show object" + /// + /// The result of a "git show object" call + /// The commit id of the object shown. + private string GetCommitID(string showResult) + { + var pattern = @"(?<=(commit ))[\dabcdef]+\b"; + var match = Regex.Match(showResult, pattern); + if(!match.Success) + { + throw new VCSException("Could not find commit ID."); + } + return match.Value; + } + } +} \ No newline at end of file diff --git a/Angels and Demons/Assets/Editor/VCSGit.cs.meta b/Angels and Demons/Assets/Editor/VCSGit.cs.meta new file mode 100644 index 0000000..419299d --- /dev/null +++ b/Angels and Demons/Assets/Editor/VCSGit.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b4b1187c33991394a9c66710b250f24b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Angels and Demons/Assets/LICENSE.md b/Angels and Demons/Assets/LICENSE.md new file mode 100644 index 0000000..23cb790 --- /dev/null +++ b/Angels and Demons/Assets/LICENSE.md @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Angels and Demons/Assets/LICENSE.md.meta b/Angels and Demons/Assets/LICENSE.md.meta new file mode 100644 index 0000000..1463f2b --- /dev/null +++ b/Angels and Demons/Assets/LICENSE.md.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 785798e4822ed284b8daad687e2df88d +DefaultImporter: + userData: diff --git a/Angels and Demons/Assets/README.md b/Angels and Demons/Assets/README.md new file mode 100644 index 0000000..940fe64 --- /dev/null +++ b/Angels and Demons/Assets/README.md @@ -0,0 +1,17 @@ +GitMerge-for-Unity +================== + +A Unity plugin which allows you to merge scene and prefab files when using git. +More information: http://flashg.github.io/GitMerge-for-Unity/ + +### This tool does not work with Unity 5... + +...and it will not do so until a small change in scene serialization will be reverted in Unity. +Please vote for this here: http://feedback.unity3d.com/suggestions/re-add-local-identifiers-in-scene-file-for-prefab-instances + +## Current state of the project + +You can merge both scenes and prefabs. +Working with the scene hierarchy is currently being improved. + +There are still a few bugs to work on. If the tool messes up something, remember to git reset --hard :wink: diff --git a/Angels and Demons/Assets/README.md.meta b/Angels and Demons/Assets/README.md.meta new file mode 100644 index 0000000..392dd3d --- /dev/null +++ b/Angels and Demons/Assets/README.md.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: b364bc2946220bf428dccb47dbcee795 +DefaultImporter: + userData: diff --git a/Angels and Demons/Assets/Scenes.meta b/Angels and Demons/Assets/Scenes.meta new file mode 100644 index 0000000..709eb49 --- /dev/null +++ b/Angels and Demons/Assets/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f704ae4b4f98ae41a0bce26658850c1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Angels and Demons/Assets/Scenes/Main.unity b/Angels and Demons/Assets/Scenes/Main.unity new file mode 100644 index 0000000..115a43f Binary files /dev/null and b/Angels and Demons/Assets/Scenes/Main.unity differ diff --git a/Angels and Demons/Assets/Scenes/Main.unity.meta b/Angels and Demons/Assets/Scenes/Main.unity.meta new file mode 100644 index 0000000..b86bc19 --- /dev/null +++ b/Angels and Demons/Assets/Scenes/Main.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6f41f0233cb7644e4a83e5f5543ed237 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Angels and Demons/Packages/manifest.json b/Angels and Demons/Packages/manifest.json new file mode 100644 index 0000000..526aca6 --- /dev/null +++ b/Angels and Demons/Packages/manifest.json @@ -0,0 +1,4 @@ +{ + "dependencies": { + } +} diff --git a/Angels and Demons/ProjectSettings/AudioManager.asset b/Angels and Demons/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..9e7b4b1 Binary files /dev/null and b/Angels and Demons/ProjectSettings/AudioManager.asset differ diff --git a/Angels and Demons/ProjectSettings/ClusterInputManager.asset b/Angels and Demons/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..15d7e5e Binary files /dev/null and b/Angels and Demons/ProjectSettings/ClusterInputManager.asset differ diff --git a/Angels and Demons/ProjectSettings/DynamicsManager.asset b/Angels and Demons/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..824c93e Binary files /dev/null and b/Angels and Demons/ProjectSettings/DynamicsManager.asset differ diff --git a/Angels and Demons/ProjectSettings/EditorBuildSettings.asset b/Angels and Demons/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..c6e16ec Binary files /dev/null and b/Angels and Demons/ProjectSettings/EditorBuildSettings.asset differ diff --git a/Angels and Demons/ProjectSettings/EditorSettings.asset b/Angels and Demons/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..9283dc3 Binary files /dev/null and b/Angels and Demons/ProjectSettings/EditorSettings.asset differ diff --git a/Angels and Demons/ProjectSettings/GraphicsSettings.asset b/Angels and Demons/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..58d747f Binary files /dev/null and b/Angels and Demons/ProjectSettings/GraphicsSettings.asset differ diff --git a/Angels and Demons/ProjectSettings/InputManager.asset b/Angels and Demons/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..4e1d4dd Binary files /dev/null and b/Angels and Demons/ProjectSettings/InputManager.asset differ diff --git a/Angels and Demons/ProjectSettings/NavMeshAreas.asset b/Angels and Demons/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..426ff60 Binary files /dev/null and b/Angels and Demons/ProjectSettings/NavMeshAreas.asset differ diff --git a/Angels and Demons/ProjectSettings/NetworkManager.asset b/Angels and Demons/ProjectSettings/NetworkManager.asset new file mode 100644 index 0000000..43d23d1 Binary files /dev/null and b/Angels and Demons/ProjectSettings/NetworkManager.asset differ diff --git a/Angels and Demons/ProjectSettings/Physics2DSettings.asset b/Angels and Demons/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..51cb48e Binary files /dev/null and b/Angels and Demons/ProjectSettings/Physics2DSettings.asset differ diff --git a/Angels and Demons/ProjectSettings/PresetManager.asset b/Angels and Demons/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..45bb13d Binary files /dev/null and b/Angels and Demons/ProjectSettings/PresetManager.asset differ diff --git a/Angels and Demons/ProjectSettings/ProjectSettings.asset b/Angels and Demons/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..566ad30 Binary files /dev/null and b/Angels and Demons/ProjectSettings/ProjectSettings.asset differ diff --git a/Angels and Demons/ProjectSettings/ProjectVersion.txt b/Angels and Demons/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..22977b3 --- /dev/null +++ b/Angels and Demons/ProjectSettings/ProjectVersion.txt @@ -0,0 +1 @@ +m_EditorVersion: 2018.1.0f2 diff --git a/Angels and Demons/ProjectSettings/QualitySettings.asset b/Angels and Demons/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..ac5c190 Binary files /dev/null and b/Angels and Demons/ProjectSettings/QualitySettings.asset differ diff --git a/Angels and Demons/ProjectSettings/TagManager.asset b/Angels and Demons/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..03680d8 Binary files /dev/null and b/Angels and Demons/ProjectSettings/TagManager.asset differ diff --git a/Angels and Demons/ProjectSettings/TimeManager.asset b/Angels and Demons/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..9de8d76 Binary files /dev/null and b/Angels and Demons/ProjectSettings/TimeManager.asset differ diff --git a/Angels and Demons/ProjectSettings/UnityConnectSettings.asset b/Angels and Demons/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..637d5fe Binary files /dev/null and b/Angels and Demons/ProjectSettings/UnityConnectSettings.asset differ