Value Reference Toggling - Scriptable Objects as Value Assets

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024

Комментарии • 25

  • @MrHandsy
    @MrHandsy 4 года назад +6

    The one asset I'd recommend regardless of project type. From prototype to production and regardless of genre. Supremely useful.
    Amazing!!!

  • @alejmc
    @alejmc 4 года назад +1

    Thanks a lot for this one. Really simple but so powerful.
    I also find it very useful if the value changes can be ‘observed’ optionally, don’t know what’s the best way, but I ended up manually doing a ‘ValueChanged’ event on them so that in the code that uses the ValueRefs, they can subscribe to events like “ColorRef.Changed += ChangeGraphicColorMethod”, subscribe-unsubscribe onEnable/OnDisable pairs (maybe not the best place for this).
    The idea is to use simple methods to react to changes instead of plaguing Update cycles with more crowded logic. Still can have a purpose for really complex logic, but the lift up could happen on the events first.
    Maybe something more clever can be done? Like an “ObservableReference” separate class or maybe built-in on the value reference base class... don’t know.

  • @larryp2206
    @larryp2206 3 года назад +1

    Awesome video, so useful. I learned a lot about C#/Odin programming working through this. I will note that the Tutorial Files link is incorrect, the link goes to 'Struct Value Drawers' instead of Value Reference Toggling (which unfortunately I cannot find).

    • @sirenix7891
      @sirenix7891  3 года назад +1

      Sorry about that. Looks like we didn't push all the files but you can find the Color Reference value scripts here:github.com/onewheelstudio/DevdogTutorialFiles/tree/c6e5c29956f0de20ba907c62ffb08707a5cfa1f9/ScriptableObjects/Color%20SOs

  • @DrHeinzDoofenshmirtz
    @DrHeinzDoofenshmirtz 3 года назад +2

    Really cool solution, but I have an issue.
    How do I apply Odin attributes to the different derived ValueAssets?
    For example, if I have a PercentileAsset where the value is a simple float. How do I give it a PropertyRange attribute from 0 to 1?
    Where should that attribute be placed?

    • @sirenix7891
      @sirenix7891  3 года назад

      Here's a response from the developers (I'm just the YT guy). It might be worth dropping by the Odin discord (link in any description) to get more detailed help.
      That's kinda tricky. It might be possible to make some kind of attribute processor that grabs attributes from the parent ValueAsset object, and moves them to the actual value property inside the class.

  • @jeffreyhersh908
    @jeffreyhersh908 2 года назад +1

    This is awesome. BTW is there a way to have the dropdown only display the icon until you click on it? Basically like if I did the editor via script and used the ImagePosition.ImageOnly property in a defined GUI style.

    • @ninosandlarz783
      @ninosandlarz783 Год назад

      If you find a way to do this share it with me, I'm quite interested.

    • @ninosandlarz783
      @ninosandlarz783 Год назад

      I ended up using a simple button to toggle on and off the useValue field. I used the following code for a nice and clean result :
      protected bool useValue = true;
      [HorizontalGroup("Reference", 30)]
      [Button(SdfIconType.ArrowLeftRight, Name = "")]
      protected void Switch()
      {
      useValue = !useValue;
      }

  • @a.technology1446
    @a.technology1446 4 года назад +1

    Cool

  • @Fuzzel
    @Fuzzel 4 года назад +1

    Instead of having a second field _assetReference, why not just use a property?
    protected TAsset AssetReference => assetReference;

    • @alejmc
      @alejmc 4 года назад

      It still not quite clear to me the need for the double reference... I think it was about having the ability edit it there directly but making the intention obvious? If you do what you mean with a ‘ShowInspector, InlineEditor’ and other attributes, I think it would display all the editing features and be editable right?

    • @TChrisBaker
      @TChrisBaker 4 года назад

      I didn't understand it either. I just hid it from the UI

    • @Fuzzel
      @Fuzzel 4 года назад +1

      @@alejmc The first field is there to have a regular field for a scriptable object to put in. The second field is there to render the inline editor instead of the field for the scriptable object.

    • @Salmonman0604
      @Salmonman0604 Год назад

      Pretty sure that the issue there is that unity can't serialize a custom property, it can only handle an autoproperty

  • @bluzenkk
    @bluzenkk 8 месяцев назад

    would be nice if there are more use case to justify the work needed to make this...

    • @alexgergely3930
      @alexgergely3930 7 месяцев назад

      Mainly useful for larger teams or more design oriented devs as this gives a lot of control from the editor. If you want the full benefits watch the talk he mentions, where Ryan Hipple actually explains how it is used in a succesful gamedev studio.
      Additionally, its a pretty alright alternative for singletons.

  • @mrstruijk
    @mrstruijk 3 года назад

    Hi there, great tutorial, very helpful! Quick question: the implicit operator doesn't seem to work for me. It allows me to return the valueRef._value (from the ValueReference script), but not the valueRef.value (from the ValueAsset script). What am I doing wrong? This doesn't work:
    public static implicit operator TValue(ValueReference valueRef)
    {
    return valueRef.value;
    }

    • @sirenix7891
      @sirenix7891  3 года назад

      This operator will only work on the type "ValueReference" if you want a similar operator for another type you can create a similar operator for that type.

  • @DarkNemesisUmbrella
    @DarkNemesisUmbrella 4 года назад

    With this asset it's possible to "keep/save" a list or an array of System . Object[] in the Editor?

    • @sirenix7891
      @sirenix7891  4 года назад

      Yes, with Odin serialization you can do that.

    • @DarkNemesisUmbrella
      @DarkNemesisUmbrella 4 года назад

      @@sirenix7891 is there a tutorial or guide to do that specifically?

    • @sirenix7891
      @sirenix7891  4 года назад

      If you scroll about halfway down on the link below, you there are a bunch of written tutorials on the Odin Serializer. Link: odininspector.com/tutorials
      Otherwise, jump on the Odin Discord and ping Tor or Mikkel. They should be able to answer any questions on the serializer.

  • @halivudestevez2
    @halivudestevez2 8 месяцев назад

    fckn complicated