[Unity] ํ”Œ๋ ˆ์ด์–ด ์นด๋ฉ”๋ผ ๊ตฌํ˜„ํ•˜๊ธฐ - ์นด๋ฉ”๋ผ ์—๋””ํ„ฐ ๊ธฐ๋Šฅ ํ™•์žฅํ•˜๊ธฐ

2024. 5. 8. 21:20ยท โš™๏ธ ์—”์ง„/๐Ÿค ์œ ๋‹ˆํ‹ฐ

  • ์—๋””ํ„ฐ์—์„œ ํ™•์ธ ๊ฐ€๋Šฅํ•œ ๊ธฐ๋Šฅ์œผ๋กœ, editor๋ฅผ ์ƒ์†๋ฐ›๋Š”๋‹ค.
  • ์ฝ”๋“œ์—์„œ ์‚ฌ์šฉํ•˜๋Š” TopDownCamera ๋Š” ์ด์ „ ํฌ์ŠคํŠธ์— ๋‚˜์™€์žˆ๋‹ค.
  • ์› : ์บ๋ฆญํ„ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ distance๋ฅผ ํ‘œ์‹œ
  • ์‚ฌ๊ฐํ˜•๋“ค : handle์˜ ์Šค์ผ€์ผ ์Šฌ๋ผ์ด๋”๋ฅผ ์‚ฌ์šฉํ•ด ๋งŒ๋“  ์Šฌ๋ผ์ด๋” ์ปจํŠธ๋กค

using UnityEditor;
using UnityEngine;

namespace FastCampus.Cameras
{
    [CustomEditor(typeof(TopDownCamera))]
    public class TopDownCamera_Editor : Editor {
        #region Variables
        private TopDownCamera targetCamera;
        #endregion

        #region Main Methods
        public override void OnInspectorGUI() {
            targetCamera = (TopDownCamera)target;
            base.OnInspectorGUI();
        }

        private void OnSceneGUI() {
            // Make sure we have a target first!
            if (!targetCamera || !targetCamera.target) {
                return;
            }

            // Storing target reference
            Transform camTarget = targetCamera.target;
            Vector3 targetPosition = camTarget.position;
            targetPosition.y += targetCamera.lookAtHeight;

            // Draw distance circle
            Handles.color = new Color(1f, 0f, 0f, 0.15f);
            Handles.DrawSolidDisc(targetPosition, Vector3.up, targetCamera.distance);

            Handles.color = new Color(0f, 1f, 0f, 0.75f);
            Handles.DrawWireDisc(targetPosition, Vector3.up, targetCamera.distance);

            // Create slider handles to adjust camera properties
            Handles.color = new Color(1f, 0f, 0f, 0.5f);
            targetCamera.distance = Handles.ScaleSlider(targetCamera.distance, targetPosition, -camTarget.forward, Quaternion.identity, targetCamera.distance, 0.1f);
            targetCamera.distance = Mathf.Clamp(targetCamera.distance, 2f, float.MaxValue);

            Handles.color = new Color(0f, 0f, 1f, 0.5f);
            targetCamera.height = Handles.ScaleSlider(targetCamera.height, targetPosition, Vector3.up, Quaternion.identity, targetCamera.height, 0.1f);
            targetCamera.height = Mathf.Clamp(targetCamera.height, 2f, float.MaxValue);

            // Create Labels
            GUIStyle labelStyle = new GUIStyle();
            labelStyle.fontSize = 15;
            labelStyle.normal.textColor = Color.white;
            labelStyle.alignment = TextAnchor.UpperCenter;

            Handles.Label(targetPosition + (-camTarget.forward * targetCamera.distance), "Distance", labelStyle);

            labelStyle.alignment = TextAnchor.MiddleRight;
            Handles.Label(targetPosition + (Vector3.up * targetCamera.height), "Height", labelStyle);

            targetCamera.HandleCamera();
        }
        #endregion
    }
}

 

์ €์ž‘์žํ‘œ์‹œ

'โš™๏ธ ์—”์ง„ > ๐Ÿค ์œ ๋‹ˆํ‹ฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Unity] ํ”Œ๋ ˆ์ด์–ด ์นด๋ฉ”๋ผ ๊ตฌํ˜„ํ•˜๊ธฐ - 3์ธ์นญ TopDown ์นด๋ฉ”๋ผ ๊ตฌํ˜„ํ•˜๊ธฐ  (0) 2024.05.08
[Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - ์บ๋ฆญํ„ฐ ๋ชจ๋ธ, ์• ๋‹ˆ๋ฉ”์ด์…˜ ์„ค์ •  (0) 2024.05.06
[Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - NavMeshAgent  (1) 2024.05.06
[Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - Character Controller  (0) 2024.05.06
[Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - Rigidbody  (0) 2024.05.06
'โš™๏ธ ์—”์ง„/๐Ÿค ์œ ๋‹ˆํ‹ฐ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • [Unity] ํ”Œ๋ ˆ์ด์–ด ์นด๋ฉ”๋ผ ๊ตฌํ˜„ํ•˜๊ธฐ - 3์ธ์นญ TopDown ์นด๋ฉ”๋ผ ๊ตฌํ˜„ํ•˜๊ธฐ
  • [Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - ์บ๋ฆญํ„ฐ ๋ชจ๋ธ, ์• ๋‹ˆ๋ฉ”์ด์…˜ ์„ค์ •
  • [Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - NavMeshAgent
  • [Unity] ํ”Œ๋ ˆ์ด์–ด ์บ๋ฆญํ„ฐ ์ œ์ž‘ํ•˜๊ธฐ - Character Controller
peewoong
peewoong
peewoong
peewoong.log
peewoong
์ „์ฒด
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ
    • ๐Ÿ™‚ Info
    • ๐ŸŽฎ ๊ฒŒ์ž„ ๊ด€๋ จ ๊ฐœ๋…
    • ๐Ÿ‘ฉโ€๐Ÿ’ป ํ”„๋กœ๊ทธ๋ž˜๋ฐ
      • ๐ŸŽญ C
      • ๐ŸŽ  C++
      • ๐Ÿ• C#
      • โœจ ์ž๋ฃŒ๊ตฌ์กฐ
      • ๐ŸŽ ์•Œ๊ณ ๋ฆฌ์ฆ˜
      • ๐Ÿ”ข ์ˆ˜ํ•™
      • ๐ŸŽจ ๊ทธ๋ž˜ํ”ฝ์Šค
    • โš™๏ธ ์—”์ง„
      • ๐Ÿง€ VS
      • ๐Ÿค ์œ ๋‹ˆํ‹ฐ
      • ๐Ÿซ ์–ธ๋ฆฌ์–ผ
      • ๐Ÿน DirectX
      • ๐Ÿฆฅ error
    • ๐Ÿ“ฝ๏ธ ํ”„๋กœ์ ํŠธ
    • ๐Ÿง ์ฝ”๋”ฉํ…Œ์ŠคํŠธ

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

ํƒœ๊ทธ

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

hELLO ยท Designed By ์ •์ƒ์šฐ.v4.2.0
peewoong
[Unity] ํ”Œ๋ ˆ์ด์–ด ์นด๋ฉ”๋ผ ๊ตฌํ˜„ํ•˜๊ธฐ - ์นด๋ฉ”๋ผ ์—๋””ํ„ฐ ๊ธฐ๋Šฅ ํ™•์žฅํ•˜๊ธฐ
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”

๋‹จ์ถ•ํ‚ค

๋‚ด ๋ธ”๋กœ๊ทธ

๋‚ด ๋ธ”๋กœ๊ทธ - ๊ด€๋ฆฌ์ž ํ™ˆ ์ „ํ™˜
Q
Q
์ƒˆ ๊ธ€ ์“ฐ๊ธฐ
W
W

๋ธ”๋กœ๊ทธ ๊ฒŒ์‹œ๊ธ€

๊ธ€ ์ˆ˜์ • (๊ถŒํ•œ ์žˆ๋Š” ๊ฒฝ์šฐ)
E
E
๋Œ“๊ธ€ ์˜์—ญ์œผ๋กœ ์ด๋™
C
C

๋ชจ๋“  ์˜์—ญ

์ด ํŽ˜์ด์ง€์˜ URL ๋ณต์‚ฌ
S
S
๋งจ ์œ„๋กœ ์ด๋™
T
T
ํ‹ฐ์Šคํ† ๋ฆฌ ํ™ˆ ์ด๋™
H
H
๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด
Shift + /
โ‡ง + /

* ๋‹จ์ถ•ํ‚ค๋Š” ํ•œ๊ธ€/์˜๋ฌธ ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด์šฉ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ํ‹ฐ์Šคํ† ๋ฆฌ ๊ธฐ๋ณธ ๋„๋ฉ”์ธ์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.