Inheritance: EditorWindow
コード例 #1
0
 protected Helper(Helper parent, UniMergeWindow window, ObjectMerge objectMerge, SceneMerge sceneMerge)
 {
     this.parent      = parent;
     this.window      = window;
     this.objectMerge = objectMerge;
     this.sceneMerge  = sceneMerge;
 }
コード例 #2
0
        public PropertyHelper(SerializedProperty mine, SerializedProperty theirs, string propertyPath,
                              Helper parent = null, UniMergeWindow window = null) : base(parent, window)
        {
            this.mine         = mine;
            this.theirs       = theirs;
            this.propertyPath = propertyPath;

            objectMerge = window as ObjectMerge;
            sceneMerge  = window as SceneMerge;

            gameObjectParent = parent as GameObjectHelper;
            componentParent  = parent as ComponentHelper;
            propertyParent   = parent as PropertyHelper;
        }
コード例 #3
0
        PropertyHelper(SerializedProperty mine, SerializedProperty theirs, string propertyPath,
                       SerializedPropertyType propertyType, GameObjectHelper gameObjectParent, ComponentHelper componentParent,
                       PropertyHelper propertyParent, Helper parent, UniMergeWindow window,
                       ObjectMerge objectMerge, SceneMerge sceneMerge) : base(parent, window, objectMerge, sceneMerge)
        {
            this.mine         = mine;
            this.theirs       = theirs;
            this.propertyPath = propertyPath;
            this.propertyType = propertyType;

            this.gameObjectParent = gameObjectParent;
            this.componentParent  = componentParent;
            this.propertyParent   = propertyParent;
        }
コード例 #4
0
        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;
                // ReSharper disable once LoopVariableIsNeverChangedInsideLoop
                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);
        }