40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
public class ObjectMover : MonoBehaviour
|
|
{
|
|
[Header("이동할 오브젝트 리스트")]
|
|
public List<GameObject> targetObjects = new List<GameObject>();
|
|
|
|
[Header("프리셋 위치 (GameObjects)")]
|
|
public List<GameObject> presetPositions = new List<GameObject>();
|
|
|
|
/// <summary>
|
|
/// targetObjects를 지정한 프리셋 위치로 이동합니다.
|
|
/// </summary>
|
|
public void Set(int presetIndex)
|
|
{
|
|
if (presetIndex < 0 || presetIndex >= presetPositions.Count)
|
|
{
|
|
Debug.LogWarning($"[ObjectMover] 잘못된 프리셋 인덱스: {presetIndex}, 유효 범위: 0-{presetPositions.Count - 1}");
|
|
return;
|
|
}
|
|
|
|
var preset = presetPositions[presetIndex];
|
|
if (preset == null)
|
|
{
|
|
Debug.LogWarning($"[ObjectMover] 프리셋 위치가 null입니다: {presetIndex}");
|
|
return;
|
|
}
|
|
|
|
foreach (var obj in targetObjects)
|
|
{
|
|
if (obj == null) continue;
|
|
obj.transform.position = preset.transform.position;
|
|
obj.transform.rotation = preset.transform.rotation;
|
|
}
|
|
|
|
Debug.Log($"[ObjectMover] {targetObjects.Count}개 오브젝트를 프리셋 {presetIndex} ({preset.name})으로 이동");
|
|
}
|
|
}
|