#UnityEvent, call function on public property.

1 messages · Page 1 of 1 (latest)

steel current
#

Is there anyway to access a public property and run a function on it through the UnityEvent interface?

My EchoGameMode has the following property:

//persistent
    public GameEventsManager GameEvents { get => _gameEvents; private set => _gameEvents = value; }
    private GameEventsManager _gameEvents;

I would like to be able to, in the UnityEvent interface, run EchoGameMode.GameEvents.FinishReached.

Do i really have to make a pass-trhough function for that? Is there no other way?

fringe hemlock
steel current
#

yeah cool, but can i not access the reference through EchoGameMode

#

EchoGameMode holds a reference to GameEventsManager, and that's what i want to run the function on

fringe hemlock
#

You can set the reference, but you can't access the members of that object. That's the limitations of an inspector event interface.

steel current
#

GameEventsManager is a persistent object ,DDOL, and so if i reference it directly in the editor, it can end up being a wrong instance

#

ah well, nothing to do about it

fringe hemlock
#

Why not define OnTriggerEnter in your script directly? Then you can call whatever you want from it.

steel current
#

Since i wanted that to be a generic script, that executed a bunch of unity events for quick prototyping, but i guess making a non-generic script is in order for this case then

fringe hemlock
#

Yes. If you want to make it more generic you'll have to think of a different way. This is just a limitation of the unity event inspector.

#

Which is not unreasonable.