Skip to content

Commit

Permalink
Add horizontal and vertical tile count settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mminer committed May 19, 2021
1 parent baece27 commit 2c78d02
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Editor/BigCameraInputSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ public string CameraTag

[SerializeField] string cameraTag = "MainCamera";

public int HorizontalTileCount
{
get => horizontalTileCount;
set => horizontalTileCount = value;
}

[SerializeField] int horizontalTileCount = 2;

public override int OutputHeight
{
get => outputHeight;
Expand All @@ -34,10 +42,36 @@ public override int OutputWidth

[SerializeField] int outputWidth = 8096;

public int VerticalTileCount
{
get => verticalTileCount;
set => verticalTileCount = value;
}

[SerializeField] int verticalTileCount= 2;

protected override bool ValidityCheck(List<string> errors)
{
var ok = true;

if (HorizontalTileCount < 1 || VerticalTileCount < 1)
{
errors.Add($"Need a minimum of 1 horizontal and vertical tile.");
ok = false;
}

if (OutputWidth % HorizontalTileCount != 0)
{
errors.Add($"Output width must be a multiple of the horizontal tile count.");
ok = false;
}

if (OutputHeight % VerticalTileCount != 0)
{
errors.Add($"Output height must be a multiple of the vertical tile count.");
ok = false;
}

if (OutputWidth <= 0 || OutputHeight <= 0)
{
errors.Add($"Invalid output resolution: {OutputWidth}x{OutputHeight}");
Expand Down
8 changes: 8 additions & 0 deletions Editor/BigCameraInputSettingsPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var cameraTag = property.FindPropertyRelative("cameraTag");
var horizontalTileCount = property.FindPropertyRelative("horizontalTileCount");
var outputHeight = property.FindPropertyRelative("outputHeight");
var outputWidth = property.FindPropertyRelative("outputWidth");
var verticalTileCount = property.FindPropertyRelative("verticalTileCount");

var tileWidth = outputWidth.intValue / horizontalTileCount.intValue;
var tileHeight = outputHeight.intValue / verticalTileCount.intValue;

using (new EditorGUI.IndentLevelScope(-1))
{
EditorGUILayout.PropertyField(cameraTag);
EditorGUILayout.PropertyField(outputWidth);
EditorGUILayout.PropertyField(outputHeight);
EditorGUILayout.PropertyField(horizontalTileCount);
EditorGUILayout.PropertyField(verticalTileCount);
EditorGUILayout.LabelField("Tile Size", $"{tileWidth} × {tileHeight}");
}
}
}
Expand Down

0 comments on commit 2c78d02

Please sign in to comment.