Search Unity

[UnityEvent] Static function call. Feature request.

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Dampire, Sep 29, 2014.

  1. Dampire

    Dampire

    Joined:
    Jan 18, 2014
    Posts:
    7
    Unity 4.6.0b19.
    This code works great.
    Code (CSharp):
    1.  
    2. ...
    3.     [System.Serializable]
    4.     public class ClickEvent : UnityEvent<bool> {}
    5.     public ClickEvent OnClick = new ClickEvent();
    6.  
    7.     void Start()
    8.     {
    9.         image.color = normal;
    10.         image.sprite = Checked?on:off;
    11.         OnClick.AddListener(GameManager.Test);
    12.         OnClick.Invoke(Checked);
    13.     }
    14. ...
    15.  
    But why I can't add this listener via editor? Tried static class with static method, singleton with static method.

    Upd.
    GameManager is not property, it is a class with static method Test.
     
    turbanov and Nanity like this.
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,093
    We don't have a nice way to hook up statics via the editor currently (we need to store some instance that is the target). We want to address this in the future.
     
    Goat-Boy likes this.
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    502
    Has this been addresses in the meantime? Or is there some other nice way to assign static functions via the inspector?
     
    turbanov likes this.
  4. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,140
    No it hasn't been addressed and still no nice way to assign static functions
     
  5. RyuHayaboosa

    RyuHayaboosa

    Joined:
    Mar 8, 2015
    Posts:
    6
    Any update to this?
     
  6. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    30
    Just piling on in 2018 that this would be a nice feature! Doesn't seem to be in place as far as I can tell (2017.3)

    Thanks!
     
  7. leveledgames_dev

    leveledgames_dev

    Joined:
    Jul 27, 2016
    Posts:
    44
    We'd like to throw our hat into this ring as well. This thread has been here three and a half years, it could probably use all the support it can get.
     
  8. Wokarol

    Wokarol

    Joined:
    Aug 1, 2017
    Posts:
    16
    Calling static methods would be really helpful. Making ScriptableObjects for each class just to pass function call is irritating.
     
  9. CoderNation1

    CoderNation1

    Joined:
    May 23, 2016
    Posts:
    2
    @Tim-C

    Are we still going to get static calls through unity events?
    It's been awhile...
     
    Goat-Boy and Haapavuo like this.
  10. Haapavuo

    Haapavuo

    Joined:
    Sep 19, 2015
    Posts:
    37
    +1 for this! Been waiting for it since 2014 (5 years)!
     
    Goat-Boy likes this.
  11. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,017
    Did anyone create a feedback item for it? That's how Unity Technologies wants us to report suggestions:
    https://feedback.unity3d.com

    Once a feedback item exists, people can vote on it and Unity Technologies is able to see it's demand.
     
  12. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    518
    Anyone who is still looking for this functionality should check out my free UltEvents plugin which serves the same purpose as UnityEvents, but has superior features (including the ability to call static methods) with fewer restrictions and an improved Inspector interface that requires fewer clicks to perform individual tasks.
     
    funbites and Wokarol like this.
  13. Goat-Boy

    Goat-Boy

    Joined:
    Jun 15, 2015
    Posts:
    127
    Adding my +1 for this feature. Is this on the road map?
     
  14. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    73
    Lol still nothing? Hilarious! :D