|
|
@ -48,8 +48,28 @@ public class GameUI : MonoBehaviour { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PreparePlayerPanels() { |
|
|
|
private void PreparePlayerPanels() { |
|
|
|
float heightPercentage = Dimensions.Singleton.panelHeightPercentage; |
|
|
|
float heightPercentage = Dimensions.Singleton.panelHeightPercentage; |
|
|
|
PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = Length.Percent(heightPercentage); |
|
|
|
PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = Length.Percent(heightPercentage); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetupButtons(Side.Top); |
|
|
|
|
|
|
|
SetupButtons(Side.Bottom); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public delegate void ButtonDown(Side side, string direction); |
|
|
|
|
|
|
|
public delegate void ButtonUp(Side side, string direction); |
|
|
|
|
|
|
|
public ButtonDown buttonDown; |
|
|
|
|
|
|
|
public ButtonUp buttonUp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SetupButtons(Side side) { |
|
|
|
|
|
|
|
Button btnLeft = PlayerPanel(side).Q<Button>("btn_left"); |
|
|
|
|
|
|
|
btnLeft.clickable.activators.Clear(); |
|
|
|
|
|
|
|
btnLeft.RegisterCallback<MouseDownEvent>(_ => buttonDown(side, "left")); |
|
|
|
|
|
|
|
btnLeft.RegisterCallback<MouseUpEvent>(_ => buttonUp(side, "left")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Button btnRight = PlayerPanel(side).Q<Button>("btn_right"); |
|
|
|
|
|
|
|
btnRight.clickable.activators.Clear(); |
|
|
|
|
|
|
|
btnRight.RegisterCallback<MouseDownEvent>(_ => buttonDown(side, "right")); |
|
|
|
|
|
|
|
btnRight.RegisterCallback<MouseUpEvent>(_ => buttonUp(side, "right")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|