Visualize Raycasts, Paths, and More in the Scene View with Editor Scripting




Published: 04 Oct 2022

Gargoyle Model used here: https://assetstore.unity.com/packages/3d/characters/creatures/gargoyles-fantasy-rpg-37416?aid=1101l9QvC


Learn how to extend an existing Inspector in the Unity Editor and draw debug information in the Scene View!


In this unity tutorial you will learn how you can start visualizing hard-to-debug information in the Scene View and the Inspector to help you understand exactly what's happening in your script and track down problems fast!


We'll do some simple editor scripting to:

⚫ Show some new controls on the Inspector that toggle on/off the Scene View visualization.

⚫ Show the path and current velocity of a NavMeshAgent in the Scene View

⚫ Show the health of an Enemy in the Scene View

⚫ Show the line of sight raycasts in the Scene View and mark which object is obstructing line of sight.

⚫ Show line of sight information in the Inspector

⚫ Allow clicking in the inspector on an object to ping it in the hierarchy and focus it in the scene view. Optionally with 1 line of code removed you can also select it)


I know it sounds like a lot, but it's actually pretty easy as you'll see in this introduction video


👨‍💻 As always, all code from this video is available on GitHub: https://github.com/llamacademy/scene-inspector-debug-information


🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


📚 Resources 📚

⚫ Handles API: https://docs.unity3d.com/ScriptReference/Handles.html

⚫ EditorGUIUtility.GetControlID: https://docs.unity3d.com/ScriptReference/GUIUtility.GetControlID.html

⚫ Custom Editors: https://docs.unity3d.com/Manual/editor-CustomEditors.html

⚫ Editor Windows Not Tied to a Custom Editor: https://docs.unity3d.com/Manual/editor-EditorWindows.html

⚫ AI Series Part 40 (Base for this video): https://youtu.be/dHLNqbKrJdg


🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:

🌟 Patreon: https://www.patreon.com/llamacademy

🌟 YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video

📚 Take my Unity ShaderGraph Course:

https://www.gamedev.tv/p/unity-shader-graph?affcode=45216_kuvg0bp7

👕 Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/

💸 Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4

💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publisher-sale?aid=1101l9QvC (affiliate)

💸 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC (affiliate)


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Music:

Soft Corporate: Soft Corporate by NewHOfTechnology | https://soundcloud.com/ewfechnolohy

Music promoted by https://www.free-stock-music.com

Creative Commons Attribution 3.0 Unported License

https://creativecommons.org/licenses/by/3.0/deed.en_US


Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.