Example #1
0
        public void SetCurves(AnimationCurve[] curves, EditorCurveBinding[] bindings)
        {
            m_Curves = curves;
            if (m_Curves != null && m_Curves.Length > 0)
            {
                m_CurveWrappers = new CurveWrapper[m_Curves.Length];
                for (int i = 0; i < m_Curves.Length; i++)
                {
                    var cw = new CurveWrapper
                    {
                        renderer = new NormalCurveRenderer(m_Curves[i]),
                        readOnly = false,
                        color    = EditorGUI.kCurveColor,
                        id       = curves[i].GetHashCode(),
                        hidden   = false,
                        regionId = -1
                    };

                    cw.renderer.SetWrap(WrapMode.Clamp, WrapMode.Clamp);
                    cw.renderer.SetCustomRange(0, 1);

                    if (bindings != null)
                    {
                        cw.binding = bindings[i];
                        cw.color   = CurveUtility.GetPropertyColor(bindings[i].propertyName);
                        cw.id      = bindings[i].GetHashCode();
                    }

                    m_CurveWrappers[i] = cw;
                }

                UpdateSelectionColors();
                m_CurveEditor.animationCurves = m_CurveWrappers;
            }
        }
        static void DoCurveColorIndicator(Rect rect, CurveTreeViewNode node)
        {
            if (node == null)
            {
                return;
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            Color originalColor = GUI.color;

            if (node.bindings.Length == 1 && !node.bindings[0].isPPtrCurve)
            {
                GUI.color = CurveUtility.GetPropertyColor(node.bindings[0].propertyName);
            }
            else
            {
                GUI.color = s_KeyColorForNonCurves;
            }

            Texture icon = CurveUtility.GetIconCurve();

            rect = new Rect(rect.xMax - k_RowRightOffset - (k_CurveColorIndicatorIconSize / 2) - 5,
                            rect.yMin + k_ColorIndicatorTopMargin + (rect.height - EditorGUIUtility.singleLineHeight) / 2,
                            k_CurveColorIndicatorIconSize,
                            k_CurveColorIndicatorIconSize);

            GUI.DrawTexture(rect, icon, ScaleMode.ScaleToFit, true, 1);

            GUI.color = originalColor;
        }
        private void DoCurveColorIndicator(Rect rect, AnimationWindowHierarchyNode node)
        {
            if (Event.current.type == EventType.Repaint)
            {
                Color color = GUI.color;
                if (!this.state.showCurveEditor)
                {
                    GUI.color = k_KeyColorInDopesheetMode;
                }
                else if ((node.curves.Length == 1) && !node.curves[0].isPPtrCurve)
                {
                    GUI.color = CurveUtility.GetPropertyColor(node.curves[0].binding.propertyName);
                }
                else
                {
                    GUI.color = k_KeyColorForNonCurves;
                }
                bool flag = false;
                if (AnimationMode.InAnimationMode())
                {
                    foreach (AnimationWindowCurve curve in node.curves)
                    {
                        if (curve.m_Keyframes.Any <AnimationWindowKeyframe>(key => this.state.time.ContainsTime(key.time)))
                        {
                            flag = true;
                        }
                    }
                }
                Texture image = !flag?CurveUtility.GetIconCurve() : CurveUtility.GetIconKey();

                rect = new Rect(((rect.xMax - 10f) - (image.width / 2)) - 5f, rect.yMin + 3f, (float)image.width, (float)image.height);
                GUI.DrawTexture(rect, image, ScaleMode.ScaleToFit, true, 1f);
                GUI.color = color;
            }
        }
 public void SetCurves(AnimationCurve[] curves, EditorCurveBinding[] bindings)
 {
     this.m_Curves = curves;
     if (this.m_Curves != null && this.m_Curves.Length > 0)
     {
         this.m_CurveWrappers = new CurveWrapper[this.m_Curves.Length];
         for (int i = 0; i < this.m_Curves.Length; i++)
         {
             CurveWrapper curveWrapper = new CurveWrapper();
             curveWrapper.set_renderer(new NormalCurveRenderer(this.m_Curves[i]));
             curveWrapper.readOnly = false;
             curveWrapper.color    = EditorGUI.kCurveColor;
             curveWrapper.id       = curves[i].GetHashCode();
             curveWrapper.hidden   = false;
             curveWrapper.regionId = -1;
             CurveWrapper curveWrapper2 = curveWrapper;
             curveWrapper2.get_renderer().SetWrap(1, 1);
             curveWrapper2.get_renderer().SetCustomRange(0f, 1f);
             if (bindings != null)
             {
                 curveWrapper2.binding = bindings[i];
                 curveWrapper2.color   = CurveUtility.GetPropertyColor(bindings[i].propertyName);
                 curveWrapper2.id      = bindings[i].GetHashCode();
             }
             this.m_CurveWrappers[i] = curveWrapper2;
         }
         this.UpdateSelectionColors();
         this.m_CurveEditor.set_animationCurves(this.m_CurveWrappers);
     }
 }
        public static CurveWrapper GetCurveWrapper(AnimationWindowCurve curve, AnimationClip clip)
        {
            CurveWrapper curveWrapper = new CurveWrapper();

            curveWrapper.renderer = (CurveRenderer) new NormalCurveRenderer(curve.ToAnimationCurve());
            curveWrapper.renderer.SetWrap(WrapMode.Once, !clip.isLooping ? WrapMode.Once : WrapMode.Loop);
            curveWrapper.renderer.SetCustomRange(clip.startTime, clip.stopTime);
            curveWrapper.binding = curve.binding;
            curveWrapper.id      = CurveUtility.GetCurveID(clip, curve.binding);
            curveWrapper.color   = CurveUtility.GetPropertyColor(curve.propertyName);
            curveWrapper.hidden  = false;
            return(curveWrapper);
        }
Example #6
0
        public void ConfigureCurveWrapper(CurveWrapper wrapper)
        {
            var color = CurveUtility.GetPropertyColor(wrapper.binding.propertyName);

            wrapper.color = color;

            float h, s, v;

            Color.RGBToHSV(color, out h, out s, out v);
            wrapper.wrapColorMultiplier = Color.HSVToRGB(h, s * 0.33f, v * 1.15f);

            var curve = AnimationUtility.GetEditorCurve(proxyCurves, wrapper.binding);

            wrapper.renderer = new NormalCurveRenderer(curve);

            // Use curve length instead of animation clip length
            wrapper.renderer.SetCustomRange(0.0f, curve.keys.Last().time);
        }
        private void DoCurveColorIndicator(Rect rect, AnimationWindowHierarchyNode node)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            Color color = GUI.color;

            if (!this.state.m_ShowCurveEditor)
            {
                GUI.color = AnimationWindowHierarchyGUI.k_KeyColorInDopesheetMode;
            }
            else
            {
                if (node.curves.Length == 1 && !node.curves[0].isPPtrCurve)
                {
                    GUI.color = CurveUtility.GetPropertyColor(node.curves[0].binding.propertyName);
                }
                else
                {
                    GUI.color = AnimationWindowHierarchyGUI.k_KeyColorForNonCurves;
                }
            }
            bool flag = false;

            if (AnimationMode.InAnimationMode())
            {
                AnimationWindowCurve[] curves = node.curves;
                for (int i = 0; i < curves.Length; i++)
                {
                    AnimationWindowCurve animationWindowCurve = curves[i];
                    if (animationWindowCurve.m_Keyframes.Any((AnimationWindowKeyframe key) => this.state.time.ContainsTime(key.time)))
                    {
                        flag = true;
                    }
                }
            }
            Texture texture = (!flag) ? CurveUtility.GetIconCurve() : CurveUtility.GetIconKey();

            rect = new Rect(rect.xMax - 10f - (float)(texture.width / 2) - 5f, rect.yMin + 3f, (float)texture.width, (float)texture.height);
            GUI.DrawTexture(rect, texture, ScaleMode.ScaleToFit, true, 1f);
            GUI.color = color;
        }
        private void DoCurveColorIndicator(Rect rect, AnimationWindowHierarchyNode node)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            Color originalColor = GUI.color;

            if (!state.showCurveEditor)
            {
                GUI.color = k_KeyColorInDopesheetMode;
            }
            else if (node.curves.Length == 1 && !node.curves[0].isPPtrCurve)
            {
                GUI.color = CurveUtility.GetPropertyColor(node.curves[0].binding.propertyName);
            }
            else
            {
                GUI.color = k_KeyColorForNonCurves;
            }

            bool hasKey = false;

            if (state.previewing)
            {
                foreach (var curve in node.curves)
                {
                    if (curve.m_Keyframes.Any(key => state.time.ContainsTime(key.time)))
                    {
                        hasKey = true;
                    }
                }
            }

            Texture icon = hasKey ? CurveUtility.GetIconKey() : CurveUtility.GetIconCurve();

            rect = new Rect(rect.xMax - k_RowRightOffset - (icon.width / 2) - 5, rect.yMin + k_ColorIndicatorTopMargin, icon.width, icon.height);
            GUI.DrawTexture(rect, icon, ScaleMode.ScaleToFit, true, 1);

            GUI.color = originalColor;
        }
 private void DoCurveColorIndicator(Rect rect, CurveTreeViewNode node)
 {
     if (node != null)
     {
         if (Event.get_current().get_type() == 7)
         {
             Color color = GUI.get_color();
             if (node.bindings.Length == 1 && !node.bindings[0].get_isPPtrCurve())
             {
                 GUI.set_color(CurveUtility.GetPropertyColor(node.bindings[0].propertyName));
             }
             else
             {
                 GUI.set_color(BindingTreeViewGUI.s_KeyColorForNonCurves);
             }
             Texture iconCurve = CurveUtility.GetIconCurve();
             rect = new Rect(rect.get_xMax() - BindingTreeViewGUI.s_RowRightOffset - (float)iconCurve.get_width() * 0.5f - 5f, rect.get_yMin() + BindingTreeViewGUI.s_ColorIndicatorTopMargin, (float)iconCurve.get_width(), (float)iconCurve.get_height());
             GUI.DrawTexture(rect, iconCurve, 2, true, 1f);
             GUI.set_color(color);
         }
     }
 }
