LocalToGlobal() public method

public LocalToGlobal ( Rect rect ) : Rect
rect UnityEngine.Rect
return UnityEngine.Rect
示例#1
0
    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);
    }
示例#2
0
        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)));
        }
示例#3
0
        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));
        }