internal void EndDrag(UIDragableElement uIDragableElement) { Debug.LogWarning("End Drag..."); uIDragableElement.transform.SetParent(currentDragParent, worldPositionStays: false); uIDragableElement.transform.position = currentDragPosition; }
internal void StartDrag(UIDragableElement uIDragableElement) { currentDragParent = uIDragableElement.transform.parent; currentDragPosition = uIDragableElement.transform.position; Vector3 scale = uIDragableElement.transform.localScale; uIDragableElement.transform.SetParent(UICanvas.transform, worldPositionStays: false); uIDragableElement.transform.localScale = scale; }
public override void OnInitialize() { mainPanel = new UIDragableElement(); mainPanel.HAlign = 0.5f; mainPanel.VAlign = 0.5f; mainPanel.Width.Set(756f, 0f); mainPanel.Height.Set(323f, 0f); mainPanel.OnScrollWheel += OnScrollWheel_FixHotbarScroll; Append(mainPanel); if (offsetX != -1) { mainPanel.Left.Set(offsetX, 0f); mainPanel.Top.Set(offsetY, 0f); } var panelBackground = new UIImage(ModContent.GetTexture("SpiritMod/Items/Books/UI/MaterialUI/EnchantedLeafMaterialPage")); panelBackground.SetPadding(12); mainPanel.Append(panelBackground); mainPanel.AddDragTarget(panelBackground); Texture2D closeTexture = ModContent.GetTexture("SpiritMod/Items/Books/UI/closeButton"); UIImageButton closeButton = new UIImageButton(closeTexture); closeButton.Left.Set(-20, 1f); closeButton.Top.Set(5, 0f); closeButton.Width.Set(15, 0f); closeButton.Height.Set(15, 0f); closeButton.OnClick += CloseButton_OnClick; panelBackground.Append(closeButton); UIElement messageBoxPanel = new UIElement { Width = { Percent = 1f }, Height = { Pixels = -50, Percent = 1f }, Top = { Pixels = 50, }, }; panelBackground.Append(messageBoxPanel); mainPanel.AddDragTarget(messageBoxPanel); }