98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using XED.Asset;
|
|
using XED.Util;
|
|
using WI.UI;
|
|
|
|
namespace XED.UI
|
|
{
|
|
public class Panel_ObjectAlign : PanelBase
|
|
{
|
|
public TMP_InputField InputField_GapX;
|
|
public TMP_InputField InputField_GapZ;
|
|
public TMP_InputField InputField_Row;
|
|
public TMP_InputField InputField_Col;
|
|
public Button Button_AlignXAxis;
|
|
public Button Button_AlignZAxis;
|
|
public Button Button_AlignGrid;
|
|
|
|
private RenderObjectHandler renderObjectHandler;
|
|
private float gapX = 0.0f;
|
|
private float gapZ = 0.0f;
|
|
private int row = 0;
|
|
private int col = 0;
|
|
private int direction = 0;
|
|
public override void AfterAwake()
|
|
{
|
|
CustomAssetConnector assetConnector = FindSingle<CustomAssetConnector>();
|
|
renderObjectHandler = assetConnector.renderObjectHandler;
|
|
InputField_GapX.onValueChanged.AddListener(OnGapXChanged);
|
|
InputField_GapZ.onValueChanged.AddListener(OnGapZChanged);
|
|
InputField_Row.onValueChanged.AddListener(OnRowChanged);
|
|
InputField_Col.onValueChanged.AddListener(OnColChanged);
|
|
Button_AlignXAxis.onClick.AddListener(OnAlignXAxis);
|
|
Button_AlignZAxis.onClick.AddListener(OnAlignZAxis);
|
|
Button_AlignGrid.onClick.AddListener(OnAlignGrid);
|
|
}
|
|
void OnGapXChanged(string input)
|
|
{
|
|
if (!float.TryParse(input, out gapX))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
void OnGapZChanged(string input)
|
|
{
|
|
if (!float.TryParse(input, out gapZ))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
void OnRowChanged(string input)
|
|
{
|
|
if (!int.TryParse(input, out row))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
void OnColChanged(string input)
|
|
{
|
|
if (!int.TryParse(input, out col))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
void OnAlignXAxis()
|
|
{
|
|
if (direction < 4)
|
|
{
|
|
direction = 4;
|
|
}
|
|
else if (direction > 4)
|
|
{
|
|
direction = 0;
|
|
}
|
|
renderObjectHandler.AlignObjects(0, 0, gapX, gapZ, direction);
|
|
direction++;
|
|
}
|
|
void OnAlignZAxis()
|
|
{
|
|
if (direction < 5)
|
|
{
|
|
direction = 5;
|
|
}
|
|
else if (direction > 5)
|
|
{
|
|
direction = 1;
|
|
}
|
|
renderObjectHandler.AlignObjects(0, 0, gapX, gapZ, direction);
|
|
direction++;
|
|
}
|
|
void OnAlignGrid()
|
|
{
|
|
renderObjectHandler.AlignObjects(row, col, gapX, gapZ, direction);
|
|
direction++;
|
|
}
|
|
}
|
|
} |