PixelInBounds() public static method

public static PixelInBounds ( IntVector2 pixelPosition, Sprite sprite ) : bool
pixelPosition Assets.RagePixel2.Editor.Utility.IntVector2
sprite UnityEngine.Sprite
return bool
Ejemplo n.º 1
0
        public void OnMouseDown(RagePixelState state)
        {
            if (Event.current.button != 0 || !Event.current.control || active)
            {
                return;
            }

            IntVector2 mouse = GetMousePixel(state, false);

            if (!Utility.PixelInBounds(mouse, state.sprite))
            {
                state.paintColor = new Color(0f, 0f, 0f, 0f);
                Event.current.Use();
                state.Repaint();
                return;
            }

            Color newColor = state.sprite.texture.GetPixel((int)mouse.x, (int)mouse.y);

            if (state.mode == RagePixelState.SceneMode.ReplaceColor)
            {
                state.replaceTargetColor = newColor;
            }
            else
            {
                state.paintColor = newColor;
            }

            Event.current.Use();
            m_MarqueeStart = mouse;
            m_MarqueeEnd   = mouse;
            state.Repaint();
        }