Created
March 22, 2024 11:47
-
-
Save baba-s/fe00a972049ae0886a9d728557376540 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
internal static class Example | |
{ | |
static Example() | |
{ | |
SceneView.beforeSceneGui -= OnDuringSceneGui; | |
SceneView.beforeSceneGui += OnDuringSceneGui; | |
static void OnDuringSceneGui( SceneView sceneView ) | |
{ | |
var position = Event.current.mousePosition; | |
var currentDrawingSceneView = SceneView.currentDrawingSceneView; | |
var camera = currentDrawingSceneView.camera; | |
position.y = camera.pixelHeight - position.y; | |
position = camera.ScreenToWorldPoint( position ); | |
position.y = -position.y; | |
var outObjectList = new List<Object>(); | |
HandleUtility.GetOverlappingObjects( position, outObjectList ); | |
foreach ( var outObject in outObjectList ) | |
{ | |
Debug.Log( outObject ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment