Advertisement
Guest User

UIManager

a guest
Mar 25th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. UIManager = {
  2.     CurrentlyOpen = nil,   
  3. }
  4.  
  5. --Config
  6. local tweenSpeed = 0.4
  7.  
  8. function UIManager:Toggle(frame)
  9.     if UIManager.CurrentlyOpen and UIManager.CurrentlyOpen == frame then
  10.         --Close
  11.         local s = frame.AbsoluteSize
  12.         frame:TweenPosition(UDim2.new(0.5,-s.X/2,0,-s.Y-100),"Out","Quint",tweenSpeed,true)
  13.         UIManager.CurrentlyOpen = nil
  14.         return
  15.     end
  16.    
  17.     if UIManager.CurrentlyOpen then
  18.         --Close
  19.         local s = UIManager.CurrentlyOpen.AbsoluteSize
  20.         UIManager.CurrentlyOpen:TweenPosition(UDim2.new(0.5,-s.X/2,0,-s.Y-100),"Out","Quint",tweenSpeed,true)
  21.         UIManager.CurrentlyOpen = nil  
  22.     end
  23.    
  24.     if frame then
  25.         local s = frame.AbsoluteSize
  26.         frame:TweenPosition(UDim2.new(0.5,-s.X/2,0.5,-s.Y/2),"Out","Quint",tweenSpeed,true)
  27.         UIManager.CurrentlyOpen = frame
  28.     end
  29. end
  30.  
  31. return UIManager
  32.  
  33. --[[
  34.     To use:
  35.    
  36.     UIManager:Toggle(someUI) --Hides any UI currently showing, then tweens this in. If someUI is already
  37.                                open it will hide it
  38.                            
  39.     UIManager:Toggle() --Hides any UI currently open
  40. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement