2026-04-03 미니맵 추가중
This commit is contained in:
8
Assets/02_Scripts/UI/Minimap.meta
Normal file
8
Assets/02_Scripts/UI/Minimap.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ac2fd73b3fec65448b65adadd35989f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/02_Scripts/UI/Minimap/MinimapCapture.cs
Normal file
40
Assets/02_Scripts/UI/Minimap/MinimapCapture.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
public class MinimapCapture : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Camera _minimapCamera;
|
||||
[SerializeField] private int _resolution = 1024;
|
||||
[SerializeField] private string _savePath = "Assets/08_UI/MinimapImage.png";
|
||||
|
||||
[ContextMenu("미니맵 이미지 캡처")]
|
||||
public void CaptureMapImage()
|
||||
{
|
||||
RenderTexture rt = new RenderTexture(_resolution, _resolution, 24);
|
||||
_minimapCamera.targetTexture = rt;
|
||||
_minimapCamera.Render();
|
||||
|
||||
RenderTexture.active = rt;
|
||||
Texture2D tex = new Texture2D(_resolution, _resolution, TextureFormat.RGB24, false);
|
||||
tex.ReadPixels(new Rect(0, 0, _resolution, _resolution), 0, 0);
|
||||
tex.Apply();
|
||||
|
||||
byte[] bytes = tex.EncodeToPNG();
|
||||
System.IO.File.WriteAllBytes(_savePath, bytes);
|
||||
|
||||
_minimapCamera.targetTexture = null;
|
||||
RenderTexture.active = null;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
DestroyImmediate(rt);
|
||||
DestroyImmediate(tex);
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log($"미니맵 이미지 저장 완료: {_savePath}");
|
||||
#else
|
||||
Destroy(rt);
|
||||
Destroy(tex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/Minimap/MinimapCapture.cs.meta
Normal file
2
Assets/02_Scripts/UI/Minimap/MinimapCapture.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4a6e37a841f8f64bb2142ceb2c29d0e
|
||||
52
Assets/02_Scripts/UI/Minimap/MinimapMarker.cs
Normal file
52
Assets/02_Scripts/UI/Minimap/MinimapMarker.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MinimapMarker : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Sprite _iconSprite;
|
||||
[SerializeField] private Color _iconColor = Color.red;
|
||||
[SerializeField] private Vector2 _iconSize = new Vector2(10f, 10f);
|
||||
[SerializeField] private bool _rotateWithTarget = false;
|
||||
|
||||
private RectTransform _iconRect;
|
||||
private Transform _target; // 추적할 월드 오브젝트
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_target = transform;
|
||||
}
|
||||
|
||||
public void Initialize(MinimapManager manager)
|
||||
{
|
||||
// 마커 아이콘 UI 생성
|
||||
GameObject iconObj = new GameObject($"Marker_{gameObject.name}");
|
||||
iconObj.transform.SetParent(manager.MarkerContainer, false);
|
||||
|
||||
Image img = iconObj.AddComponent<Image>();
|
||||
img.sprite = _iconSprite;
|
||||
img.color = _iconColor;
|
||||
|
||||
_iconRect = iconObj.GetComponent<RectTransform>();
|
||||
_iconRect.sizeDelta = _iconSize;
|
||||
|
||||
manager.RegisterMarker(this);
|
||||
}
|
||||
|
||||
public void UpdatePosition(MinimapManager manager)
|
||||
{
|
||||
if (_iconRect == null || _target == null) return;
|
||||
|
||||
_iconRect.anchoredPosition = manager.WorldToMapPos(_target.position);
|
||||
|
||||
if (_rotateWithTarget)
|
||||
{
|
||||
_iconRect.localRotation = Quaternion.Euler(0, 0, -_target.eulerAngles.y);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_iconRect != null)
|
||||
Destroy(_iconRect.gameObject);
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/UI/Minimap/MinimapMarker.cs.meta
Normal file
2
Assets/02_Scripts/UI/Minimap/MinimapMarker.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85b8750f387527d4c8751eefec4c4c47
|
||||
Reference in New Issue
Block a user