public AnimationWindowHierarchyPropertyGroupNode(Type animatableObjectType, int setId, string propertyName, string path, TreeViewItem parent) : base(AnimationWindowUtility.GetPropertyNodeID(setId, path, animatableObjectType, propertyName), (parent == null) ? -1 : (parent.depth + 1), parent, animatableObjectType, AnimationWindowUtility.GetPropertyGroupName(propertyName), path, AnimationWindowUtility.GetNicePropertyGroupDisplayName(animatableObjectType, propertyName))
 {
 }
示例#2
0
        public int CompareTo(AnimationWindowCurve obj)
        {
            bool flag  = this.path.Equals(obj.path);
            bool flag2 = obj.type == this.type;
            int  result;

            if (!flag && this.depth != obj.depth)
            {
                int num        = Math.Min(this.path.Length, obj.path.Length);
                int startIndex = 0;
                int i;
                for (i = 0; i < num; i++)
                {
                    if (this.path[i] != obj.path[i])
                    {
                        break;
                    }
                    if (this.path[i] == '/')
                    {
                        startIndex = i + 1;
                    }
                }
                if (i == num)
                {
                    startIndex = num;
                }
                string text  = this.path.Substring(startIndex);
                string text2 = obj.path.Substring(startIndex);
                if (string.IsNullOrEmpty(text))
                {
                    result = -1;
                }
                else if (string.IsNullOrEmpty(text2))
                {
                    result = 1;
                }
                else
                {
                    Regex  regex  = new Regex("^[^\\/]*\\/");
                    Match  match  = regex.Match(text);
                    string text3  = (!match.Success) ? text : match.Value.Substring(0, match.Value.Length - 1);
                    Match  match2 = regex.Match(text2);
                    string strB   = (!match2.Success) ? text2 : match2.Value.Substring(0, match2.Value.Length - 1);
                    result = text3.CompareTo(strB);
                }
            }
            else
            {
                bool flag3 = this.type == typeof(Transform) && obj.type == typeof(Transform) && flag;
                bool flag4 = (this.type == typeof(Transform) || obj.type == typeof(Transform)) && flag;
                if (flag3)
                {
                    string nicePropertyGroupDisplayName  = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(this.propertyName));
                    string nicePropertyGroupDisplayName2 = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(obj.propertyName));
                    if (nicePropertyGroupDisplayName.Contains("Position") && nicePropertyGroupDisplayName2.Contains("Rotation"))
                    {
                        result = -1;
                        return(result);
                    }
                    if (nicePropertyGroupDisplayName.Contains("Rotation") && nicePropertyGroupDisplayName2.Contains("Position"))
                    {
                        result = 1;
                        return(result);
                    }
                }
                else if (flag4)
                {
                    if (this.type == typeof(Transform))
                    {
                        result = -1;
                        return(result);
                    }
                    result = 1;
                    return(result);
                }
                if (flag && flag2)
                {
                    int componentIndex  = AnimationWindowUtility.GetComponentIndex(obj.propertyName);
                    int componentIndex2 = AnimationWindowUtility.GetComponentIndex(this.propertyName);
                    if (componentIndex != -1 && componentIndex2 != -1 && this.propertyName.Substring(0, this.propertyName.Length - 2) == obj.propertyName.Substring(0, obj.propertyName.Length - 2))
                    {
                        result = componentIndex2 - componentIndex;
                        return(result);
                    }
                }
                result = (this.path + this.type + this.propertyName).CompareTo(obj.path + obj.type + obj.propertyName);
            }
            return(result);
        }
