52 lines
1005 B
C#
52 lines
1005 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public enum PlaneAxis
|
|
{
|
|
XZ = 0,
|
|
XY = 1,
|
|
YZ = 2
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class PlaneSelection
|
|
{
|
|
public PlaneAxis planeAxis;
|
|
public GameObject WorldGrid;
|
|
}
|
|
|
|
public class PlaneSelector : MonoBehaviour
|
|
{
|
|
public TMP_Dropdown planeAxisDropDown;
|
|
|
|
public PlaneSelection[] PlaneAxis;
|
|
|
|
private void Start()
|
|
{
|
|
planeAxisDropDown.onValueChanged.AddListener(OnPlaneAxisChanged);
|
|
UpdatePlaneVisibility();
|
|
}
|
|
|
|
private void OnPlaneAxisChanged(int index)
|
|
{
|
|
UpdatePlaneVisibility();
|
|
}
|
|
|
|
private void UpdatePlaneVisibility()
|
|
{
|
|
foreach (var plane in PlaneAxis)
|
|
{
|
|
if (plane.planeAxis == (PlaneAxis)planeAxisDropDown.value)
|
|
{
|
|
plane.WorldGrid.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
plane.WorldGrid.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|