public static string GetPropertyGroupName(string propertyName)
 {
     if (AnimationWindowUtility.GetComponentIndex(propertyName) != -1)
     {
         return(propertyName.Substring(0, propertyName.Length - 2));
     }
     return(propertyName);
 }
Ejemplo n.º 2
0
        public int CompareTo(AnimationWindowCurve obj)
        {
            if (!path.Equals(obj.path))
            {
                return(ComparePaths(obj.path));
            }

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

            // 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 (obj.type == type)
            {
                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(string.Compare((path + type + propertyName), obj.path + obj.type + obj.propertyName, StringComparison.Ordinal));
        }
        public static string GetPropertyGroupName(string propertyName)
        {
            string result;

            if (AnimationWindowUtility.GetComponentIndex(propertyName) != -1)
            {
                result = propertyName.Substring(0, propertyName.Length - 2);
            }
            else
            {
                result = propertyName;
            }
            return(result);
        }
        public int CompareTo(AnimationWindowCurve obj)
        {
            bool flag = this.path.Equals(obj.path);

            if (!flag && this.depth != obj.depth)
            {
                return((this.depth >= obj.depth) ? 1 : -1);
            }
            bool flag2 = this.type == typeof(Transform) && obj.type == typeof(Transform) && flag;
            bool flag3 = (this.type == typeof(Transform) || obj.type == typeof(Transform)) && flag;

            if (flag2)
            {
                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"))
                {
                    return(-1);
                }
                if (nicePropertyGroupDisplayName.Contains("Rotation") && nicePropertyGroupDisplayName2.Contains("Position"))
                {
                    return(1);
                }
            }
            else
            {
                if (flag3)
                {
                    if (this.type == typeof(Transform))
                    {
                        return(-1);
                    }
                    return(1);
                }
                else
                {
                    if (this.path == obj.path && obj.type == this.type)
                    {
                        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))
                        {
                            return(componentIndex2 - componentIndex);
                        }
                    }
                }
            }
            return((this.path + this.type + this.propertyName).CompareTo(obj.path + obj.type + obj.propertyName));
        }
Ejemplo n.º 5
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);
        }
        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));
        }