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
Parameter | Type | Description |
---|---|---|
model | MediaModel | Class contains the metadata and files for Media from the Svrf API. |
options | SvrfModelOpitons | Advanced options for customizing how 3D models are rendered. |
options.ShaderOverride | Shader | Apply a custom shader to the model. (Optional, default: null ) |
options.WithOccluder | bool | Use the default occluder that is provided by the model. (Optional, default: true ) |
gameObject | GameObject | Attach 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.