Search Unity

Workaround to use static methods on Inspector Unity Events?

Discussion in 'Scripting' started by IvanNevesDev, Sep 15, 2019.

  1. IvanNevesDev

    IvanNevesDev

    Joined:
    Jan 28, 2019
    Posts:
    27
    I'm designing a Spell System using ScriptableObjects, and several spells have the same layout, chaning only the functions they use on Update, OnCollideEnter, etc...

    I have 2 static classes to provide several utilities for me, such as ApplyDamageOnCollision, DestroySpellPrefabOnCollisio, etc.... and with the help of those i can define new spells quite easily.

    However, since UnityEvents don't seem to be able to use static class functions, i'm needing to create a new spell C# Scriptable Object for every spell and then assigning the behavior "manually" there, and then creating the ScriptableObject asset instead of just changing the UnityEvents functions inside a "main" ScriptableObject.

    The way i have to do it right now is not much difference from just creating several prefab variantes of an actual spell prefab, but being able to benefit from the ScriptableObject stuff would be helpful.

    So, is there any workaround that gives me the at least a similar behavior to just use UnityEvents with those static classes functions?