Unity extension to allow you to assign Object fields by picking it from the scene view
Sometimes scene hierarchies get complex and you get in a frustrating situation where you need to assign a field and you know exactly where it is in the scene, but it's hard to point out in the hierarchy. I figured: why not make something to allow you to assign fields by pointing where the object is in the scene? That's exactly what this is.
- Add the package to your Unity project (tips on how to install it are in the Installation section)
- Open a script with fields derived from Object
- Click the new button next to the hierarchy picker
- Left Click to pick the desired object from the scene
- Middle Click to pick from nearby objects when they are cluttered together
- Right Click to cancel
- If you want a callback whenever a field is assigned via picking, add the
[PickCallback("OnPicked")]
attribute- You can specify the name of a method to be called
- This method can be parameterless or have two parameters of the same type of the field
- In the latter case, the previous and current value are provided
Go to Edit > Project Settings > Package Manager
. Under 'Scoped Registries' make sure there is an OpenUPM entry.
If you don't have one: click the +
button and enter the following values:
- Name:
OpenUPM
- URL:
https://package.openupm.com
Then under 'Scope(s)' press the +
button and add com.roytheunissen
.
It should look something like this:
All of my packages will now be available to you in the Package Manager in the 'My Registries' section and can be installed from there.
You can check out this repository as a submodule into your project's Assets folder. This is recommended if you intend to contribute to the repository yourself
The package is available on the openupm registry. It's recommended to install it via openupm-cli.
openupm add com.roytheunissen.sceneviewpicker
You can also install via git URL by adding this entry in your manifest.json
"com.roytheunissen.sceneviewpicker": "https://github.com/RoyTheunissen/Scene-View-Picker.git"
from Window->Package Manager, click on the + sign and Add from git: https://github.com/RoyTheunissen/Scene-View-Picker.git