chip-gameV3/Assets/Scripts/Menu/MenuLayoutController.cs
sega f32d7dd69b Как вот это вот описать...
Было очень много экстренных ситуаций.
И по мне стреляли, и я упал в лужу нахуй блять, и лежал нахуй
2026-07-29 15:05:01 +03:00

43 lines
1.0 KiB
C#

using System.Collections.Generic;
using UnityEngine;
public class MenuLayoutController : MonoBehaviour
{
[SerializeField] List<MenuPanel> panels;
int panelIndex = 0;
private void Start()
{
foreach (var panel in panels)
{
panel.Disable(0);
}
panels[panelIndex].Enable(0, 0);
}
private void Update()
{
int direction = GetDirection();
int newPanelIndex = Mathf.Clamp(panelIndex + direction, 0, 2);
bool indexChanged = newPanelIndex != panelIndex;
if (indexChanged)
{
var currentPanel = panels[panelIndex];
var nextPanel = panels[newPanelIndex];
currentPanel.Disable(0);
nextPanel.Enable(0, 0);
panelIndex = newPanelIndex;
}
}
private static int GetDirection()
{
int dir_h = 0;
dir_h += In.GetButtonDownAnyPlayer(PlayerAction.right) ? 1 : 0;
dir_h += In.GetButtonDownAnyPlayer(PlayerAction.left) ? -1 : 0;
return dir_h;
}
}