using UnityEngine;
///
/// Test script to verify team marker camera functionality.
/// Attach this to any GameObject to test the camera system.
///
public class TeamMarkerCameraTest : MonoBehaviour
{
[Header("Test Controls")]
[Tooltip("Key to run all camera tests")]
public KeyCode testAllKey = KeyCode.T;
[Tooltip("Key to test team marker centering")]
public KeyCode testCenterKey = KeyCode.Y;
[Tooltip("Key to test full map view")]
public KeyCode testFullMapKey = KeyCode.U;
void Update()
{
if (Input.GetKeyDown(testAllKey))
{
RunAllTests();
}
if (Input.GetKeyDown(testCenterKey))
{
TestTeamMarkerCentering();
}
if (Input.GetKeyDown(testFullMapKey))
{
TestFullMapView();
}
}
public void RunAllTests()
{
Debug.Log("π§ͺ Running Team Marker Camera Tests...");
// Test 1: Check if team placement exists
TestTeamPlacementExists();
// Test 2: Check if camera controllers exist
TestCameraControllersExist();
// Test 3: Test team marker centering
TestTeamMarkerCentering();
// Test 4: Test full map view
TestFullMapView();
Debug.Log("β
Team Marker Camera Tests Complete!");
}
private void TestTeamPlacementExists()
{
SimpleTeamPlacement teamPlacement = FindFirstObjectByType();
if (teamPlacement == null)
{
Debug.LogError("β SimpleTeamPlacement not found in scene!");
return;
}
Debug.Log("β
SimpleTeamPlacement found");
if (!teamPlacement.IsTeamPlaced())
{
Debug.LogWarning("β οΈ Team not yet placed, attempting to place...");
teamPlacement.RandomlyPlaceTeam();
}
else
{
Debug.Log("β
Team is placed");
}
GameObject teamMarker = teamPlacement.GetTeamMarker();
if (teamMarker != null)
{
Debug.Log($"β
Team marker found at position: {teamMarker.transform.position}");
}
else
{
Debug.LogError("β Team marker object not found!");
}
}
private void TestCameraControllersExist()
{
// Check for enhanced camera controllers
MapCameraController mapCameraController = FindFirstObjectByType();
MMCameraController mmCameraController = FindFirstObjectByType();
TeamMarkerCameraController teamMarkerController = FindFirstObjectByType();
int controllerCount = 0;
if (mapCameraController != null)
{
Debug.Log("β
MapCameraController found (enhanced with team marker support)");
controllerCount++;
}
if (mmCameraController != null)
{
Debug.Log("β
MMCameraController found (enhanced with team marker support)");
controllerCount++;
}
if (teamMarkerController != null)
{
Debug.Log("β
TeamMarkerCameraController found (universal component)");
controllerCount++;
}
if (controllerCount == 0)
{
Debug.LogWarning("β οΈ No enhanced camera controllers found. You may need to add TeamMarkerCameraController to your camera.");
}
else
{
Debug.Log($"β
Found {controllerCount} camera controller(s) with team marker support");
}
}
private void TestTeamMarkerCentering()
{
Debug.Log("π― Testing team marker centering...");
// Try to find any camera controller that supports team marker centering
TeamMarkerCameraController teamMarkerController = FindFirstObjectByType();
if (teamMarkerController != null)
{
teamMarkerController.CenterOnTeamMarker();
Debug.Log("β
Called CenterOnTeamMarker() on TeamMarkerCameraController");
return;
}
MapCameraController mapCameraController = FindFirstObjectByType();
if (mapCameraController != null)
{
mapCameraController.CenterOnTeamMarker();
Debug.Log("β
Called CenterOnTeamMarker() on MapCameraController");
return;
}
MMCameraController mmCameraController = FindFirstObjectByType();
if (mmCameraController != null)
{
mmCameraController.CenterOnTeamMarker();
Debug.Log("β
Called CenterOnTeamMarker() on MMCameraController");
return;
}
Debug.LogWarning("β οΈ No camera controller with CenterOnTeamMarker() method found!");
}
private void TestFullMapView()
{
Debug.Log("πΊοΈ Testing full map view...");
// Try to find any camera controller that supports full map view
TeamMarkerCameraController teamMarkerController = FindFirstObjectByType();
if (teamMarkerController != null)
{
teamMarkerController.ZoomToFullMap();
Debug.Log("β
Called ZoomToFullMap() on TeamMarkerCameraController");
return;
}
MapCameraController mapCameraController = FindFirstObjectByType();
if (mapCameraController != null)
{
mapCameraController.ZoomToFullMap();
Debug.Log("β
Called ZoomToFullMap() on MapCameraController");
return;
}
MMCameraController mmCameraController = FindFirstObjectByType();
if (mmCameraController != null)
{
mmCameraController.ZoomToFullMap();
Debug.Log("β
Called ZoomToFullMap() on MMCameraController");
return;
}
Debug.LogWarning("β οΈ No camera controller with ZoomToFullMap() method found!");
}
void OnEnable()
{
Debug.Log($"π§ͺ Team Marker Camera Test script enabled!\n" +
$"- {testAllKey}: Run all tests\n" +
$"- {testCenterKey}: Test team marker centering\n" +
$"- {testFullMapKey}: Test full map view");
}
}