There are a few fun ways to make fantastic Editor tools in Unity for your code. Two of those are `Handles` and `GenericMenu`. They enable you to create interactive components inside the Unity Scene View that allow you to more easily interact with your objects. They work as fantastic solutions for building custom editors. The thing is... I’ve never really used them. It’s time that changed.
Lets explore how these features work and how we might use them for our own projects. How do we draw a custom Handle using Unity’s Handle features? How about creating a custom editor with a context menu we can consume? We’ll build both to improve the visualization of our custom Graph code from a previous video.
To draw a basic `Handle` you may use `OnSceneGUI`. A sample of what this kind of editor might look like is below. It will draw a yellow line from the center of the scene to the `GameObject`’s position.
```csharp
using UnityEditor;
[CustomEditor(typeof(MyCustomClass))]
public class MyCustomClassEditor: Editor
{
protected virtual void OnSceneGUI()
{
MyCustomClass customClass = (MyCustomClass)target;
// Safety against selecting a null GameObject
if (customClass == null)
{
return;
}
= ;
(, );
}
}
```
You may draw a custom `GenericMenu` using something like this. It will create a two option menu that prints out the selected option to the Debug Log.
```csharp
GenericMenu menu = new GenericMenu();
(new GUIContent(“The name of a menu option“), false, () ⇒ { (“Picked First Option“); });
(new GUIContent(“The name of a second menu option“), false, () ⇒ { (“Picked Second Option“); });
// once you are done, show your menu
();
```
The documentation for `Handles` is available on Unity’s website:
The documentation for `GenericMenu` is also on Unity’s site. More info here:
Join the World of Zero Discord Server:
1 view
77
17
2 weeks ago 01:14:09 11
Behemoth Evangelia Heretika live on Paris 2008 HQ DVD RIP h264 AAC
3 weeks ago 00:12:04 1
Trump Claims He’ll Do Some Crazy Sh** To The World Map
3 weeks ago 00:37:45 1
Лулуха-убиваха | Смурф | Лига Легенд
3 weeks ago 00:03:24 1
Breaking Benjamin - The Diary of Jane | Drum Cover by Kristina Rybalchenko !!!
3 weeks ago 00:32:43 1
🟣 УЧУ ИГРАТЬ НА 5000 СРЕДНЕГО ● ВАЖНЫЕ ПРИНЦИПЫ! ● ОБУЧЕНИЕ ОТ СТАТИСТА №50
4 weeks ago 00:25:53 1
Смурф дуреет с этой прикормки | Лига Легенд
4 weeks ago 02:00:48 1
LIVE: URGENT Donald Trump MAGA & Joe Biden Rallies
4 weeks ago 00:11:46 1
SUPER-HERO-BOWL! (REACTION!!!)
4 weeks ago 00:12:36 1
SUPER-HERO-BOWL! (TOON SANDWICH) Reaction
4 weeks ago 00:12:03 1
“2025: A Year You Will Never Forget...“ | Pleiadian Council Of Light (Rieva)
4 weeks ago 00:02:59 1
What RESIDENT EVIL 1 REMAKE Would Look Like In FIRST PERSON
1 month ago 03:46:53 1
Gypsy Rose’s TikTok Hacked Is Fake IMO. The Signs Are All There - Blake Lively Astroturfing Lawsuit
1 month ago 00:03:09 1
New Imagebon 11.4“ H70 Pro 4K ADAS QLED In-cell Display Car DVR Wireless CarPlay
1 month ago 00:11:05 1
FULL SPEECH: Lauren Boebert Speaks at TPUSA’s America Fest Conference: Day Three - 12/21/24
1 month ago 00:16:24 1
Rage - Live at Wacken Open Air 2024
1 month ago 02:00:54 2
Syria Falls And No It’s Not A Good Thing | Candace Ep 116
2 months ago 00:27:46 1
Kill Team | Approved Ops 2024 Map Pack
3 months ago 00:04:28 1
💸 HOW TO ALWAYS WIN AND PROFIT ON CRASH ROOBET! BEST ROOBET CRASH STRATEGY! ROOBET PROMOCODE 2024 💸
3 months ago 00:04:20 2
Still Here | Season 2024 Cinematic - League of Legends (ft. Forts, Tiffany Aris, and 2WEI)
3 months ago 06:17:49 1
LIVE: President Trump Holds a Rally in Albuquerque, NM - 10/31/24
3 months ago 01:09:16 1
Бонус и Гамовер про главные игры 2000 г.
3 months ago 00:06:37 1
Dikengyuan Village With Underground Houses Thousands Of Years Old
3 months ago 00:15:42 1
WAKING UP AT 3 am? Warning🚨 THIS IS SERIOUS!!
3 months ago 00:34:31 5
Dragon Age: The Veilguard Shills Don’t Receive Review Codes Because They Weren’t Positive Enough