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

[0.3.5-preview, Bug] AssetReferences serialized in structs or subassets are not visible.

Discussion in 'Addressables' started by james7132, Sep 7, 2018.

  1. james7132

    james7132

    Joined:
    Mar 6, 2015
    Posts:
    166
    Code (CSharp):
    1. Error rendering drawer for AssetReference property Palletes.Array.data[2].Portrait.
    The source code that leads to this error.
    Code (CSharp):
    1. [Serializable]
    2. public struct CharacterPallete {
    3.   public AssetReference Portrait;
    4.   public AssetReference Prefab;
    5. }
    6.  
    7. public class CharacterData : ScriptableObject {
    8.  
    9.   public AssetReference Icon;
    10.   public CharacterPallete[] Palletes;
    11.  
    12. }
    The editor UI is not drawn at all, and a blank region is shown:

    upload_2018-9-7_3-27-57.png

    Unity 2018.2.0f2, .NET 4.x Equivalent
     
  2. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Error rendering drawer for AssetReference property Reference List.Array.data[0].

    I have run into this bug as well with a List<AssetReferenceGameObject>
    2018.2.6f1, .NET 4.x Equivalent and Addressable Assets 0.3.5

    The problem is in the
    GetActualObjectForSerializedProperty<T>
    method in AssetReferenceDrawer.cs

    I've placed 2 debugs but it does not seem to recognize my List<T> as an array.
    it debugs "Not Array Type".
    When I changed List<T> into an array it did work.

    But a List / Array of classes containing an AssetReference. That will still fail.

    Code (CSharp):
    1. internal static class SerializedPropertyExtensions
    2.     {
    3.         public static T GetActualObjectForSerializedProperty<T>(this SerializedProperty property, System.Reflection.FieldInfo field) where T : class
    4.         {
    5.             try
    6.             {
    7.                 if (property == null || field == null)
    8.                     return null;
    9.                 var serializedObject = property.serializedObject;
    10.                 if (serializedObject == null)
    11.                 {
    12.                     return null;
    13.                 }
    14.                 var targetObject = serializedObject.targetObject;
    15.                 var obj = field.GetValue(targetObject);
    16.                 if (obj == null)
    17.                 {
    18.                     return null;
    19.                 }
    20.                 T actualObject = null;
    21.                 if (obj.GetType().IsArray)
    22.                 {
    23.                     Debug.Log(property.propertyPath);
    24.                     var index = Convert.ToInt32(new string(property.propertyPath.Where(c => char.IsDigit(c)).ToArray()));
    25.                     actualObject = ((T[])obj)[index];
    26.                 }
    27.                 else
    28.                 {
    29.                     Debug.Log("Not Array Type");
    30.                     actualObject = obj as T;
    31.                 }
    32.                 return actualObject;
    33.             }
    34.             catch
    35.             {
    36.                 return null;
    37.             }
    38.         }
    39.     }
    Like this it will fail.
    Error rendering drawer for AssetReference property Reference List.Array.data[0].Reference Object.

    Code (CSharp):
    1.     public References[] ReferenceList;
    2.  
    3.     [Serializable]
    4.     public class References
    5.     {
    6.         public AssetReferenceGameObject ReferenceObject;
    7.     }
     
    Last edited: Sep 7, 2018
  3. takuyahimeji

    takuyahimeji

    Joined:
    Feb 26, 2016
    Posts:
    4
    Me too.
    I hope for an immediate bug fix.
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Thanks for the report, I've opened a bug in our system about it.

    -Bill