Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[BUG] Assigning Sprite Object to AssetReferenceSprite.editorAsset fails

Discussion in 'Addressables' started by CapnCromulent, Jan 4, 2019.

  1. CapnCromulent


    Sep 7, 2010
    I'm building an editor tool that automatically assigns AssetReferences within ScriptableObjects, and it looks like there's a bug when trying to do:
    Code (CSharp):
    1. data.spriteReference = new AssetRefereceSprite()
    2. data.spriteReference.editorAsset = AssetDatabase.LoadAssetAtPath<Sprite>(spritePath);
    In the property setter, it trips up on
    Code (CSharp):
    1. var type = AssetDatabase.GetMainAssetTypeAtPath(path);
    2. if (!ValidateType(type))
    3. {
    4.     Addressables.LogWarningFormat("Invalid type for AssetReference {0}, path = '{1}'.", type.FullName, path);
    5. }
    because the MainAssetTypeAtPath is Texture2D, and ValidateType fails. Is it intentional to use GetMainAssetTypeAtPath? Why not just get the type of the actual object?
  2. unity_bill


    Unity Technologies

    Apr 11, 2017
    Good discovery. There are some changes to how AssetReferences restrict assignment coming in the next release. I'll try to slip in an improvement for this as well.
    MNNoxMortem likes this.