Beispiel #1
0
        // given a groupID, get the list of curve bindings
        public CurveBindingGroup GetGroupBinding(string groupID)
        {
            if (m_groupings == null)
            {
                m_groupings = new Dictionary <string, CurveBindingGroup>();
            }

            CurveBindingGroup result = null;

            if (!m_groupings.TryGetValue(groupID, out result))
            {
                result            = new CurveBindingGroup();
                result.timeRange  = new Vector2(float.MaxValue, float.MinValue);
                result.valueRange = new Vector2(float.MaxValue, float.MinValue);
                List <CurveBindingPair> found = new List <CurveBindingPair>();
                for (int i = 0; i < bindings.Length; i++)
                {
                    if (bindings[i].GetGroupID() == groupID)
                    {
                        CurveBindingPair pair = new CurveBindingPair();
                        pair.binding = bindings[i];
                        pair.curve   = curves[i];
                        found.Add(pair);

                        for (int k = 0; k < curves[i].keys.Length; k++)
                        {
                            var key = curves[i].keys[k];
                            result.timeRange  = new Vector2(Mathf.Min(key.time, result.timeRange.x), Mathf.Max(key.time, result.timeRange.y));
                            result.valueRange = new Vector2(Mathf.Min(key.value, result.valueRange.x), Mathf.Max(key.value, result.valueRange.y));
                        }
                    }
                }
                for (int i = 0; i < objectBindings.Length; i++)
                {
                    if (objectBindings[i].GetGroupID() == groupID)
                    {
                        CurveBindingPair pair = new CurveBindingPair();
                        pair.binding     = objectBindings[i];
                        pair.objectCurve = objectCurves[i];
                        found.Add(pair);

                        for (int k = 0; k < objectCurves[i].Length; k++)
                        {
                            var key = objectCurves[i][k];
                            result.timeRange = new Vector2(Mathf.Min(key.time, result.timeRange.x), Mathf.Max(key.time, result.timeRange.y));
                        }
                    }
                }

                result.curveBindingPairs = found.OrderBy(x => AnimationWindowUtility.GetComponentIndex(x.binding.propertyName)).ToArray();

                m_groupings.Add(groupID, result);
            }
            return(result);
        }
Beispiel #2
0
        public CurveBindingGroup GetGroupBinding(string groupID)
        {
            if (this.m_groupings == null)
            {
                this.m_groupings = new Dictionary <string, CurveBindingGroup>();
            }
            CurveBindingGroup curveBindingGroup = null;

            if (!this.m_groupings.TryGetValue(groupID, out curveBindingGroup))
            {
                curveBindingGroup            = new CurveBindingGroup();
                curveBindingGroup.timeRange  = new Vector2(3.40282347E+38f, -3.40282347E+38f);
                curveBindingGroup.valueRange = new Vector2(3.40282347E+38f, -3.40282347E+38f);
                List <CurveBindingPair> list = new List <CurveBindingPair>();
                for (int i = 0; i < this.bindings.Length; i++)
                {
                    if (this.bindings[i].GetGroupID() == groupID)
                    {
                        list.Add(new CurveBindingPair
                        {
                            binding = this.bindings[i],
                            curve   = this.curves[i]
                        });
                        for (int j = 0; j < this.curves[i].get_keys().Length; j++)
                        {
                            Keyframe keyframe = this.curves[i].get_keys()[j];
                            curveBindingGroup.timeRange  = new Vector2(Mathf.Min(keyframe.get_time(), curveBindingGroup.timeRange.x), Mathf.Max(keyframe.get_time(), curveBindingGroup.timeRange.y));
                            curveBindingGroup.valueRange = new Vector2(Mathf.Min(keyframe.get_value(), curveBindingGroup.valueRange.x), Mathf.Max(keyframe.get_value(), curveBindingGroup.valueRange.y));
                        }
                    }
                }
                for (int k = 0; k < this.objectBindings.Length; k++)
                {
                    if (this.objectBindings[k].GetGroupID() == groupID)
                    {
                        list.Add(new CurveBindingPair
                        {
                            binding     = this.objectBindings[k],
                            objectCurve = this.objectCurves[k]
                        });
                        for (int l = 0; l < this.objectCurves[k].Length; l++)
                        {
                            ObjectReferenceKeyframe objectReferenceKeyframe = this.objectCurves[k][l];
                            curveBindingGroup.timeRange = new Vector2(Mathf.Min(objectReferenceKeyframe.time, curveBindingGroup.timeRange.x), Mathf.Max(objectReferenceKeyframe.time, curveBindingGroup.timeRange.y));
                        }
                    }
                }
                curveBindingGroup.curveBindingPairs = (from x in list
                                                       orderby AnimationWindowUtility.GetComponentIndex(x.binding.propertyName)
                                                       select x).ToArray <CurveBindingPair>();
                this.m_groupings.Add(groupID, curveBindingGroup);
            }
            return(curveBindingGroup);
        }
Beispiel #3
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));
        }
 // make sure vectors and colors are sorted correctly in their subgroups
 static int BindingSort(EditorCurveBinding b)
 {
     return(AnimationWindowUtility.GetComponentIndex(b.propertyName));
 }