public void StartDrag(GObject source, string icon, object sourceData, int touchPointID = -1) { if (_agent.parent != null) return; _sourceData = sourceData; _agent.url = icon; GRoot.inst.AddChild(_agent); Vector2 pt = source.LocalToGlobal(new Vector2(0, 0)); _agent.SetXY(pt.x, pt.y); _agent.StartDrag(null, touchPointID); }
public Vector2 GetPoupPosition(GObject popup, GObject target, object downward) { Vector2 pos; float sizeW = 0; float sizeH = 0; if (target != null) { pos = target.LocalToGlobal(new Vector2(0, 0)); sizeW = target.width; sizeH = target.height; } else { pos = new Vector2(Stage.mouseX / contentScaleFactor, Stage.mouseY / contentScaleFactor); } float xx, yy; xx = pos.x; if (xx + popup.width > this.width) { xx = xx + sizeW - popup.width; } yy = pos.y + sizeH; if ((downward == null && yy + popup.height > this.height) || downward != null && (bool)downward == false) { yy = pos.y - popup.height - 1; if (yy < 0) { yy = 0; xx += sizeW / 2; } } return(new Vector2(Mathf.RoundToInt(xx), Mathf.RoundToInt(yy))); }
public Vector2 GetPoupPosition(GObject popup, GObject target, object downward) { Vector2 pos; float sizeW = 0; float sizeH = 0; if (target != null) { pos = target.LocalToGlobal(new Vector2(0, 0)); sizeW = target.width; sizeH = target.height; } else { pos = new Vector2(Stage.mouseX / contentScaleFactor, Stage.mouseY / contentScaleFactor); } float xx, yy; xx = pos.x; if (xx + popup.width > this.width) xx = xx + sizeW - popup.width; yy = pos.y + sizeH; if ((downward == null && yy + popup.height > this.height) || downward != null && (bool)downward == false) { yy = pos.y - popup.height - 1; if (yy < 0) { yy = 0; xx += sizeW / 2; } } return new Vector2(Mathf.RoundToInt(xx), Mathf.RoundToInt(yy)); }