private void ImportResults(PolyStatusOr <PolyListAssetsResult> result) { // Set options for import so the assets aren't crazy sizes PolyImportOptions options = PolyImportOptions.Default(); options.rescalingMode = PolyImportOptions.RescalingMode.FIT; options.desiredSize = 5.0f; options.recenter = true; // List our assets List <PolyAsset> assetsInUse = new List <PolyAsset>(); // Loop through the list and display the first 3 for (int i = 0; i < Mathf.Min(5, result.Value.assets.Count); i++) { // Import our assets into the scene with the ImportAsset function PolyApi.Import(result.Value.assets[i], options, ImportAsset); PolyAsset asset = result.Value.assets[i]; assetsInUse.Add(asset); //attributionsText.text = PolyApi.GenerateAttributions(includeStatic: false, runtimeAssets: assetsInUse); } string attribution = PolyApi.GenerateAttributions(includeStatic: false, runtimeAssets: assetsInUse); InterfaceManager.GetInstance().AddMessageToBox(attribution); }
// Callback invoked when the featured assets results are returned. private void ListAssetsCallback(PolyStatusOr <PolyListAssetsResult> result) { if (!result.Ok) { Debug.LogError("Failed to get featured assets. :( Reason: " + result.Status); statusText.text = "ERROR: " + result.Status; return; } Debug.Log("Successfully got featured assets!"); statusText.text = "Importing..."; // Set the import options. PolyImportOptions options = PolyImportOptions.Default(); // We want to rescale the imported meshes to a specific size. options.rescalingMode = PolyImportOptions.RescalingMode.FIT; // The specific size we want assets rescaled to (fit in a 1x1x1 box): options.desiredSize = 1.0f; // We want the imported assets to be recentered such that their centroid coincides with the origin: options.recenter = true; // Now let's get the first 5 featured assets and put them on the scene. List <PolyAsset> assetsInUse = new List <PolyAsset>(); for (int i = 0; i < Mathf.Min(5, result.Value.assets.Count); i++) { // Import this asset. PolyApi.Import(result.Value.assets[i], options, ImportAssetCallback); assetsInUse.Add(result.Value.assets[i]); } // Show attributions for the assets we display. attributionsText.text = PolyApi.GenerateAttributions(includeStatic: true, runtimeAssets: assetsInUse); }
public string GetAttributionsString() { string msg = ""; if (downloadedPolyAssets.Count > 0) { msg += PolyApi.GenerateAttributions(true, downloadedPolyAssets); } if (downloadedImageUrls.Count > 0) { if (msg != "") { msg += "\n"; } msg += GenerateImageAttributions();; } return(msg); }