Search Unity

The non-generic method 'AssetReference.Instantiate" error

Discussion in 'Addressables' started by stevenchristian20, Mar 8, 2020.

  1. stevenchristian20

    stevenchristian20

    Joined:
    Dec 23, 2019
    Posts:
    29
    I was watching this video:


    And thought it would be simple to follow. When I get to

    using UnityEngine.SceneManagement;
    using UnityEngine;
    using System.Collections.Generic;
    using UnityEngine.AddressableAssets;
    using UnityEngine.ResourceManagement;

    public class GameManager1 : MonoBehaviour
    {
    //public GameObject chapterPrefab;
    public AssetReference chapterPrefab;


    void Start()
    {
    chapterPrefab.Instantiate<GameObject>();
    }

    }


    I get an error: Assets\Scripts\GameManager1.cs(28,23): error CS0308: The non-generic method 'AssetReference.Instantiate(Vector3, Quaternion, Transform)' cannot be used with type arguments

    Why is this happening? All I am trying to do is build out some content in a scene with the Vuforia SDK and Image targets, nest each collection of image targets and AR content in a prefab, make it addressable, label the addressable "AR Pages", have the "chapterPrefab" AssetReference load all the addressable prefabs with that label into the scene and play the content on the respective Image Target when it is recognized.

    I know this isn't the Vuforia forum, but I had to put my request in context.
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    We'll flag this for the team to take a look at. Which version of the package and editor are you using?
     
  3. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    The non-async methods are deprecated. You should instead use
    InstantiateAsync<GameObject>
    .
     
  4. stevenchristian20

    stevenchristian20

    Joined:
    Dec 23, 2019
    Posts:
    29
    I am using Addressables version 1.1.10 and Unity 2019.3.4f1
     
  5. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Like @ProtoTerminator said, I would change to InstantiateAsync because the synchronous API is deprecated. Also you might try updating to the most recent version of the package. At the time of writing the most up to date version is 1.6.2
     
    stevenchristian20 likes this.