I’m trying to position my TouchButtons correctly using ContextActionService:SetPosition and it doesn’t seem to be working correctly?
ContextActionService:SetPosition("ActionName", UDim2.new(.5,0,.5,0))
I figured if I set the position to be in the center of the screen the button would be there, but the button ends up being on top of the jump button.
The position set for the button is actually relative to UDim2(0.7,0,0.5,0)
This is because the button is parented to a frame created by the ContextActionTouch CoreScript.
Here is where the frame for ContextActionService buttons is created:
end
function createContextActionGui()
if not buttonScreenGui and isTouchDevice then
buttonScreenGui = Instance.new("ScreenGui")
buttonScreenGui.Name = "ContextActionGui"
buttonFrame = Instance.new("Frame")
buttonFrame.BackgroundTransparency = 1
buttonFrame.Size = UDim2.new(0.3,0,0.5,0)
buttonFrame.Position = UDim2.new(0.7,0,0.5,0)
buttonFrame.Name = "ContextButtonFrame"
buttonFrame.Parent = buttonScreenGui
buttonFrame.Visible = not userInputService.ModalEnabled
userInputService.Changed:connect(function(property)
if property == "ModalEnabled" then
buttonFrame.Visible = not userInputService.ModalEnabled
end
end)
end
4 Likes
Thanks! Also I noticed that :UnbindAction() has a chance of not removing touchButtons if they were edited manually, if I wanted to get rid of them would I used :GetButton() and :Destroy()?
Is this the case? It sounds like something that should be fixed.
Manipulating the button means getting the button with GetButton and then doing some re-parenting or something. If you only use the ContextActionService methods to change the button then it will be removed when the action is unbound.
1 Like