public GetPoupPosition ( |
||
popup | ||
target | ||
downward | object | |
return |
public Vector2 GetPoupPosition(GObject popup, GObject target, object downward)
{
Vector2 pos;
Vector2 size = Vector2.zero;
if (target != null)
{
pos = target.LocalToRoot(Vector2.zero, this);
size = target.LocalToRoot(target.size, this) - pos;
}
else
{
pos = this.GlobalToLocal(Stage.inst.touchPosition);
}
float xx, yy;
xx = pos.x;
if (xx + popup.width > this.width)
xx = xx + size.x - popup.width;
yy = pos.y + size.y;
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 += size.x / 2;
}
}
return new Vector2(Mathf.RoundToInt(xx), Mathf.RoundToInt(yy));
}
static int GetPoupPosition(IntPtr L) { try { ToLua.CheckArgsCount(L, 4); FairyGUI.GRoot obj = (FairyGUI.GRoot)ToLua.CheckObject(L, 1, typeof(FairyGUI.GRoot)); FairyGUI.GObject arg0 = (FairyGUI.GObject)ToLua.CheckObject(L, 2, typeof(FairyGUI.GObject)); FairyGUI.GObject arg1 = (FairyGUI.GObject)ToLua.CheckObject(L, 3, typeof(FairyGUI.GObject)); object arg2 = ToLua.ToVarObject(L, 4); UnityEngine.Vector2 o = obj.GetPoupPosition(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }