Esempio n. 1
0
        public Color Colorize(RigidBody rb)
        {
            if (rb == null)
            {
                throw new ArgumentNullException("rb");
            }

            var colorData = GetOrCreateColorData(rb);

            if (colorData.Colorized)
            {
                return(colorData.Color);
            }

            var shapes = rb.GetComponentsInChildren <Shape>();

            foreach (var shape in shapes)
            {
                if (!shape.IsEnabledInHierarchy)
                {
                    continue;
                }

                var shapeFilters = ShapeDebugRenderData.GetMeshFilters(shape);
                foreach (var shapeFilter in shapeFilters)
                {
                    m_meshColors.Add(shapeFilter, colorData.Color);
                }
            }

            colorData.Colorized = true;

            return(colorData.Color);
        }
Esempio n. 2
0
        public void Highlight(RigidBody rb, SelectionType selectionType)
        {
            if (rb == null)
            {
                return;
            }

            Color rbColor = Colorize(rb);

            foreach (var shape in rb.Shapes)
            {
                if (!shape.IsEnabledInHierarchy)
                {
                    continue;
                }

                var shapeFilters = ShapeDebugRenderData.GetMeshFilters(shape);
                foreach (var shapeFilter in shapeFilters)
                {
                    m_meshColors[shapeFilter] = selectionType == SelectionType.ConstantColor ?
                                                ChangeColorHSVDelta(rbColor, HSVDeltaData.SelectedRigidBody) :
                                                TimeInterpolator.Lerp(rbColor, ChangeColorHSVDelta(rbColor, HSVDeltaData.HighlightedRigidBodyMax));
                }
            }

            Color filterColor = ColorizeMeshFilters(rb);
            var   filters     = rb.GetComponentsInChildren <MeshFilter>();

            foreach (var filter in filters)
            {
                m_meshColors[filter] = selectionType == SelectionType.ConstantColor ?
                                       ChangeColorHSVDelta(filterColor, HSVDeltaData.SelectedMeshFilter) :
                                       TimeInterpolator.Lerp(filterColor, ChangeColorHSVDelta(filterColor, HSVDeltaData.HighlightedRigidBodyMax));
            }
        }
Esempio n. 3
0
        public void Highlight(Shape shape, SelectionType selectionType)
        {
            if (shape == null)
            {
                return;
            }

            RigidBody rb    = shape.GetComponentInParent <RigidBody>();
            Color     color = rb != null?Colorize(rb) : ShapeColor;

            var shapeFilters = ShapeDebugRenderData.GetMeshFilters(shape);

            foreach (var shapeFilter in shapeFilters)
            {
                m_meshColors[shapeFilter] = selectionType == SelectionType.ConstantColor ?
                                            ChangeColorHSVDelta(color, HSVDeltaData.SelectedShape) :
                                            TimeInterpolator.Lerp(color, ChangeColorHSVDelta(color, HSVDeltaData.HighlightedShapeMax));
            }
        }