优化画线逻辑
This commit is contained in:
parent
5ca2c9ce43
commit
d95f71b5e3
@ -7,7 +7,6 @@ using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.UI;
|
||||
using static UnityEditor.Progress;
|
||||
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class ScreenShotPainter : MonoBehaviour
|
||||
@ -621,6 +620,7 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
ChangeToEraser(this.status == Status.Eraser);
|
||||
}
|
||||
|
||||
Vector2 lineStart = Vector2.zero;
|
||||
private void OnPaintBeginDrag(BaseEventData arg0)
|
||||
{
|
||||
if (_enabled && _haveRegion)
|
||||
@ -631,14 +631,14 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
break;
|
||||
case Status.Line:
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
if (_currentLine == null)
|
||||
{
|
||||
_currentLine = new LineSegment(_paintBrushMat.GetColor("_Color"), _brushSize, _eraserFlag);
|
||||
Graphics.Blit(_currentRenderTexture, _currentLine.Texture);
|
||||
}
|
||||
LerpPaint(Input.mousePosition, _eraserFlag);
|
||||
}
|
||||
|
||||
lineStart = Input.mousePosition;
|
||||
_lastPoint = lineStart;
|
||||
|
||||
break;
|
||||
|
||||
@ -677,6 +677,16 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
}
|
||||
LerpPaint(Input.mousePosition, _eraserFlag);
|
||||
break;
|
||||
case Status.Line:
|
||||
if (_lastPoint != default && Vector2.Distance(lineStart, Input.mousePosition) > 2f)
|
||||
{
|
||||
Graphics.Blit(_currentLine.Texture, _currentRenderTexture);
|
||||
_paintCanvasImg.texture = _currentRenderTexture;
|
||||
_lastPoint = lineStart;
|
||||
Paint(_eraserFlag, lineStart);
|
||||
LerpPaint(Input.mousePosition, _eraserFlag);
|
||||
}
|
||||
break;
|
||||
case Status.Rect:
|
||||
Graphics.Blit(_currentLine.Texture, _currentRenderTexture);
|
||||
_paintCanvasImg.texture = _currentRenderTexture;
|
||||
@ -709,8 +719,8 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
case Status.Line:
|
||||
if (_currentLine != null)
|
||||
{
|
||||
LerpPaint(Input.mousePosition, false);
|
||||
FinishedRaw();
|
||||
lineStart = Vector2.zero;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user