public override void AfterLoad() { base.AfterLoad(); if (GetChildTexture() != null) { texChildOrigin = GetChildTexture(); texChildResized = SWTextureProcess.TextureResize(texChildOrigin, data.resolution, data.resolution); } if (textureEx != null) { if (data.resolution != textureEx.width) { data.reso = (SWTexResolution)SWDataNode.resoList.IndexOf(textureEx.width); } } if (data.rd != null && data.rd.l != null && data.rd.l.pts != null) { for (int i = 0; i < data.rd.l.pts.Count; i++) { var pData = data.rd.l.pts [i]; RemapWayPoint pt = new RemapWayPoint(); pt.uv = pData.uv; pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS")); lineInfo.pts.Add(pt); } } }
void UpdateRemapWayPoint(RemapWayPoint pt, Vector2 mPos) { Vector2 m = mPos - drawRect.position; //lsy : new remap ratio var uv = SWTextureProcess.TexUV_NoClamp(oMin, oMin, (int)m.x, (int)m.y); pt.uv = uv; pt.mousePos = mPos; }
void DrawLine() { //Add Point if (SWCommon.GetMouseDown(0) && al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY))) { if (!al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY))) { return; } if (!drawRect.Contains(mousePos)) { return; } SWUndo.Record(info); Vector2 m = Event.current.mousePosition; m = m - drawRect.position; m = SWTextureProcess.TexUV(size, size, (int)m.x, (int)m.y); RemapWayPoint pt = new RemapWayPoint(); pt.uv = m; pt.mousePos = mousePos; pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS")); info.pts.Add(pt); } DrawPoints(); //Draw Cursor if (focusedWindow == this) { if (al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)) && drawRect.Contains(mousePos)) { GUI.DrawTexture(new Rect(mousePos.x - brushSize * 1f, mousePos.y - brushSize * 1f, brushSize * 2f, brushSize * 2f), SWEditorUI.Texture(SWUITex.cursor)); GUI.DrawTexture(new Rect(mousePos.x - 8, mousePos.y - 8, 16, 16), SWEditorUI.Texture(SWUITex.cursorCenter)); Cursor.visible = false; } else { Cursor.visible = true; } } //Key Command if (Event.current.type == EventType.keyDown) { if (Event.current.keyCode == KeyCode.Return) { node.data.dirty = true; SWTextureProcess.ProcessRemap_Line(node.textureEx, info, brushSizeUV); } } }
void LineEditUpdate() { if (!InMap()) { return; } if (!al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY))) { return; } if (!drawRect.Contains(mousePos)) { return; } RemapWayPoint cp = CloestPt(mousePos); if (SWCommon.GetMouseDown(0)) { editingPoint = cp; } if (SWCommon.GetMouse(0)) { if (editingPoint != null) { SWUndo.Record(node.lineInfo); UpdateRemapWayPoint(editingPoint, Event.current.mousePosition); } } if (SWCommon.GetMouseUp(0)) { if (editingPoint != null) { SWUndo.Record(node.lineInfo); UpdateRemapWayPoint(editingPoint, Event.current.mousePosition); } editingPoint = null; } if (SWCommon.GetMouseUp(1)) { if (cp != null) { SWUndo.Record(node.lineInfo); node.lineInfo.pts.Remove(cp); } } }
RemapWayPoint CloestPt(Vector2 v) { RemapWayPoint cp = null; float minDis = float.MaxValue; for (int i = 0; i < node.lineInfo.pts.Count; i++) { RemapWayPoint p = node.lineInfo.pts[i]; float dis = Vector2.Distance(v, p.mousePos); if (dis < minDis) { minDis = dis; cp = p; } } if (minDis < IconSize_Center) { return(cp); } return(null); }
void LinePlaceUpdate() { //Add Point //if (SWCommon.GetMouseDown (0) && al_rectMain.Contains(mousePosOut+new Vector2(0,al_startY))) { if (SWCommon.GetMouseDown(0) && InMap()) { if (!al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY))) { return; } if (!drawRect.Contains(mousePos)) { return; } SWUndo.Record(node.lineInfo); RemapWayPoint pt = new RemapWayPoint(); UpdateRemapWayPoint(pt, Event.current.mousePosition); pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS")); node.lineInfo.pts.Add(pt); } }