public StackHelper(PropertyHelper helper, int siblingIndex) { this.helper = helper; this.siblingIndex = siblingIndex; }
public static IEnumerator <bool> UpdatePropertyList(List <PropertyHelper> properties, SerializedObject myObject, SerializedObject theirObject, GameObjectHelper gameObjectParent, ComponentHelper componentParent, PropertyHelper propertyParent, ObjectMerge objectMerge, SceneMerge sceneMerge, Helper parent, UniMergeWindow window, bool showHidden = false) { var myObjectIsNull = myObject == null; var theirObjectIsNull = theirObject == null; if (myObjectIsNull && theirObjectIsNull) { yield break; } SerializedProperty myIterator = null; if (!myObjectIsNull) { myIterator = myObject.GetIterator(); } SerializedProperty theirIterator = null; if (!theirObjectIsNull) { theirIterator = theirObject.GetIterator(); } if (theirIterator != null) { theirIterator.Reset(); } var isGameObject = (myObjectIsNull ? theirObject.targetObject : myObject.targetObject) is GameObject; var isTransform = (myObjectIsNull ? theirObject.targetObject : myObject.targetObject) is Transform; var tempShowHiddenDepth = -1; var tempShowHidden = false; var same = true; var mineHasNext = myIterator != null; var theirsHasNext = theirIterator != null; var lastDepth = 0; PropertyHelper lastHelper = null; var root = parent; var gameObjectRoot = gameObjectParent; var componentRoot = componentParent; var propertyRoot = propertyParent; var ignored = false; while (mineHasNext || theirsHasNext) { var _myIterator = myIterator; var _theirIterator = theirIterator; var iterator = _myIterator != null && mineHasNext ? _myIterator : _theirIterator; #if UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER if (iterator.propertyType == SerializedPropertyType.Gradient) { tempShowHiddenDepth = iterator.depth; tempShowHidden = true; } else #endif if (iterator.depth == tempShowHiddenDepth) { tempShowHidden = false; tempShowHiddenDepth = -1; } if (mineHasNext && theirsHasNext) { if (myIterator.depth > theirIterator.depth) { //Catch up myIterator if (showHidden || tempShowHidden) { mineHasNext &= myIterator.Next(!ignored); } else { mineHasNext &= myIterator.NextVisible(!ignored); } } else if (theirIterator.depth > myIterator.depth && theirsHasNext) { // Catch up theirIterator if (showHidden || tempShowHidden) { theirsHasNext &= theirIterator.Next(!ignored); } else { theirsHasNext &= theirIterator.NextVisible(!ignored); } } else { if (showHidden || tempShowHidden) { mineHasNext &= myIterator.Next(!ignored); theirsHasNext &= theirIterator.Next(!ignored); } else { mineHasNext &= myIterator.NextVisible(!ignored); theirsHasNext &= theirIterator.NextVisible(!ignored); } } if (mineHasNext && theirsHasNext) { if (myIterator.depth > theirIterator.depth) // Missing elements in mine { _theirIterator = null; } if (theirIterator.depth > myIterator.depth) // Missing elements in theirs { _myIterator = null; } } } else { if (mineHasNext) { if (showHidden || tempShowHidden) { mineHasNext &= myIterator.Next(!ignored); } else { mineHasNext &= myIterator.NextVisible(!ignored); } } if (theirsHasNext) { if (showHidden || tempShowHidden) { theirsHasNext &= theirIterator.Next(!ignored); } else { theirsHasNext &= theirIterator.NextVisible(!ignored); } } } if (!mineHasNext && !theirsHasNext) { break; } if (!mineHasNext) { _myIterator = null; } if (!theirsHasNext) { _theirIterator = null; } // Get new iterator if one has become null // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (_myIterator == null) { iterator = _theirIterator; } else { iterator = _myIterator; } var path = iterator.propertyPath; var type = iterator.propertyType; ignored = path == "m_Script"; if (isGameObject) { ignored = type == SerializedPropertyType.ObjectReference || type == SerializedPropertyType.Generic; } else if (isTransform) { #if UNITY_4_5 || UNITY_4_5_0 || UNITY_4_6 || UNITY_4_7 || UNITY_5 || UNITY_5_3_OR_NEWER ignored = type != SerializedPropertyType.Vector3 && type != SerializedPropertyType.Quaternion && type != SerializedPropertyType.Float; #elif !Unity3 ignored = type != SerializedPropertyType.Vector3 && type != (SerializedPropertyType)16 && type != SerializedPropertyType.Float; #else ignored = type != SerializedPropertyType.Vector3 && type != SerializedPropertyType.Float; #endif } if (ignored) { continue; } PropertyHelper ph = null; var count = properties.Count; for (var i = 0; i < count; i++) { var property = properties[i]; if (property.propertyPath == path) { ph = property; break; } } var depth = iterator.depth; if (depth > lastDepth) { parent = lastHelper; propertyParent = lastHelper; } if (depth < lastDepth && parent != null) { parent = parent.parent; propertyParent = propertyParent.propertyParent; } if (depth > 0) { var children = propertyParent.children; if (children != null) { count = children.Count; for (var i = 0; i < count; i++) { var child = children[i]; if (child.propertyPath == path) { ph = child; break; } } } } SerializedProperty myIteratorCopy = null; if (_myIterator != null) { myIteratorCopy = _myIterator.Copy(); } SerializedProperty theirIteratorCopy = null; if (_theirIterator != null) { theirIteratorCopy = _theirIterator.Copy(); } if (ph == null) { if (depth == 0) { ph = new PropertyHelper(myIteratorCopy, theirIteratorCopy, path, type, gameObjectRoot, componentRoot, propertyRoot, root, window, objectMerge, sceneMerge); properties.Add(ph); } else { ph = new PropertyHelper(myIteratorCopy, theirIteratorCopy, path, type, gameObjectParent, componentParent, propertyParent, parent, window, objectMerge, sceneMerge); var children = propertyParent.children; if (children == null) { propertyParent.children = children = new List <PropertyHelper>(1); } children.Add(ph); } } else { ph.mine = myIteratorCopy; ph.theirs = theirIteratorCopy; } lastHelper = ph; lastDepth = depth; } for (var i = 0; i < properties.Count; i++) { var property = properties[i]; if (property.children == null) { property.CheckSame(); } else { var enumerator = DeepCheckSame(property); while (enumerator.MoveNext()) { yield return(false); } } if (!property.Same) { same = false; } } yield return(same); }
public void Draw(float indent, GUILayoutOption colWidth, GUILayoutOption indentOption) { if (window.drawAbort) { return; } if (!window || window.ScrollCheck()) { window.StartRow(Same); var foldoutState = showChildren; thisArg = this; DrawProperty(true, indent, colWidth, indentOption); //Swap buttons var mine = this.mine; var theirs = this.theirs; var hasBothParents = gameObjectParent != null && gameObjectParent.mine && gameObjectParent.theirs || componentParent != null && componentParent.mine && componentParent.theirs || propertyParent != null && propertyParent.mine != null && propertyParent.theirs != null || mine != null && theirs != null && mine.depth == 0; if (hasBothParents) { DrawMidButtons(mine != null, theirs != null, LeftButton, RightButton, LeftDeleteButton, RightDeleteButton); } else { GUILayout.Space(UniMergeConfig.DoubleMidWidth); } DrawProperty(false, indent, colWidth, indentOption); if (foldoutState != showChildren) { thisArg.InvalidateDrawCount(); if (Event.current.alt) { thisArg.SetFoldoutRecursively(showChildren); } } window.EndRow(Same); } var children = this.children; if (children != null) { if (showChildren) { tmpList.Clear(); var count = children.Count; for (var i = 0; i < count; i++) { tmpList.Add(children[i]); } var newWidth = indent + Util.TabSize; var newIndent = GUILayout.Width(newWidth); for (var i = 0; i < count; i++) { tmpList[i].Draw(newWidth, colWidth, newIndent); } } } }