Merge branch 'master' into 3DBody
This commit is contained in:
commit
4f7e881083
@ -472,12 +472,10 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
|
||||
void OnPostRender()
|
||||
{
|
||||
Debug.LogError(" OnPostRender");
|
||||
if (!enabled)
|
||||
return;
|
||||
if (_drawRegionRect)
|
||||
{
|
||||
Debug.LogError("111");
|
||||
//如果材质球不存在
|
||||
if (!_lineMaterial)
|
||||
{
|
||||
@ -548,10 +546,6 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
_drawRegionRect = false;
|
||||
float width = _rightUpConnerPoint.x - _leftDownConnerPoint.x;
|
||||
float height = _rightUpConnerPoint.y - _leftDownConnerPoint.y;
|
||||
Debug.LogError(_leftDownConnerPoint.x.ToString("0.00"));
|
||||
Debug.LogError(_leftDownConnerPoint.y.ToString("0.00"));
|
||||
Debug.LogError("width:" + width);
|
||||
Debug.LogError("width:" + height);
|
||||
Rect rect = new Rect(_leftDownConnerPoint.x, Screen.height - _leftUpConnerPoint.y, width, height);
|
||||
|
||||
|
||||
@ -619,6 +613,13 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
|
||||
|
||||
|
||||
|
||||
public void SetStatus(Status status)
|
||||
{
|
||||
this.status = status;
|
||||
ChangeToEraser(this.status == Status.Eraser);
|
||||
}
|
||||
|
||||
private void OnPaintBeginDrag(BaseEventData arg0)
|
||||
{
|
||||
if (_enabled && _haveRegion)
|
||||
@ -658,13 +659,6 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetStatus(Status status)
|
||||
{
|
||||
this.status = status;
|
||||
ChangeToEraser(this.status == Status.Eraser);
|
||||
}
|
||||
|
||||
private void PaintDragging(BaseEventData data)
|
||||
{
|
||||
if (_enabled && _haveRegion)
|
||||
@ -698,53 +692,6 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
bool isRect = false;
|
||||
private void OnGUI()
|
||||
{
|
||||
if (isRect)
|
||||
{
|
||||
var points = GenerateRectanglePoints(_lastPoint, Input.mousePosition);
|
||||
|
||||
|
||||
float minX = float.MaxValue;
|
||||
float minY = float.MaxValue;
|
||||
float maxX = float.MinValue;
|
||||
float maxY = float.MinValue;
|
||||
|
||||
// 找出最小和最大的 x、y 坐标
|
||||
foreach (Vector2 point in points)
|
||||
{
|
||||
if (point.x < minX)
|
||||
{
|
||||
minX = point.x;
|
||||
}
|
||||
if (point.x > maxX)
|
||||
{
|
||||
maxX = point.x;
|
||||
}
|
||||
if (point.y < minY)
|
||||
{
|
||||
minY = point.y;
|
||||
}
|
||||
if (point.y > maxY)
|
||||
{
|
||||
maxY = point.y;
|
||||
}
|
||||
}
|
||||
|
||||
float x = minX;
|
||||
float y = maxY;
|
||||
float width = maxX - minX;
|
||||
float height = maxY - minY;
|
||||
|
||||
Rect rect = new Rect(x, y, width, height);
|
||||
|
||||
GUI.backgroundColor = Color.blue;
|
||||
GUI.color = Color.yellow;
|
||||
GUI.Box(rect, "我帮你绘制了个 Rect Box");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPaintEndDrag(BaseEventData data)
|
||||
{
|
||||
if (_enabled && _haveRegion)
|
||||
@ -796,6 +743,69 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FinishedRaw()
|
||||
{
|
||||
if (_currentLine != null)
|
||||
{
|
||||
// 保存当前纹理到 LineSegment
|
||||
RenderTexture.active = _currentLine.Texture;
|
||||
Graphics.Blit(_currentRenderTexture, _currentLine.Texture);
|
||||
RenderTexture.active = null;
|
||||
|
||||
_lineStack.Push(_currentLine);
|
||||
_currentLine = null;
|
||||
}
|
||||
|
||||
_lastPoint = Vector2.zero;
|
||||
|
||||
}
|
||||
bool isRect = false;
|
||||
private void OnGUI()
|
||||
{
|
||||
if (isRect)
|
||||
{
|
||||
var points = GenerateRectanglePoints(_lastPoint, Input.mousePosition);
|
||||
|
||||
|
||||
float minX = float.MaxValue;
|
||||
float minY = float.MaxValue;
|
||||
float maxX = float.MinValue;
|
||||
float maxY = float.MinValue;
|
||||
|
||||
// 找出最小和最大的 x、y 坐标
|
||||
foreach (Vector2 point in points)
|
||||
{
|
||||
if (point.x < minX)
|
||||
{
|
||||
minX = point.x;
|
||||
}
|
||||
if (point.x > maxX)
|
||||
{
|
||||
maxX = point.x;
|
||||
}
|
||||
if (point.y < minY)
|
||||
{
|
||||
minY = point.y;
|
||||
}
|
||||
if (point.y > maxY)
|
||||
{
|
||||
maxY = point.y;
|
||||
}
|
||||
}
|
||||
|
||||
float x = minX;
|
||||
float y = maxY;
|
||||
float width = maxX - minX;
|
||||
float height = maxY - minY;
|
||||
|
||||
Rect rect = new Rect(x, y, width, height);
|
||||
|
||||
GUI.backgroundColor = Color.blue;
|
||||
GUI.color = Color.yellow;
|
||||
GUI.Box(rect, "我帮你绘制了个 Rect Box");
|
||||
}
|
||||
}
|
||||
|
||||
List<Vector2> GenerateCirclePoints(Vector2 center, float r, int numPoints = 36)
|
||||
{
|
||||
List<Vector2> points = new List<Vector2>();
|
||||
@ -868,25 +878,18 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
public void FinishedRaw()
|
||||
public void Clear()
|
||||
{
|
||||
if (_currentLine != null)
|
||||
{
|
||||
// 保存当前纹理到 LineSegment
|
||||
RenderTexture.active = _currentLine.Texture;
|
||||
Graphics.Blit(_currentRenderTexture, _currentLine.Texture);
|
||||
RenderTexture.active = null;
|
||||
// 重新分配 RenderTexture
|
||||
_currentRenderTexture = RenderTexture.GetTemporary(_screenWidth, _screenHeight, 24);
|
||||
|
||||
_lineStack.Push(_currentLine);
|
||||
_paintCanvasImg.texture = _currentLine.Texture;
|
||||
_currentLine = null;
|
||||
}
|
||||
|
||||
_lastPoint = Vector2.zero;
|
||||
// 更新画布的纹理
|
||||
_paintCanvasImg.texture = _currentRenderTexture;
|
||||
|
||||
// 清空线条栈
|
||||
_lineStack.Clear();
|
||||
}
|
||||
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
if (_lineStack.Count > 0)
|
||||
@ -898,10 +901,13 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
if (_lineStack.Count > 0)
|
||||
{
|
||||
var previousLine = _lineStack.Peek();
|
||||
RenderTexture.active = _currentRenderTexture;
|
||||
Graphics.Blit(previousLine.Texture, _currentRenderTexture);
|
||||
RenderTexture.active = null;
|
||||
//RenderTexture.active = _currentRenderTexture;
|
||||
//Graphics.Blit(previousLine.Texture, _currentRenderTexture);
|
||||
//RenderTexture.active = null;
|
||||
_currentRenderTexture = previousLine.Texture;
|
||||
_paintCanvasImg.texture = previousLine.Texture;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -909,17 +915,7 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
// 重新分配 RenderTexture
|
||||
_currentRenderTexture = RenderTexture.GetTemporary(_screenWidth, _screenHeight, 24);
|
||||
|
||||
// 更新画布的纹理
|
||||
_paintCanvasImg.texture = _currentRenderTexture;
|
||||
|
||||
// 清空线条栈
|
||||
_lineStack.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// 绘画进行插值
|
||||
/// </summary>
|
||||
@ -967,7 +963,6 @@ public class ScreenShotPainter : MonoBehaviour
|
||||
material = _paintBrushMat;
|
||||
}
|
||||
|
||||
|
||||
_commandBuffer.Blit(_currentRenderTexture, _currentRenderTexture, material);
|
||||
|
||||
Graphics.ExecuteCommandBuffer(_commandBuffer);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user