Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UltEvents - The Ultimate Event System For The Ultimate Price - FREE

Discussion in 'Assets and Asset Store' started by Kybernetik, Jun 1, 2019.

  1. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    I can't think of anything in UltEvents or Animancer that would cause problems with it, but I haven't used Unity 2020 much. If you do run into any issues just let me know.
     
  2. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    521
    Could you make UltEvent accept a static string as parameter on string fields in the inspector? Unity only accepts hard coded strings, it would be amazing if we could pass variables. I think this applies to int, floats, etc. Regular Unity only allows hard coded values in the inspector. I want to avoid magic strings in the inspector, but I can't find a way. It seems that I will just need to stop using the inspector for this. I like the inspector's convenience, and I'd like to keep using the inspector if there's a way to avoid magic strings on them. I was hoping weaver could do this. But maybe UltEvent can be updated to support this?
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    It would be possible, but if I get time to do more development on UltEvents there are a lot of more useful features I'd work on before something like that.

    I doubt there's any simple solution that would really improve your workflow for something like that.
     
    Marks4 likes this.
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    hi @Kybernetik , i encountered a small bug when multiselecting then dropping items in an ult event.
    multiselection display is correct
    upload_2021-4-14_13-52-0.png
    but if i drop in game ai in actions then i get this
    upload_2021-4-14_13-52-58.png
    two problems:
    immobilize and pause now refer to the same component instead of their own
    one drag and drop produces 2 entries
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    That's normal. Unity's multiselection system doesn't preserve the order of the objects so even if I were to explicitly override the drop behaviour you would only get them randomly assigned.
     
  6. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    I'm getting an "Attempted to Invoke a PersistentCall which couldn't find it's method: SetBool" error which happens only on the build, since it is working on the editor.

    It's just a trigger that sets a bool on an Animator to open a Door:

    upload_2021-4-16_10-33-21.png

    The Door is instantiated at runtime from a prefab
     
  7. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Check your Managed Code Stripping level. If it's enabled and none of your scripts are actually calling that method then it could be compiling it out of the build, in which case you could use a Link.xml file to prevent it as explained on that page.
     
  8. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    That was it, thanks.

    I didn't think 'Low' was going to strip this method, since I was using the SetBool(int, bool) equivalent on the code.
    By calling this exact method somewhere on the code the issue was fixed.

    However, I couldn't quite solve it with the Link.xml method, which I'm not very familiar with. This is what I tried, so far, without success:
    Code (XML):
    1. <linker>
    2.   <assembly fullname="UnityEngine">
    3.     <type fullname="UnityEngine.Animator">
    4.       <method signature="System.Void SetBool(System.String, System.Boolean)" />
    5.     </type>
    6.   </assembly>
    7. </linker>
    I also tried UnityEngine.AnimationModule here and there and some other stuff... Anyway, any help is appreciated :)
     
  9. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Try logging
    typeof(Animator).Assembly.FullName
    . If that name doesn't work, try logging it in a build since the runtime assembly might be different.

    I've never used it either so I'm not sure what else could be wrong.
     
  10. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    I use ultevent a lot, unfortunately rider can't find references by it and some times things need renaming or break
    Is there a way to detect broken things like this:
    upload_2021-4-17_17-13-35.png
    that can happen if i rename the method
    or things that are empty references
    i'll need to add a bunch of asserts
     
  11. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Unfortunately not. It would need to load every prefab and scriptable object in your project and go through all their fields recursively to look for missing methods then load every scene one by one to do the same. It's possible to do, but would take a bunch of work to implement and you'd have to execute it manually and wait for it to run which could take ages in a large project.

    It might be possible to make a central asset that tracks which methods are used where, but that would take even more effort to implement and could never be fully reliable.
     
  12. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Thanks for the tip!

    By the way, I found out that removing the space character after the comma made it work, so the answer was basically the same as I typed before, but without a space:


    Code (XML):
    1.     <linker>
    2.       <assembly fullname="UnityEngine">
    3.         <type fullname="UnityEngine.Animator">
    4.           <method signature="System.Void SetBool(System.String,System.Boolean)" />
    5.         </type>
    6.       </assembly>
    7.     </linker>
     
  13. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Hi,
    i'm not sure where to locate the source of this error, so i'm asking here first:
    i have a [SerializeReference] List of objects where UltEvent<T> derived classes don't appear in the inspector inside of them.
    They do appear if i put such an object in a regular serialized field:
    upload_2021-4-22_13-14-10.png

    upload_2021-4-22_13-15-42.png

    upload_2021-4-22_13-17-26.png

    I'm using odin inspector, but even with it disabled, the event that's contained in the list's object doesn't show up.
    UnityEvents are visible in both cases though
    Any idea?
     
  14. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    I haven't played around with SerializeReference yet so I'm not sure. See if you can narrow down the problem. What if you don't use a list? What if you use a non-generic UltEvent? What if you use a simpler serializable class?
     
  15. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    That's what i wanted to express in the example above, if i put it in a regular field it works fine.
    I tried that, but that resulted in the same; it wasn't shown in the list, but still in the field-based one as in the first case.

    This is where it breaks:

    Code (CSharp):
    1.  
    2. [SerializeField, SerializeReference] List<InheritedBase> testClasses = new List<InheritedBase>();
    3.  
    4. [Serializable]
    5. public abstract class BaseClass<T>
    6. {
    7. }
    8.  
    9. [Serializable]
    10. public abstract class InheritedBase: BaseClass<bool>
    11. {
    12. }
    13.  
    14. [Serializable]
    15. public class TestClass: InheritedBase
    16. {
    17.     [SerializeField] BoolEvent testEventInSimpleClass = new BoolEvent();
    18. }
    And it only seems to break visually; as odin inspector adds copy-paste functionality for rightclicks on properties and the popup is shown for what seems to be an invisible/undrawn field, that spans a single line, just as your event drawer does by default.
    upload_2021-4-23_9-24-18.png

    Edit: i do get a queue empty error when i completely disable odin; but from researching i found a post in the animancer thread that helped, [NonReorderable] removed it, although it's still not visible.

    Edit2: While trying to debug it i saw that UltEventDrawer.OnGUI never gets past this line:
    Code (csharp):
    1.  
    2. if (!DrawerState.Current.TryBeginEvent(property))
    3.     return;
    4.  
    Edit3: Serialization.cs:476 GetAccessor(..) fails, returns null on line 487

    Edit4: this seems to be where it fails:
    upload_2021-4-23_10-25-21.png
    parent is an array and var field = GetField(..) then obviously returns null, so accessor becomes null
     
    Last edited: Apr 23, 2021
  16. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Looks like it has nothing to do with lists or generics, the problem is inheritance which I wasn't accounting for since it wasn't possible before [SerializeReference].

    So you can get the same issue with this:
    Code (CSharp):
    1. public class NewBehaviourScript : MonoBehaviour
    2. {
    3.     [SerializeReference] private Base thing = new Child();
    4. }
    5.  
    6. [Serializable]
    7. public abstract class Base { }
    8.  
    9. [Serializable]
    10. public class Child : Base
    11. {
    12.     [SerializeField] UltEvent ult = new UltEvent();
    13. }
    The problem is that it's trying to get a field named "ult" from the Base class because that's the field type but it actually needs to look in the Child class since that's the type of object actually assigned to the field. It should be fixable, but looks like it won't be particularly simple so it might be a few days before I can make time to work on it properly.
     
    Flavelius likes this.
  17. TheShadowKnight13

    TheShadowKnight13

    Joined:
    Jan 5, 2019
    Posts:
    2
    Hi! Is there any way to change default logic for adding new methods in Editor UI? I'm currently trying to show Ult Event in Editor Window and it makes changing object really tedious. I can live with that but I'm doing it for story writes and thay would have hard time finding correct object. Is there any event that i can listen automatically change selected object?
    [Listening for + button clicks or new method poping up]
    upload_2021-4-23_17-34-26.png
     
  18. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    The logic for adding new calls via the GUI is in the AddNewCall method in the UltEventDrawer class.

    What do you want to change it to?
     
  19. TheShadowKnight13

    TheShadowKnight13

    Joined:
    Jan 5, 2019
    Posts:
    2
    Thanks! Now whenever I want to add new object It defaults to new alternative object instead of normal object that stores UltEvent!
    [My implementation, clunky but it just works]
    upload_2021-4-24_11-31-56.png
    PS: sorry if my explanation is bad but English is not my first language.
     
  20. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    @Flavelius Replacing your Serialization.cs with the attached script should solve that issue.
     

    Attached Files:

    Flavelius likes this.
  21. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Looks like it works, thanks
     
  22. NeedsLoomis

    NeedsLoomis

    Joined:
    Mar 22, 2017
    Posts:
    57
    With the Addressables system slowly becoming a major part of the Unity workflow for lots of us, it would be pretty sweet if UltEvents had support for AssetReference/AssetReferenceGameObject/AssetReferenceSprite/etc classes.
     
  23. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    It looks like it should be possible with some modifications to PersistentArgument and PersistentArgumentDrawer, but I don't have any spare time to work on UltEvents at the moment.

    When I do get to work on it again I might end up totally restructuring the system because I have an idea for a different approach that could potentially allow it to support any serializable type without needing specific support for each one, though I'm not certain it's actually possible and would also need to make sure it can achieve decent performance.
     
  24. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    request:
    when something is not valid, also turn the title red
    useful when you have tons of ult
    upload_2021-7-20_13-41-47.png
     
  25. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Should be easy enough. I'll put it on my to do list for when I next work on the system.
     
    laurentlavigne likes this.
  26. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    could we also get a search?
    ouch
    upload_2021-7-23_20-37-38.png
     
  27. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    If I do end up reworking the system, replacing those dropdown menus is one of things I'd want to do, though I don't have any specific ideas for how I'd design it yet.
     
  28. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    this is pretty nice
    upload_2021-7-23_21-15-59.png
     
  29. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Can you publish this change to the asset store? I keep coming back to this thread, because i also keep encountering this issue whenever i use UltEvents in a new project.
     
    laurentlavigne likes this.
  30. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    UltEvents v2.2 is now up on itch.io with the fixed Serialization script. Might take a while for the Asset Store.
     
    Flavelius likes this.
  31. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    I have a situation where i cannot unlink a handler parameter from a previous handler:
    upload_2021-9-14_14-38-11.png
    The link button (the small one to the right) does nothing when clicked
    Is this intended or what could potentially be a problem here?
    It's a regular [SerializeField] non-generic UltEvent.
    I just want to print a custom string
     
  32. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    print takes an object (not a string) which isn't one of the supported parameter types so it can only come from a linked return value or event parameter. The method should be highlighted in red and shouldn't be selectable in that situation.

    You'll have to make your own method that takes a string.
     
  33. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Ok, that makes sense. Thanks for clarifying
     
  34. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    Hey @Kybernetik have you heard of situations when ultevents don't all get invoked?
    The first few ones in the array do get called but then some times the ones after do not.
     
  35. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Not that I know of.

    Is an exception being thrown or is it just silently failing?
     
  36. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    silently failing
     
  37. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    I can't think of anything which would cause that sort of behaviour.

    Is it something you can replicate reliably to debug through the code?
     
  38. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,222
    not easily as i use a lot of ult
    and looking through your code that shouldn't happen, ult does a simple for loop through all calls
     
  39. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    I'm using a library called Unity Atoms, and it uses inheritance and template on its types. My point being that its abstract class has a property:
    Code (CSharp):
    1. public override T Value { get => _value; set => SetValue(value); }
    My issue with UltEvents it that when trying to access this property in UltEvents component I have a different behaviour depending on the type T. If it's a
    int
    I have access to the
    Value
    property, if the type T is
    vector3
    I cant. If on the vector3 derived class I implement a method
    SetValue
    that is just an set for the
    T Value
    , I can user it on UltEvents component.

    Would like to know if this is an issue, a limitation or anything else.
     
  40. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Yeah, I'm pretty sure that's just an unfortunate limitation of the way UltEvents is implemented. Anything to do with generics makes reflection a bunch more complicated.
     
  41. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Dont know if this helps or if you plans on target that, but here is the diference between both types: On int the first 2 lines are showing correctly, on vector3, the first 2 are empty, and on the second line there is a list but it's empty

    Int:
    Atoms Int.png


    Vector3:
    Atoms Vector3.png

    If you want to investigate I can send a raw project with ult events and atoms showcasing the problem
     
  42. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Yeah, that looks like it could just be an issue with the way I'm building the list or maybe an unusual character somewhere so if you want to send a minimal repro project to mail@kybernetik.com.au I'll take a look at it.
     
  43. thomas_superFASTgames

    thomas_superFASTgames

    Joined:
    Jul 15, 2017
    Posts:
    23
    This is very cool! Is there a built in way to "disable" an entry, like a toggle to temporarily skip it so we don't have to remove it and add it again later?
     
  44. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    There isn't. When I designed the system I didn't want to encourage people to leave unused data all over the place that's just wasting space and loading times. But if I ever get around to redesigning the system (which isn't likely to happen any time soon) I'd probably build in a feature like that because people do ask for it occasionally.
     
  45. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    @Fira-Soft There's something wrong in the MethodSelectionMenu class but I don't have time to keep looking into it right now.

    As a temporary workaround, Display Options -> Base Types -> Individual Sub-Menus seems to avoid the problem and allows you to pick the SetValue method.
     
  46. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    OK! Thanks for the feedback
     
  47. DMurz

    DMurz

    Joined:
    Jan 31, 2020
    Posts:
    1
    Hello, thank you for this great asset.
    Can i see number of assigned event in JetBrains Rider as at UnityEvent? upload_2021-9-30_13-54-8.png
     
  48. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    Unfortunately that system is likely specific to UnityEvents so someone would need to implement a similar extension (or whatever Rider uses) for UltEvents which wouldn't be worth the effort.
     
  49. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    @Fira-Soft Looks like there's a maximum allowed length for menu items but rather than giving an error or just drawing what can fit, it goes blank instead.

    If you open the
    MethodSelectionMenu
    class, there are 4 calls to
    GetNameCS()
    which don't pass in a parameter and changing them to
    GetNameCS(BoolPref.ShowFullTypeNames)
    shortens them enough to avoid the issue. Obviously that's not an ideal solution, but if I ever get around to doing more development on UltEvents, I'd want to replace that entire menu anyway.
     
  50. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Hey, i was getting errors about fields not being part of a type which they also shouldn't be (in one of the GetValue calls in Serialization.cs). It seemed to have come from a [SerializeField] UltEvent<T> field.
    In the containing abstract class i have two UltEvent fields, one non-generic and one that is left generic as UltEvent<T> as i hoped this would work when inheriting. Interestingly the generic one was drawn in the inspector while the non-generic one wasn't and errors were spamming the console.
    I think there was some mixup happening internally as the generic one shouldn't have been drawn, atleast that is now my understanding (SerializeReference (which was at the root of the object chain) doesn't handle 'inflated' types, and SerializeField (which was applied to the event field) neither).
    It's hard to create a reproduction as i'm not entirely sure what's causing it and the source project is way too entangled to meaningfully rip that apart, but i hope this (hopefully not to confusing) description atleast gives a hint.
    Also, when i removed the generic event field (and put it as an inherited non-generic one into a derived class) the errors stopped, so it atleast points towards a glitch there.
    The basic structure is
    a [SerializeReference] List<AbstractClass> containing instances of wrappers that each contain different UltEvent type fields, one type (handling enums) with the two described above.

    Edit: Here's the error:

    Code (CSharp):
    1. ArgumentException: Field onValueChanged defined on type Data.Properties.Components.BoolExposedComponentProperty is not a field on the target object which is of type Data.Properties.Components.ToggleDirectionsExposedComponentProperty.
    2. Parameter name: obj
    3. System.Reflection.MonoField.GetValue (System.Object obj) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    4. UltEvents.Editor.Serialization+PropertyAccessor.GetValue (System.Object obj) (at Assets/3rdParty/UltEvents/Inspector/Serialization.cs:970)
    5. UltEvents.Editor.Serialization.GetValue (UnityEditor.SerializedProperty property, System.Object targetObject) (at Assets/3rdParty/UltEvents/Inspector/Serialization.cs:113)
    6. UltEvents.Editor.Serialization.GetValue (UnityEditor.SerializedProperty property) (at Assets/3rdParty/UltEvents/Inspector/Serialization.cs:120)
    7. UltEvents.Editor.Serialization.GetValue[T] (UnityEditor.SerializedProperty property) (at Assets/3rdParty/UltEvents/Inspector/Serialization.cs:123)
    8. UltEvents.Editor.DrawerState.TryBeginEvent (UnityEditor.SerializedProperty eventProperty) (at Assets/3rdParty/UltEvents/Inspector/DrawerState.cs:80)
    And: after i changed the generic field to a non-generic derived one and put that into the derived class, the error stopped as mentioned, but after i then reverted the field (to be able to copy the error) there was no error anymore, so i had to copy it from another location where it was also thrown. My assumption here is that, because i named the new field in the inherited class the same, unity persisted the data and after i reverted the definition the persistent data is still somehow involved in then hiding the error, but that's just a guess; atleast it's a strange behaviour.

    Edit 2: Ok, now that i re-reverted to the non-generic inherited class field, i also get the error there..
     
    Last edited: Oct 28, 2021