[Feature Request] (Custom Tasks) Easy Drop-down selector for list/arrays

NodeCanvas Forums General Discussion [Feature Request] (Custom Tasks) Easy Drop-down selector for list/arrays

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #8748
    Async0x42
    Participant

    All the dropdowns I saw in Tasks for NodeCanvas were via Enums I think, so what would be great would be an attribute we could add for the following:

    as a few examples.

    For example, while the parameter is for a single string, this easily allows the designer to restrict the selection to specific names, gives the user an easy way of selecting a specific value, avoids typos, and would provide warnings if due to code changes, that variable no longer exists (missing parameter)

    It would in effect, work like a enum selector dropdown that is currently created for enums, however this doesn’t require things to be enums, just that the values are provided in advance somehow, which is great for integrating with other custom editor tools.

    #8759
    Async0x42
    Participant

    I’ll post this in the same thread, as it’s related to Custom Tasks…

    Another great feature, allowing more complex Tasks without cluttering up the view, is to have an attribute that requires the boolean value of another field for it to be displayed, otherwise it’s null.

    I.e.

    #8758
    Async0x42
    Participant

    Third request for making tasks! (maybe I should have picked a better thread title)

    An attribute to allow us to set a friendly name for a variable in the node view, i.e. instead of ‘scaleZoom’ (variable), it would display ‘Scale (Zoom)’

    [Text("Scale (Zoom)", SliderField(0.01f, 2)] public float scaleZoom = 1f;

    Basically, the Name attribute that’s already applied to the class name, but for variables.

    And lastly…. Have the SliderField accept ints in addition to floats would be good! I very lazily copy/pasted and edited a bit to make an IntSliderField, not exactly refined or anything, I just wanted it quickly working, but I think that’d be a good addition to the base NodeCanvas

    #8757
    Gavalakis
    Keymaster

    Hi,

    Ive added [SliderField] to accept and be possible to use with integers as well as the ability to use [Name] on top of variables and BBParameters.

    The [ShowIf] attribute can’t really work this way, because attributes can’t reference non-static members.

    I’ve also added AcceptableValues (I named the attribute RestrictValues though). Of course, for the same reason as above, this can’t work with providing some instance array, but rather values directly.

    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

    #8756
    Async0x42
    Participant

    Okay thanks! Those are good.

    I saw something like ShowIf from Advanced Inspector, but they were using a string to point to a method which would return true/false, so now I know there’s a coding reason behind that!

    I think their implementation required users to write a function for each comparison they wanted. So would it be possible to implement something similar to…

    [ShowIf("IsTrue(isAdvancedAI)") public float advancedAttackSpeed;

    In which, IsTrue is a built in method in NodeCanvas, but uses reflection to call it and pass in a boolean parameter to check the return value, to determine if it should be shown or not?

    It’s the best workaround that I can think of, what do you think?

    #8755
    Gavalakis
    Keymaster

    Hey 🙂

    It could be implemented like this:
    [ShowIf(“isAdvanecedAI”)]

    …where isAdvancedAI should be a boolean field, although it’s of course very error prone 🙂
    I could add this in the next version if you like. No problem 😉

    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

    #8754
    Async0x42
    Participant

    Yes if you could do that, it’d be great! For me at least, all of the bools will be within the same source, so the errors will be minimal I’d think. Hopefully this is useful for other people as well.

    Though, speaking of errors, two solutions I can think of are either NodeCanvas could display a red * with a tooltip on the canvas, beside the parameter, if the reflected name is unable to be found, or B) just output to the console that there’s an error in the node script (which may just do that by default with the reflection, I don’t know the details of it)

    P.S. Just curious, if/when Unity ever gets an updated version of .Net and has nameof support ( https://msdn.microsoft.com/en-us/magazine/dn802602.aspx ), would that solve this whole issue and allow us to do [ShowIf(isAdvancedAi)] without passing a string?

    #8753
    Gavalakis
    Keymaster

    Hey,

    Sure I will add with an error label in case of error that is.
    Regarding nameof, not really, since the attribute still can’t use an instance member 🙂

    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

    #8752
    Async0x42
    Participant

    Alright, thanks and thanks! I don’t like using strings for method/variable names either, but the alternative is more complicated for simple scripts, so this will do really nicely.

    #8751
    Async0x42
    Participant

    Hey, I came across Vexe Framework for Unity that provides some drawers, I noticed he sorted out a way to display a popup of string values using an attribute (his comment also says it can do non-static, but I haven’t checked it out).

    Source: https://github.com/vexe/VFW/blob/master/Assets/VFW%20Examples/Scripts/Attributes/PopupsExample.cs

    [PerItem, Popup("ItemsDB.getItemNames", CaseSensitive = false)]

    pulls from

    (Oh, I noticed a typo in GraphOwner.cs, enum EnableBahaviour should be EnableBehaviour)

    #8750
    Gavalakis
    Keymaster

    Hey,

    I could add pointing to a static property in the next version sure 🙂
    The comment in vexe Popup indicates that the class doesn’t have to be static. The member(property) still has to be though 🙂
    I will add this in the next update.

    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

    #8749
    Async0x42
    Participant

    Oh too bad, I saw that and since both were static thought he was referring to that! Pointing to a static property will be good enough though, thanks!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.