Skip to content
On this page

Get to use

Retrieve Default List of Models

Example

csharp
async void Start()
    {
        if(_searchMenu == null)
        {
            Debug.LogError("_searchMenu is not set");
        }
        _searchMenu.Init(this.gameObject);
        var modelList = await API.GetDefaultModelList();
        FillModelList(modelList);
    }

Functions

csharp
public static async Task<List<SketchfabModel>> GetDefaultModelList(Action OnLoading=null);
public static async Task<List<SketchfabModel>> GetDefaultModelList(UnityWebRequestSketchfabModelList.Parameters param, Action OnLoading = null);

Input

Details
ClassInputDescription
UnityWebRequestSketchfabModelList.Parametersparamoptional, if no specific, the global search parameter will be used
ActiononLoadoptional, callback when loading model

Output

Details
ClassOutputDescription
List<sketchfabModel>SketchfabModelsEach model contains Uid, Name, IsDownloadable, Description , FaceCount, VertexCount, and Thumbnail

Retrieve List of Purchased Models

csharp
public static async Task<List<SketchfabModel>> GetPurchasedModelList();

Retrieve List of Liked Models

csharp
public static async Task<List<SketchfabModel>> GetMyModelList();

Retrieve List of Models from Collection

csharp
public static async Task<List<SketchfabCollection>> GetMyCollectionList();
public static async Task<List<SketchfabModel>> GetCollectionModelList(string id)

Input

Details
ClassInputDescription
stringidcollection id which is retrieved from SketchfabCollection

Search Model

Example

csharp
public async void Search()
    {
        if (searchField == null)
        {
            Debug.LogError("inputField is not set (NULL)");
            return;
        }
        UnityWebRequestSketchfabModelList.Parameters param = _searchMenu.GetParameters();
        param.downloadable=true;
        param.count = API.Instance.LengthOfModelList;
        string query = searchField.text;
        var models =await API.SearchModel(query,param);
        FillModelList(models);
    }

Function

csharp
public static async Task<List<SketchfabModel>> SearchModel(string query,Action OnSearching=null);
public static async Task<List<SketchfabModel>> SearchModel(string query, UnityWebRequestSketchfabModelList.Parameters param, Action OnSearching = null);

Input

Details
ClassInputDescription
stringquerykeyword used to search model, if empty, list of random models will be given
UnityWebRequestSketchfabModelList.Parametersparamoptional, if no specific, the global search parameter will be used
ActiononSearchingoptional, callback when searching model

Output

Details
ClassOutputDescription
List<sketchfabModel>SketchfabModelsEach model contains Uid, Name, IsDownloadable, Description , FaceCount, VertexCount, and Thumbnail

Download Model

Example

csharp
public override async void Interact()
    {
        background.sprite = _loadSprite;
        var gameObject = await API.ImportModelByID(_model.Uid);
        if (gameObject != null)
        {
            Debug.Log("get the object success");
            //preprocessing
            Tools.PreprocessGameObject(gameObject);
            background.sprite = _sucessSprite;
        }
        else
        {
            Debug.LogWarning("unable to get the object");
            background.sprite = _errorSprite;
        }
        //
        this.gameObject.SetActive(true);
        this.StartCoroutine(Tools.DelayExecute(1f, () =>
        {
            Debug.Log("Delay");
            background.sprite = _defaultSprite;
        }));
    }

Function

csharp
public async static Task<GameObject> ImportModelByID(string guid, Action OnImporting =null);

Input

Details
ClassInputDescription
stringguidid of the model
ActiononImportoptional, callback when importing model

Output

Details
ClassOutputDescription
GameObjectgameObject