Esempio n. 1
0
        public static string GetDescription(this CurveBindingGroup group, float t)
        {
            string result = string.Empty;

            if (group.isFloatCurve)
            {
                if (group.count > 1)
                {
                    result += "(" + group.curveBindingPairs[0].curve.Evaluate(t).ToString("0.##");
                    for (int j = 1; j < group.curveBindingPairs.Length; j++)
                    {
                        result += "," + group.curveBindingPairs[j].curve.Evaluate(t).ToString("0.##");
                    }
                    result += ")";
                }
                else
                {
                    result = group.curveBindingPairs[0].curve.Evaluate(t).ToString("0.##");
                }
            }
            else if (group.isObjectCurve)
            {
                Object obj = null;
                if (group.curveBindingPairs[0].objectCurve.Length > 0)
                {
                    obj = CurveEditUtility.Evaluate(group.curveBindingPairs[0].objectCurve, t);
                }
                result = (obj == null ? "None" : obj.name);
            }

            return(result);
        }
        public static string GetDescription(this CurveBindingGroup group, float t)
        {
            string text = string.Empty;

            if (group.isFloatCurve)
            {
                if (group.count > 1)
                {
                    text = text + "(" + group.curveBindingPairs[0].curve.Evaluate(t).ToString("0.##");
                    for (int i = 1; i < group.curveBindingPairs.Length; i++)
                    {
                        text = text + "," + group.curveBindingPairs[i].curve.Evaluate(t).ToString("0.##");
                    }
                    text += ")";
                }
                else
                {
                    text = group.curveBindingPairs[0].curve.Evaluate(t).ToString("0.##");
                }
            }
            else if (group.isObjectCurve)
            {
                Object @object = null;
                if (group.curveBindingPairs[0].objectCurve.Length > 0)
                {
                    @object = CurveEditUtility.Evaluate(group.curveBindingPairs[0].objectCurve, t);
                }
                text = ((!(@object == null)) ? @object.get_name() : "None");
            }
            return(text);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public static bool IsColorGroup(this CurveBindingGroup curves)
        {
            if (!curves.isFloatCurve)
            {
                return(false);
            }
            if (curves.count != 3 && curves.count != 4)
            {
                return(false);
            }
            char l = curves.curveBindingPairs[0].binding.propertyName.Last();

            return(l == 'r' || l == 'g' || l == 'b' || l == 'a');
        }
Esempio n. 6
0
        public static bool IsVectorGroup(this CurveBindingGroup curves)
        {
            if (!curves.isFloatCurve)
            {
                return(false);
            }
            if (curves.count <= 1 || curves.count > 4)
            {
                return(false);
            }
            char l = curves.curveBindingPairs[0].binding.propertyName.Last();

            return(l == 'x' || l == 'y' || l == 'z' || l == 'w');
        }
        public static bool IsColorGroup(this CurveBindingGroup curves)
        {
            bool result;

            if (!curves.isFloatCurve)
            {
                result = false;
            }
            else if (curves.count != 3 && curves.count != 4)
            {
                result = false;
            }
            else
            {
                char c = curves.curveBindingPairs[0].binding.propertyName.Last <char>();
                result = (c == 'r' || c == 'g' || c == 'b' || c == 'a');
            }
            return(result);
        }
        public static bool IsVectorGroup(this CurveBindingGroup curves)
        {
            bool result;

            if (!curves.isFloatCurve)
            {
                result = false;
            }
            else if (curves.count <= 1 || curves.count > 4)
            {
                result = false;
            }
            else
            {
                char c = curves.curveBindingPairs[0].binding.propertyName.Last <char>();
                result = (c == 'x' || c == 'y' || c == 'z' || c == 'w');
            }
            return(result);
        }
        public Dictionary <float, string> GetDescriptions()
        {
            Dictionary <float, string> dictionary = new Dictionary <float, string>();
            AnimationClipCurveInfo     curveInfo  = AnimationClipCurveCache.Instance.GetCurveInfo(this.m_Track.animClip);
            HashSet <string>           hashSet    = new HashSet <string>();

            EditorCurveBinding[] bindings = curveInfo.bindings;
            for (int i = 0; i < bindings.Length; i++)
            {
                EditorCurveBinding binding = bindings[i];
                string             groupID = binding.GetGroupID();
                if (!hashSet.Contains(groupID))
                {
                    CurveBindingGroup groupBinding = curveInfo.GetGroupBinding(groupID);
                    string            nicePropertyGroupDisplayName = AnimationWindowUtility.GetNicePropertyGroupDisplayName(binding.get_type(), binding.propertyName);
                    float[]           keyTimes = curveInfo.keyTimes;
                    for (int j = 0; j < keyTimes.Length; j++)
                    {
                        float  num  = keyTimes[j];
                        float  num2 = num + (float)this.m_Track.openClipTimeOffset;
                        string text = nicePropertyGroupDisplayName + " : " + groupBinding.GetDescription(num2);
                        if (dictionary.ContainsKey(num2))
                        {
                            Dictionary <float, string> dictionary2;
                            float key;
                            (dictionary2 = dictionary)[key = num2] = dictionary2[key] + '\n' + text;
                        }
                        else
                        {
                            dictionary.Add(num2, text);
                        }
                    }
                    hashSet.Add(groupID);
                }
            }
            return(dictionary);
        }
Esempio n. 10
0
 // Extentions to determine curve types
 public static bool IsEnableGroup(this CurveBindingGroup curves)
 {
     return(curves.isFloatCurve && curves.count == 1 && curves.curveBindingPairs[0].binding.propertyName == "m_Enabled");
 }