//TODO 目前这块的添加是完全混轮的,后期需要重点设计 //以左上角为锚点,添加到组件中 public virtual void AddComponent(ERect rect, float pos_x, float pos_y) { pos_x = pos_x + rect.Ew / 2; pos_y = pos_y + rect.Eh / 2; rect.ResetPosition(pos_x, pos_y); _internal_add_chile(rect); }
public virtual void AddItem(ERect rect) { float x = _size.x / 2; _cur_height += _cur_height + rect.Eh / 2 + height_interval; rect.ResetPosition(x, _cur_height); _internal_add_chile(rect); }
public virtual void AddItem(ERect rect) { float x = rect.Ew / 2 + offset_x; _cur_height = (_view_height + rect.Eh / 2); rect.ResetPosition(x, _cur_height); _internal_add_chile(rect); _view_height = (_cur_height + rect.Eh / 2 + height_interval); }
public ERect AddComponentDown(ERect rect, ERect rect_a, float r_heigth = 5) { float pos_x = rect_a.Ex - rect_a.Ew / 2 + rect.Ew / 2; float pos_y = rect_a.Ey + rect_a.Eh / 2 + r_heigth + rect.Eh / 2; rect.ResetPosition(pos_x, pos_y); _internal_add_chile(rect); return(rect); }
// rect 在rect_a的右边 public virtual ERect AddComponentRight(ERect rect, ERect rect_a, float r_width = 5) { float pos_x = rect_a.Ex + rect_a.Ew / 2 + r_width + rect.Ew / 2; //float pos_y = rect_a.Ey + (rect_a.Eh - rect.Eh) / 2; float pos_y = rect_a.Ey - rect_a.Eh / 2 + rect.Eh / 2; rect.ResetPosition(pos_x, pos_y); _internal_add_chile(rect); return(rect); }
//添加 带锚点 public virtual void AddComponent(ERect rect, E_Anchor anchor) { // TODO bug 没有fixed float pos_x = rect.Ex; float pos_y = rect.Ey; E_Anchor e = (anchor & E_Anchor.Left); if ((anchor & E_Anchor.Left) == E_Anchor.Left) { pos_x = rect.Ew / 2; } else if ((anchor & E_Anchor.Right) == E_Anchor.Right) { pos_x = _size.x - pos_x - rect.Ew / 2; } /*else if ((anchor & E_Anchor.center) == E_Anchor.center) * { * pos_x = _size.x / 2 + pos_x; * }*/ /* if ((anchor & E_Anchor.center) == E_Anchor.center) * { * pos_y = _size.y / 2 + pos_y; * } * else */ if ((anchor & E_Anchor.UP) == E_Anchor.UP) { pos_y = pos_y + rect.Eh / 2; } else if ((anchor & E_Anchor.DOWN) == E_Anchor.DOWN) { pos_y = _size.y + pos_y - rect.Eh / 2; } if ((anchor & E_Anchor.DOWN_CENTER) == E_Anchor.DOWN_CENTER) { pos_x = (_size.x / 2) - (rect.Ew / 2); pos_y = _size.y + pos_y - rect.Eh / 2; } rect.ResetPosition(pos_x, pos_y); _internal_add_chile(rect); }