Пример #1
0
    private void Update()
    {
        currentAngle = -transform.rotation.eulerAngles.z;

        Ray        ray = new Ray(paintingTransform.position, paintingTransform.forward);
        RaycastHit hit;

        Debug.DrawRay(ray.origin, ray.direction * raycastLength);

        if (paintReceiverCollider.Raycast(ray, out hit, raycastLength))
        {
            if (lastDrawPosition.HasValue && lastDrawPosition.Value != hit.textureCoord)
            {
                paintReceiver.DrawLine(stamp, lastDrawPosition.Value, hit.textureCoord, lastAngle, currentAngle, color, spacing);
            }
            else
            {
                paintReceiver.CreateSplash(hit.textureCoord, stamp, color, currentAngle);
            }

            lastAngle = currentAngle;

            lastDrawPosition = hit.textureCoord;
        }
        else
        {
            lastDrawPosition = null;
        }
    }
Пример #2
0
        private void Update()
        {
            if (m_PaintReceiver == null)
            {
                return;
            }

            if (Input.GetMouseButtonDown(1))
            {
                m_PaintReceiver.ResetColor();

                return;
            }

            if (!Input.GetMouseButton(0))
            {
                m_LastDrawPosition = null;
                return;
            }

            m_CurrentAngle = -transform.rotation.eulerAngles.z;


            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            Debug.DrawRay(ray.origin, ray.direction * m_RaycastLength);

            if (m_PaintReceiverCollider.Raycast(ray, out hit, m_RaycastLength))
            {
                if (m_LastDrawPosition.HasValue && m_LastDrawPosition.Value != hit.textureCoord)
                {
                    m_PaintReceiver.DrawLine(m_LastDrawPosition.Value, hit.textureCoord, m_LastAngle, m_CurrentAngle, m_CurrentColor, m_PaintingDistance, m_Strength, m_Spacing);
                }
                else
                {
                    m_PaintReceiver.CreateSplash(hit.textureCoord, m_CurrentColor, m_PaintingDistance, m_Strength);
                }

                m_LastAngle = m_CurrentAngle;

                m_LastDrawPosition = hit.textureCoord;
            }
            else
            {
                m_LastDrawPosition = null;
            }
        }
Пример #3
0
 private void DrawLine()
 {
     m_paintReceiver.DrawLine(stamp, lastDrawPosition.Value, m_texCoord, lastAngle, currentAngle, m_color, spacing);
 }