示例#3
0
        public int CompareTo(AnimationWindowCurve obj)
        {
            bool pathEquals = path.Equals(obj.path);
            bool typeEquals = obj.type == type;

            if (!pathEquals && depth != obj.depth)
            {
                int minLength    = Math.Min(path.Length, obj.path.Length);
                int commonLength = 0;
                int index        = 0;
                for (; index < minLength; ++index)
                {
                    if (path[index] != obj.path[index])
                    {
                        break;
                    }

                    if (path[index] == '/')
                    {
                        commonLength = index + 1;
                    }
                }

                if (index == minLength)
                {
                    commonLength = minLength;
                }

                string subPath1 = path.Substring(commonLength);
                string subPath2 = obj.path.Substring(commonLength);

                if (String.IsNullOrEmpty(subPath1))
                {
                    return(-1);
                }
                else if (String.IsNullOrEmpty(subPath2))
                {
                    return(1);
                }

                Regex r = new Regex(@"^[^\/]*\/");

                Match  match1 = r.Match(subPath1);
                string next1  = match1.Success ? match1.Value.Substring(0, match1.Value.Length - 1) : subPath1;

                Match  match2 = r.Match(subPath2);
                string next2  = match2.Success ? match2.Value.Substring(0, match2.Value.Length - 1) : subPath2;

                return(next1.CompareTo(next2));
            }

            bool sameTransformComponent  = type == typeof(Transform) && obj.type == typeof(Transform) && pathEquals;
            bool oneIsTransformComponent = (type == typeof(Transform) || obj.type == typeof(Transform)) && pathEquals;

            // We want to sort position before rotation
            if (sameTransformComponent)
            {
                string propertyGroupA = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(propertyName));
                string propertyGroupB = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(obj.propertyName));

                if (propertyGroupA.Contains("Position") && propertyGroupB.Contains("Rotation"))
                {
                    return(-1);
                }
                if (propertyGroupA.Contains("Rotation") && propertyGroupB.Contains("Position"))
                {
                    return(1);
                }
            }
            // Transform component should always come first.
            else if (oneIsTransformComponent)
            {
                if (type == typeof(Transform))
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            }

            // Sort (.r, .g, .b, .a) and (.x, .y, .z, .w)
            if (pathEquals && typeEquals)
            {
                int lhsIndex = AnimationWindowUtility.GetComponentIndex(obj.propertyName);
                int rhsIndex = AnimationWindowUtility.GetComponentIndex(propertyName);
                if (lhsIndex != -1 && rhsIndex != -1 && propertyName.Substring(0, propertyName.Length - 2) == obj.propertyName.Substring(0, obj.propertyName.Length - 2))
                {
                    return(rhsIndex - lhsIndex);
                }
            }

            return((path + type + propertyName).CompareTo(obj.path + obj.type + obj.propertyName));
        }
        private AnimationWindowHierarchyPropertyGroupNode AddPropertyGroupToHierarchy(AnimationWindowCurve[] curves, AnimationWindowHierarchyNode parentNode, SerializedObject so)
        {
            List <AnimationWindowHierarchyNode> childNodes = new List <AnimationWindowHierarchyNode>();

            System.Type animatableObjectType = curves[0].type;
            AnimationWindowHierarchyPropertyGroupNode node = new AnimationWindowHierarchyPropertyGroupNode(animatableObjectType, 0, AnimationWindowUtility.GetPropertyGroupName(curves[0].propertyName), curves[0].path, parentNode, AnimationWindowUtility.GetNicePropertyGroupDisplayName(curves[0].binding, so));

            node.icon = GetIcon(curves[0].binding);

            node.indent = curves[0].depth;
            node.curves = curves;

            foreach (AnimationWindowCurve curve in curves)
            {
                AnimationWindowHierarchyPropertyNode childNode = AddPropertyToHierarchy(curve, node, so);
                // For child nodes we do not want to display the type in front (It is already shown by the group node)
                childNode.displayName = AnimationWindowUtility.GetPropertyDisplayName(childNode.propertyName);
                childNodes.Add(childNode);
            }

            TreeViewUtility.SetChildParentReferences(new List <TreeViewItem>(childNodes.ToArray()), node);
            return(node);
        }