// ╔════════════════════════════════════════════════════════════════╗
// ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║
// ║ Licensed under Unity Asset Store Terms of Service: ║
// ║ https://unity.com/legal/as-terms ║
// ║ Use permitted only in compliance with the License. ║
// ║ Distributed "AS IS", without warranty of any kind. ║
// ╚════════════════════════════════════════════════════════════════╝
#region
using NWH.DWP2.WaterObjects;
using UnityEngine;
#endregion
namespace NWH.DWP2.DemoContent
{
///
/// Demo script that spawns a 3D grid of cubes with WaterObjects attached.
/// Used for stress-testing and demonstrating the buoyancy system with multiple objects.
///
public class CubeGridSpawner : MonoBehaviour
{
///
/// Spacing between cubes on the Z axis.
///
public float depth = 1.1f;
///
/// Spacing between cubes on the Y axis.
///
public float height = 1.1f;
///
/// Spacing between cubes on the X axis.
///
public float width = 1.1f;
///
/// Number of cubes to spawn along the X axis.
///
public int xResolution = 10;
///
/// Number of cubes to spawn along the Y axis.
///
public int yResolution = 10;
///
/// Number of cubes to spawn along the Z axis.
///
public int zResolution = 10;
private void Start()
{
for (int x = 0; x < xResolution; x++)
{
for (int y = 0; y < yResolution; y++)
{
for (int z = 0; z < zResolution; z++)
{
GameObject spawnedObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
spawnedObject.transform.position = new Vector3(x * width, y * height, z * depth);
Rigidbody rb = spawnedObject.AddComponent();
rb.mass = 200f;
spawnedObject.AddComponent();
}
}
}
}
}
}