public void KeyCommands() { mousePos = Event.current.mousePosition; if (Event.current.type == EventType.keyDown) { KeyCmd_HotkeyDown(Event.current.keyCode); if (Event.current.keyCode == KeyCode.Delete || Event.current.keyCode == KeyCode.Backspace) { KeyCmd_Delete(); } } if (Event.current.type == EventType.keyUp) { KeyCmd_HotkeyUp(Event.current.keyCode); KeyCmd_CopyPaste(); } if (Event.current.alt) { if (Event.current.type == EventType.ScrollWheel) { KeyCmd_Scroll(Event.current.delta); } //1 drag map else if (SWCommon.GetMouse(0)) { Vector2 move = Event.current.mousePosition - mousePosLast; KeyCmd_Dragmove(move); } } else { KeyCmd_Select(); } if (SWCommon.GetMouseDown(0)) { mousePosDown = Event.current.mousePosition; mousePosLast = Event.current.mousePosition; mousePressing = true; } if (SWCommon.GetMouse(0)) { mousePosLast = Event.current.mousePosition; } if (SWCommon.GetMouseUp(0)) { mousePressing = false; } }
protected override void DrawLeftRect(int id, Rect rect) { UpdatePort(); rect = new Rect(rect.x, rect.y, rect.width, rect.height); SWEditorTools.DrawTiledTexture(rect, SWEditorTools.backdropTexture); GUI.DrawTexture(rect, data.gradients[id].Tex); if (SWCommon.GetMouseUp(1) && rect.Contains(Event.current.mousePosition)) { SWWindowMixerEditor.Show(data.gradients [id]); } }
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); } } }
public override void DrawRight() { GUILayout.BeginHorizontal(); GUILayout.Space(position.width - rightupWidth - al_scrollBarWidth * 1.8f + SWGlobalSettings.UIGap); GUILayout.BeginVertical(); if (!showRight) { Rect rect = new Rect(position.width - 50 - al_scrollBarWidth * 1f, position.height - 50 - al_scrollBarWidth, 50, 50); GUI.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectRight1)); if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown) { showRight = true; } } else { Rect rect = new Rect(position.width - rightupWidth - 50 - al_scrollBarWidth * 1.8f, position.height - 50 - al_scrollBarWidth, 50, 50); GUI.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectRight2)); if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown) { showRight = false; } DrawRightUp(); } GUILayout.EndVertical(); var mapLeftRect = showRight ? new Rect(al_rectMain.x, al_rectMain.y, al_rectMain.width - rightUpRect.width, al_rectMain.height) : new Rect(al_rectMain.x, al_rectMain.y, al_rectMain.width, al_rectMain.height); if (SWCommon.GetMouseUp(1, mapLeftRect)) { brightBackground = !brightBackground; } }
void DrawMain() { if (SWCommon.GetMouseUp(1) && InMap()) { float dis = Vector2.Distance(mousePosDown, mousePos); if (dis < 1f) { brightBackground = !brightBackground; } } OpsInit(); // if(BottomTexture()!=null) // GUI.DrawTexture (info.baseRect, BottomTexture(), ScaleMode.StretchToFill); ShowBG_Textures(); var p = new Vector3(al_rectMainZoom.x + info.imageRect.center.x, al_rectMainZoom.y + info.imageRect.center.y, 0); matrixSpinBefore = GUI.matrix; Matrix4x4 tt = Matrix4x4.TRS(p, Quaternion.identity, Vector3.one); Matrix4x4 rr = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, info.angle), Vector3.one); matrixSpinAfter = GUI.matrix * tt * rr * tt.inverse; GUI.matrix = matrixSpinAfter; info.mousePosRotated = Event.current.mousePosition; // Debug.Log ("mousePosition: "+Event.current.mousePosition); OnGUIImage(); GUI.matrix = matrixSpinBefore; DrawFrame(info.baseRect); Set_Material(OtherTexMat); Set_Material(MainTexMat); Set_MaterialLoop(MainTexMat, data); Set_MaterialTextureSheet(MainTexMat, info.effector); }
void OnGUI() { baseRect = new Rect(Gap, Gap, position.width - Gap * 2, 20); texRect = new Rect(Gap, baseRect.yMax, position.width - Gap * 2, 50); timeRect = new Rect(Gap, texRect.yMax + Gap, position.width - Gap * 2, 20); valueRect = new Rect(Gap, timeRect.yMax, position.width - Gap * 2, 20); if (SWCommon.GetMouseDown(1)) { if (!baseRect.Contains(Event.current.mousePosition)) { mode = SWGradientMode.no; opItem = null; } } if (SWCommon.GetMouseDown(0)) { bool doit = false; if (mode == SWGradientMode.no) { for (int i = 0; i < gradient.frames.Count; i++) { var item = gradient.frames [i]; Rect rect = CalRect(item); if (rect.Contains(Event.current.mousePosition)) { doit = true; mode = SWGradientMode.select; opItem = item; } } } else if (mode == SWGradientMode.select) { for (int i = 0; i < gradient.frames.Count; i++) { var item = gradient.frames [i]; Rect rect = CalRect(item); if (rect.Contains(Event.current.mousePosition)) { doit = true; opItem = item; if (opItem == item) { mode = SWGradientMode.move; } } } } else if (mode == SWGradientMode.move) { doit = true; opItem.time = TimeOnPos(); } if (!doit) { if (baseRect.Contains(Event.current.mousePosition)) { var item = new SWGradientFrame(); item.time = TimeOnPos(); gradient.frames.Add(item); mode = SWGradientMode.select; opItem = item; } } } if (SWCommon.GetMouse(0)) { if (mode == SWGradientMode.no) { } else if (mode == SWGradientMode.select) { } else if (mode == SWGradientMode.move) { opItem.time = TimeOnPos(); } } if (SWCommon.GetMouseUp(0)) { if (mode == SWGradientMode.no) { } else if (mode == SWGradientMode.select) { } else if (mode == SWGradientMode.move) { mode = SWGradientMode.select; } } if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.Delete) { if (mode == SWGradientMode.select && opItem != null) { gradient.frames.Remove(opItem); } } } gradient.Sort(); GUI.color = Color.black; GUI.DrawTexture(baseRect, SWEditorTools.blankTexture); GUI.color = Color.white; SWEditorTools.DrawTiledTexture(texRect, SWEditorTools.backdropTexture); GUI.DrawTexture(texRect, gradient.Tex); bool uppperEvent = false; for (int i = 0; i < gradient.frames.Count; i++) { var item = gradient.frames [i]; Rect rect = CalRect(item); GUI.DrawTexture(rect, icon); if (opItem == item) { GUI.DrawTexture(rect, iconSelect); } } if (opItem != null) { opItem.time = EditorGUI.Slider(timeRect, "Position:", opItem.time, 0, 1); opItem.value = EditorGUI.Slider(valueRect, "Value:", opItem.value, 0, 1); } }
void DrawDir() { Cursor.visible = true; var rect = SWCommon.GetRect(drawRect.center + ArrowOff, new Vector2(IconSize_Arrow, IconSize_Arrow)); Set_Material(matBase, Vector2.zero, 0, Vector2.one); matBase.SetColor("_Color", dragging ? Color.green:Color.white); Graphics.DrawTexture(SWCommon.GetRect(drawRect.center, new Vector2(8, 8)), SWEditorUI.Texture(SWUITex.effectCenter), matBase); matBase.SetFloat("r", -SWCommon.Vector2Angle(ArrowOff)); Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectArrow), matBase); matBase.SetFloat("r", 0f); matBase.SetTexture("_MainTex", SWEditorUI.Texture(SWUITex.effectLine)); SWDraw.DrawLine(drawRect.center, rect.center, Color.white, 3f, matBase); float factor = 1f / drawRect.size.x; if (SWCommon.GetMouseDown(0) && InMap()) { RepaintGetDirty(); if (rect.Contains(Event.current.mousePosition)) { dragging = true; lastMousePos = Event.current.mousePosition; } else { dragging = false; } } else if (dragging) { if (SWCommon.GetMouse(0) && InMap()) { RepaintGetDirty(); ArrowOff += Event.current.mousePosition - lastMousePos; if (Event.current.shift) { if (Mathf.Abs(ArrowOff.x) > Mathf.Abs(ArrowOff.y)) { ArrowOff = new Vector2(ArrowOff.x, 0); } else { ArrowOff = new Vector2(0, ArrowOff.y); } } lastMousePos = Event.current.mousePosition; SWUndo.Record(this); rData.d.v = new Vector2(ArrowOff.x * factor, -ArrowOff.y * factor); } if (SWCommon.GetMouseUp(0)) { dragging = false; SWUndo.Record(this); rData.d.v = new Vector2(ArrowOff.x * factor, -ArrowOff.y * factor); } } else { ArrowOff = new Vector2(rData.d.v.x / factor, -rData.d.v.y / factor); } if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.Return) { node.data.dirty = true; SWTextureProcess.ProcessRemap_Dir(node.textureEx, node.texChildResized, new Vector2(rData.d.v.x, -rData.d.v.y), rData.d.pre, rData.d.pb); } } }
public bool InMapClick(int mouseID) { return(SWCommon.GetMouseUp(mouseID) && (Vector2.Distance(mousePosDown, Event.current.mousePosition) < 3)); }
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(); } }
public void KeyCommands() { mousePos = Event.current.mousePosition; if (Event.current.type == EventType.KeyDown) { KeyCmd_HotkeyDown(Event.current.keyCode); #if UNITY_EDITOR_WIN if (Event.current.keyCode == KeyCode.Delete) #else if (Event.current.keyCode == KeyCode.Delete || Event.current.keyCode == KeyCode.Backspace) #endif { KeyCmd_Delete(); } } if (Event.current.type == EventType.KeyUp) { KeyCmd_HotkeyUp(Event.current.keyCode); KeyCmd_CopyPaste(); } // //Depricated: do it in CalZoom // if (Event.current.alt) { // if (Event.current.type == EventType.ScrollWheel) { // KeyCmd_Scroll (Event.current.delta); // } // } if (InMap()) { if ((Event.current.alt && SWCommon.GetMouse(0)) || SWCommon.GetMouse(2)) { Vector2 move = Event.current.mousePosition - mousePosLast; KeyCmd_Dragmove(move); } if (!RMBMenu_isShowing) { if (SWCommon.GetMouseUp(1)) { RMBMenu_Start(); } } } if (!RMBMenu_isShowing && !Event.current.alt) { KeyCmd_Select(); } if (Event.current.rawType == EventType.MouseDown) { mousePosDown = Event.current.mousePosition; mousePosLast = Event.current.mousePosition; mousePressing = true; } if (Event.current.rawType == EventType.MouseDrag) { mousePosLast = Event.current.mousePosition; } if (Event.current.rawType == EventType.MouseUp) { mousePressing = false; } }
protected void RMBMenu_Show(Vector2 pos) { if (RMBMenu_List == null) { RMBMenu_List = new List <RMBItem>(); RMBMenu_Init(); } if (RMBMenu_List.Count == 0) { return; } if (!RMBMenu_isShowing) { return; } float dence = 5; float sizeX = 100; float sizeY = 20; float xOff = 10; //float yOff = 0; var rect = new Rect(pos.x, pos.y, sizeX, dence * 2 + sizeY * RMBMenu_List.Count); DrawBG(rect); bool willClean = false; bool clicked = false; if (RMBMenu_hasShow) { if (SWCommon.GetMouseUp(0) || SWCommon.GetMouseUp(1) || SWCommon.GetMouseUp(2)) { willClean = true; } } else { RMBMenu_hasShow = true; } GUI.Box(new Rect(rect.x + dence * 2, rect.y, 1, rect.height), "", SWEditorUI.Style_Get(SWCustomStyle.eLine)); for (int i = 0; i < RMBMenu_List.Count; i++) { var item = RMBMenu_List [i]; var rmbRect = new Rect( rect.position.x + xOff, dence - 1 + rect.position.y + sizeY * i, sizeX - xOff, sizeY); if (item.func_valid == null || item.func_valid()) { if (rmbRect.Contains(mousePosOut + new Vector2(0, al_startY))) { GUI.Box(new Rect(rmbRect.x, rmbRect.y, rmbRect.width, rmbRect.height), "", SWEditorUI.Style_Get(SWCustomStyle.eSelectRect)); repaintDirty = true; if (willClean) { clicked = true; if (item.act != null) { item.act(); } } } GUI.Label(rmbRect, item.name, SWEditorUI.Style_Get(SWCustomStyle.eTxtLight)); } else { GUI.Label(rmbRect, item.name, SWEditorUI.Style_Get(SWCustomStyle.eTxtLight)); } } if (willClean) { RMBMenu_isShowing = false; repaintDirty = true; if (!clicked) { RMBMenu_Clean(); } } }
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; } }