Svrf API Docs

Unity Utilities

GetSvrfModelAsync()

GetSvrfModelAsync() can be used to render a 3D model at runtime in Unity.

Syntax

using System.Linq;
using Svrf.Models.Http;
using Svrf.Models.Media;
using Svrf.Unity.Models;
using UnityEngine;
SvrfApi api = new SvrfApi();
MediaRequestParams requestOptions = new MediaRequestParams {IsFaceFilter = true};
MultipleMediaResponse trendingResponse = await api.Media.GetTrendingAsync(requestOptions);
MediaModel model = trendingResponse.Media.First();
SvrfModelOptions options = new SvrfModelOptions
{
ShaderOverride = Shader.Find("Svrf/LightEstimation"),
WithOccluder = true,
};
GameObject svrfModel = await SvrfModel.GetSvrfModelAsync(model, options);

Parameters

ParameterTypeDescription
modelMediaModelClass contains the metadata and files for Media from the Svrf API.
optionsSvrfModelOpitonsAdvanced options for customizing how 3D models are rendered.
options.ShaderOverrideShaderApply a custom shader to the model. (Optional, default: null)
options.WithOccluderboolUse the default occluder that is provided by the model. (Optional, default: true)
gameObjectGameObjectAttach a 3D model to an existenting GameObject instead of creating a new one. (Optional, default: null)

Return Value

This method is asynchronous and returns Task<GameObject> where GameObject instance is a newly created GameObject or the GameObject that you provided as the 3rd argument.