Search Unity

Feedback Typed AssetReferenceT::editorAsset

Discussion in 'Addressables' started by AlkisFortuneFish, Aug 23, 2019.

  1. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Just a quick thing, during development of our UMA integration, it was quite nice to have direct access to a typed editorAsset without having to cast all over the place. Obviously, this is not required per se but it is nice to have.

    I just added the following to the top of AssetReferenceT:

    Code (CSharp):
    1.  
    2. #if UNITY_EDITOR
    3.         public new TObject editorAsset => base.editorAsset as TObject;
    4. #endif
    5.  
    Since AssetReference::editorAsset is a get-only property, I haven't found a problem hiding it with a strongly typed wrapper.
     
    SugoiDev likes this.
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    makes sense. I'll add it to the list. Also, I'm guessing we should probably make the base virtual, so you don't have to do
    public new
     
  3. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    That was my first thought too, but you can’t override the return type without hiding it with new, it’d need a different name than the base/untyped version.
     
    unity_bill likes this.