void OnGUIImage() { DrawMainTex(); info.mousePos = mousePos; foreach (var item in showOps) { ops[item].OnGUITool(info, item == op); } if (SWCommon.GetMouseDown(0) && InMap()) { op = SWEffectWindowOp.none; List <SWEffectWindowOp> _opsIsPressed = new List <SWEffectWindowOp> (); foreach (var item in showOps) { if (ops[item] is OpTool_angle) { OpTool_angle en = (OpTool_angle)ops[item]; float dis = Vector2.Distance(info.mousePos, info.imageRect.center); float checkRange = Mathf.Max(en.roundRad * 0.02f, 1); if (Mathf.Abs(dis - en.roundRad) < checkRange) { op = item; RepaintGetDirty(); } continue; } if (ops[item].rect.Contains(info.mousePosRotated)) { _opsIsPressed.Add(item); } } //use other tool rather then angle ring, while overlap if (_opsIsPressed.Count == 1) { op = _opsIsPressed [0]; RepaintGetDirty(); } else if (_opsIsPressed.Count > 1) { foreach (var oopp in _opsIsPressed) { if (oopp == SWEffectWindowOp.angle) { continue; } op = oopp; RepaintGetDirty(); break; } } info.mousePosRotatedLast = info.mousePosRotated; info.mousePosLast = info.mousePos; } if (SWCommon.GetMouse(0)) { if (ops.ContainsKey(op)) { info.movement = mousePos; ops [op].UI2Data(info); if (ops [op].repaintDirty) { ops [op].repaintDirty = false; RepaintGetDirty(); } } info.mousePosRotatedLast = info.mousePosRotated; info.mousePosLast = info.mousePos; } else { } if (SWCommon.GetMouseUp(0)) { op = SWEffectWindowOp.none; info.mousePosRotatedLast = info.mousePosRotated; RepaintGetDirty(); } }
void OnGUIImage() { info.mousePos = mousePos; //Half of the extra grids int exHalf = 5; float widthAbs = Mathf.Abs(info.imageRect.width); float heightAbs = Mathf.Abs(info.imageRect.height); float widthSign = Mathf.Sign(info.imageRect.width); float heightSign = Mathf.Sign(info.imageRect.height); Graphics.DrawTexture(new Rect( info.imageRect.x - exHalf * widthAbs, info.imageRect.y - exHalf * heightAbs, (1 + exHalf * 2) * widthAbs, (1 + exHalf * 2) * heightAbs), info.effector.texture, new Rect(-exHalf * widthSign, -exHalf * heightSign, (1 + exHalf * 2) * widthSign, (1 + exHalf * 2) * heightSign), 0, 0, 0, 0, MainTexMat); foreach (var item in showOps) { ops[item].OnGUITool(info, item == op); } if (SWCommon.GetMouseDown(0) && al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY))) { op = SWEffectWindowOp.none; List <SWEffectWindowOp> _opsIsPressed = new List <SWEffectWindowOp> (); foreach (var item in showOps) { if (ops[item] is OpTool_angle) { OpTool_angle en = (OpTool_angle)ops[item]; float dis = Vector2.Distance(info.mousePos, info.imageRect.center); float checkRange = Mathf.Max(en.roundRad * 0.02f, 1); if (Mathf.Abs(dis - en.roundRad) < checkRange) { op = item; } continue; } if (ops[item].rect.Contains(info.mousePosRotated)) { _opsIsPressed.Add(item); } } //use other tool rather then angle ring, while overlap if (_opsIsPressed.Count == 1) { op = _opsIsPressed [0]; } else if (_opsIsPressed.Count > 1) { foreach (var oopp in _opsIsPressed) { if (oopp == SWEffectWindowOp.angle) { continue; } op = oopp; break; } } info.mousePosRotatedLast = info.mousePosRotated; info.mousePosLast = info.mousePos; } if (SWCommon.GetMouse(0)) { if (ops.ContainsKey(op)) { info.movement = mousePos; ops [op].UI2Data(info); } info.mousePosRotatedLast = info.mousePosRotated; info.mousePosLast = info.mousePos; } else { } if (SWCommon.GetMouseUp(0)) { op = SWEffectWindowOp.none; info.mousePosRotatedLast = info.mousePosRotated; } }