Example #10
0
 protected virtual void ConfigureCurveWrapper(CurveWrapper wrapper)
 {
     wrapper.color    = CurveUtility.GetPropertyColor(wrapper.binding.propertyName);
     wrapper.renderer = new NormalCurveRenderer(AnimationUtility.GetEditorCurve(animationClip, wrapper.binding));
     wrapper.renderer.SetCustomRange(0.0f, animationClip.length);
 }
Example #11
0
        private void DoCurveColorIndicator(Rect rect, AnimationWindowHierarchyNode node)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            Color color = GUI.color;

            GUI.color = this.state.showCurveEditor ? (node.curves.Length != 1 || node.curves[0].isPPtrCurve ? AnimationWindowHierarchyGUI.k_KeyColorForNonCurves : CurveUtility.GetPropertyColor(node.curves[0].binding.propertyName)) : AnimationWindowHierarchyGUI.k_KeyColorInDopesheetMode;
            bool flag = false;

            if (AnimationMode.InAnimationMode())
            {
                foreach (AnimationWindowCurve curve in node.curves)
                {
                    if (curve.m_Keyframes.Any <AnimationWindowKeyframe>((Func <AnimationWindowKeyframe, bool>)(key => this.state.time.ContainsTime(key.time))))
                    {
                        flag = true;
                    }
                }
            }
            Texture image = !flag ? (Texture)CurveUtility.GetIconCurve() : (Texture)CurveUtility.GetIconKey();

            rect = new Rect((float)((double)rect.xMax - 10.0 - (double)(image.width / 2) - 5.0), rect.yMin + 3f, (float)image.width, (float)image.height);
            GUI.DrawTexture(rect, image, ScaleMode.ScaleToFit, true, 1f);
            GUI.color = color;
        }