GameObject build_more_flyout() { GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu")); popupGO.SetName("MoreSceneMenu"); CCUIBuilder.AddBasicToolButton(popupGO, "New Scene", on_clear_scene_clicked); Canvas.AddChild(popupGO, false); // [RMS] I have no idea what is going on here...but this does work RectTransform targetRect = moreButton.gameObject.GetComponent <RectTransform>(); AxisAlignedBox2f targetBox = targetRect.rect; Vector2f targetPoint = BoxModel.GetBoxPosition(ref targetBox, BoxPosition.TopRight); Vector3f targetW = moreButton.gameObject.transform.TransformPoint(targetPoint.x, targetPoint.y, 0); //RectTransform popupRect = popupGO.GetComponent<RectTransform>(); //AxisAlignedBox2f popupBox = popupRect.rect; //Vector2f popupCorner = BoxModel.GetBoxPosition(ref popupBox, BoxPosition.TopLeft); //Vector3f popupW = popupGO.transform.TransformPoint(popupCorner.x, popupCorner.y, 0); //Vector2f popupCenter = BoxModel.GetBoxPosition(ref popupBox, BoxPosition.Center); //Vector3f popupC = popupGO.transform.TransformPoint(popupCenter.x, popupCenter.y, 0); //Vector3f dl = popupW - popupC; //Vector3f dx = popupW - targetW; Vector3f shift = new Vector3f(5, 5, 0); popupGO.transform.position = targetW + shift; return(popupGO); }
GameObject build_objects_popup() { GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu")); popupGO.SetName("ObjectsTools"); CCUIBuilder.AddBasicStartToolButton(popupGO, "Add Shape", GenerateShapeTool.Identifier); CCUIBuilder.AddBasicToolButton(popupGO, "Resize", set_size_clicked); CCUIBuilder.AddBasicToolButton(popupGO, "Duplicate", on_duplicate_clicked, any_so_selected); CCUIBuilder.AddBasicToolButton(popupGO, "Delete", on_delete_clicked, any_so_selected); CCUIBuilder.AddBasicStartToolButton(popupGO, "Separate", SeparateSolidsTool.Identifier); CCUIBuilder.AddBasicStartToolButton(popupGO, "Combine", CombineMeshesTool.Identifier, multi_selection_or_multi_obj); Canvas.AddChild(popupGO, false); UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero); return(popupGO); }
GameObject build_position_popup() { GameObject popupGO = GameObject.Instantiate(Resources.Load <GameObject>("BasicToolMenu")); popupGO.SetName("PositionTools"); CCUIBuilder.AddBasicToolButton(popupGO, "On Bed", on_bed_clicked); CCUIBuilder.AddBasicToolButton(popupGO, "Center", center_clicked); CCUIBuilder.AddBasicToolButton(popupGO, "Swap Y/Z Up", swap_up_clicked); CCUIBuilder.AddBasicToolButton(popupGO, "Mirror", mirror_clicked); CCUIBuilder.AddBasicToolButton(popupGO, "Reset Pivot", reset_pivot_clicked); CCUIBuilder.AddBasicToolButton(popupGO, "Set Base", set_base_clicked, single_so_selected); Canvas.AddChild(popupGO, false); UnityUIUtil.PositionRelative2D(popupGO, BoxPosition.TopLeft, Panel, BoxPosition.TopRight, Vector2f.Zero); return(popupGO); }