Context (you can skip this if you want; precise problem described below):
I’m putting together a event-condition-action tool for our designers to implement simple functionality for our game without needing to know how to program. The system is coordinated through the GameObject hierarchy so that Actions will trigger in response to its parent GameObject’s Events being invoked. Other parameters to the Actions and Events can be drag and dropped through the inspector variable assignment interface.
The problem I’m encountering is how to pass arguments from the triggered Event (e.g., when object enters Collider, pass the entering object to the action) but also allows preexisting objects to be assigned transparently. Anyway, the way I decided to solve it is through a DataProvider MonoBehaviour “interface” that can provide the object required by the Action through either an Event output parameter or as an object that already exists in the scene.
And it all works great except Events need to be able to have multiple output parameters that can each be assigned to a serialized variable of an Action component independently, and…
Problem:
When a MonoBehaviour “A” has a public variable of some other MonoBehaviour type “B”, you can drag a game object containing a B component into the B variable slot in A’s inspector. However, if the game object has multiple components of type “B”, there doesn’t seem to be a way to differentiate in which one is assigned. And I need to do that.
Can I without hacky work arounds like adding the scripts and doing the assignments in a specific order?
I did not know about the inspector trick. Pretty neat, but kind of a pain.
I would love to use a custom inspector for this, but unfortunately, it relies heavily on inheritance by using many small and functionally independent extensions of a few base classes. I don’t really want to have 30-50 copied and pasted custom inspectors laying around, and Unity doesn’t support inspector inheritance without some crazy reflection hacks, so that option is kind of out the window.
I actually just ended up putting the DataProvider components on child gameobjects of the Event. Looks pretty bad, but it works alright. It’s more convenient than the alternatives.
The other solution I’m going to investigate is just recreating the inspector. Apparently it’s not very difficult, and it would afford me the customization I want.