‎ ‎
On the Asset Store
BlackBox
BlackBox
  • Intro
  • Changelog
  • Troubleshooting
  • Main features
    • Locking Prefabs
      • Temp Unlock
      • Extra locking options
    • Reveal
      • Properties
        • UnityEvents as buttons
      • Entire components
      • Object references
      • Methods
      • Reveal lists
    • Disable Apply
  • Integrations
    • Odin Inspector
  • Other
    • Selection type
    • Project Settings
Powered by GitBook
On this page
  • Revealing object references
  • On the BlackBox component
  • Via the context menu
  1. Main features
  2. Reveal

Object references

Last updated 5 months ago

It's a common pattern in Unity to reference objects and components from one Prefab to another. A simple example is Cinemachine: to target an object with a camera, you normally assign that object's Transform to the Tracking Target property of a CinemachineCamera.

But how to do it when the object you want to assign simply isn't visible, because it's a child of a locked Prefab?

This is why you might want to expose an object reference on the BlackBox. When you do so, the reference will be visualised as an ObjectField without the little circular "picker icon":

From here, you can simply right-click on the field and choose Copy, and then paste where you need this reference.

You will notice that trying to change the reference or nulling it shouldn't work, so you can't break the reference involuntarily with an override while you work on the Prefab.

Revealing object references

To reveal a reference, you can do it in two ways:

On the BlackBox component

Click on the Show Available Properties and Methods button on the BlackBox, and expand the foldouts until you arrive to the gameObject or component you're interested in.

Object References are preceded by a small [R] letter:

Press the [+] button to add the component or gameObject to the reveal list.

Via the context menu

References to components can also be revealed in context. While you have the right GameObject selected, right-click the component's title bar and choose BlackBox > Reference to Component > Reveal in..., like so:

First List, Second List... what are they?

Unfortunately, a Unity limitation means we can't display the custom names that you might have assigned to , and that's why they are displayed as First List, Second List, etc. up to 5 lists.

To add components to a higher number list, you can move the list in one of the first 5 positions, add the component, and move it back (using the reorder buttons in ).

Reveal lists
A CinemachineCamera needing to reference a Transform as a target
The object reference as seen on the BlackBox component, in the scene
Edit mode