Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasDeM committed Mar 1, 2020
2 parents a4e8aee + 2cab53e commit e29efc4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

[![openupm](https://img.shields.io/npm/v/io.github.jonasdem.entityselection?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/io.github.jonasdem.entityselection/)

A small package that enables you to select entities in the unity sceneview.
Works with every RenderPipeline.
A small package that enables you to select entities in the unity sceneview.
It works both in play mode & edit mode.
![EntitySelectionGif](https://jonasdem.github.io/Media/EntitySelection.gif)

## How to select
1. Make sure you're in PlayMode & your focus is on the sceneview (not gameview)
0. (Optional: Enable DOTS>LivelinkMode>LiveConversionInEditMode to have all entities in edit mode.)
1. Make sure your focus is on the sceneview (not gameview)
2. Point to the entity with mouse pointer
3. Press the '1' key (Non Numpad)
=> Inspector window should show all info for entity.
Expand Down
6 changes: 5 additions & 1 deletion Unity.EntitySelection.Editor/EntitySelectionEditorTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ public void OnDrawHandles()
EntitySelectionProxy entityProxy = target as EntitySelectionProxy;
if (entityProxy == null)
return;

var world = entityProxy.World;
if (!world.EntityManager.HasComponent<WorldRenderBounds>(entityProxy.Entity))
return;
var bounds = world.EntityManager.GetComponentData<WorldRenderBounds>(entityProxy.Entity).Value;

var bounds = entityProxy.World.EntityManager.GetComponentData<WorldRenderBounds>(entityProxy.Entity).Value;
Handles.color = Color.green;
Handles.DrawWireCube(bounds.Center, bounds.Size);
}
Expand Down
4 changes: 2 additions & 2 deletions Unity.EntitySelection.Editor/EntitySelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ private Color GetColorAtMousePos(Vector2 posLocalToSceneView, RenderTexture obje
{
RenderTexture.active = objectIdTex;

// clicked outside of sceneview
// clicked outside of scene view
if (posLocalToSceneView.x < 0 || posLocalToSceneView.x > objectIdTex.width
|| posLocalToSceneView.y < 0 || posLocalToSceneView.y > objectIdTex.height)
{
return new Color(0,0,0);
return new Color(0,0,0); // results in Entity.Null
}

// handles when the edges of the screen are clicked
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "io.github.jonasdem.entityselection",
"version": "0.3.0",
"version": "0.4.0",
"displayName": "Entity Selection",
"description": "Select your entities!",
"description": "Select your entities!\nFocus on the SceneView, point to the entity & press 1 (non-numpad).",
"unity": "2019.3",
"author": {
"name": "Jonas De Maeseneer",
Expand Down

0 comments on commit e29efc4

Please sign in to comment.