riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
using UnityEngine;
using UnityEngine.InputSystem;
namespace DanieleMarotta.RiversongCodeShowcase
{
public class TerrainShaderDebugGUI : MonoBehaviour
{
private const int GUIRectWidth = 500;
private bool _drawGUI;
public Texture2D BlockedTilesMaskTexture { get; set; }
public Texture2D CliffsMaskTexture { get; set; }
public static TerrainShaderDebugGUI Create()
{
return new GameObject(nameof(TerrainShaderDebugGUI)).AddComponent<TerrainShaderDebugGUI>();
}
private void Update()
{
if (Keyboard.current.f1Key.wasPressedThisFrame) _drawGUI = !_drawGUI;
}
private void OnGUI()
{
if (!_drawGUI) return;
GUI.color = new Color(1, 1, 1, 0.8f);
var x = 0;
DrawTexture(BlockedTilesMaskTexture, ref x);
DrawTexture(CliffsMaskTexture, ref x);
}
private void DrawTexture(Texture2D texture, ref int x)
{
const int spacing = 10;
var oldFilterMode = texture.filterMode;
texture.filterMode = FilterMode.Point;
var aspect = (float)texture.height / texture.width;
GUI.DrawTexture(new Rect(spacing + x, spacing, GUIRectWidth, GUIRectWidth * aspect), texture, ScaleMode.ScaleToFit, false);
texture.filterMode = oldFilterMode;
x += GUIRectWidth + spacing;
}
}
}