Is there a way to pass an object reference to a component directly from the property/component parameter window? Using the [Inspectible] tag only allows me to input strings and not actual object references.
For example, I have a custom component called “knob” which should hold a reference to a door on the stage which it opens. I know this can be easily done in code with “knob.door = someDoor;” but since there are many objects in the scene I would prefer if I could do it visually trough the properties window.
I don’t think you can do this. Your best bet is to pass in a string identifier (perhaps a whole dot-separated path if your clips are deeply nested), and then implement code inside your custom component to find that item by name.
I’ve got a custom component which lays itself out relative to horizontal and vertical predecessor components, so I do this:
… which is made easy because all these components share the same parent.
Alternatively, if there’s only one door, you could make it a singleton, and give it a static reference, like this:
Then your handle can just refer to
Door.Singletonand you don’t have to worry about passing anything in. Alternatively, you could have a static array of Doors in the Door class, and give your handle an index number to link it to a specific Door.