Search Unity

0.5.3 - Compile error on Preload Dependencies.

Discussion in 'Addressables' started by CC9, Jan 3, 2019.

  1. CC9

    CC9

    Joined:
    Mar 20, 2013
    Posts:
    3
    This compiled in 0.4.6 but seems to have an issue in 0.5.3.

    error CS0411: The type arguments for method `UnityEngine.AddressableAssets.Addressables.PreloadDependencies<TObject>(System.Collections.Generic.IList<object>, System.Action<UnityEngine.ResourceManagement.IAsyncOperation<TObject>>, UnityEngine.AddressableAssets.Addressables.MergeMode)' cannot be inferred from the usage. Try specifying the type arguments explicitly

    Code (CSharp):
    1.         List<object> dependencies = new List<object>();
    2.         var operation2 = Addressables.PreloadDependencies(tag, null);
    3.         operation2.Completed += (res) =>
    4.         {
    5.             if (onComplete != null)
    6.                 onComplete();
    7.             Debug.Log("Loaded dependencies for " + tag);
    8.             dependencies.AddRange(res.Result);
    9.             careerAddressables.Add(tag, dependencies);
    10.         };
    11.         yield return operation2;
    12.         operation2.Release();


    I was passing in just a string to load all of the assets with a specific label (tag). The compile error I was receiving was about inferring type arguments, though it was constantly referencing the IList<Object> overload. I'm having the same compile issue with the Addressable Assets Demo project as well.

    Visual studio doesn't seem to be able to find the Addressables namespace so I can't dig further into how I need to restructure the method. (I've tried deleting the vs folder and having it recompile the solution).

    Any suggestions would be greatly appreciated!

    Unity Version: 2018.2.14f1.
    Addressables : 0.5.3
     
    Last edited: Jan 3, 2019
    skwsk8 likes this.
  2. skwsk8

    skwsk8

    Joined:
    Jul 6, 2014
    Posts:
    9
    Running into the same issue. What namespace does TObject live in?
     
  3. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    165
    Try changing
    List<object> dependencies = new List<object>();
    to
    List<UnityEngine.Object> dependencies = new List<UnityEngine.Object>();


    The compiler is probably seeing the lowercase version as System.Object due to your usings.

    Edit, actually, it's how you are passing in null to the PreloadDependencies call. You need to provide a type in this case so change
    var operation2 = Addressables.PreloadDependencies(tag, null);
    to
    var operation2 = Addressables.PreloadDependencies<object>(tag, null);
     
    Last edited: Jan 11, 2019