This guide explains how to import Poly assets using the Poly Toolkit for Unity.
Set up your development environment
Create a project
In Unity, select File > New Project.
Name your project HelloPoly, leave 3D mode selected, and click Create Project.
Click the menu Assets > Import package > Custom package..., then select
.unitypackage file you downloaded. Import everything in the package.
The Poly Asset Browser window opens automatically after installation. You can also open this window by selecting Poly > Browse assets from the menu.
Import at edit time
To import assets at edit time, use the Poly Asset Browser window (available by selecting Poly > Browse assets from the menu).
Use the interface to find an asset either by searching for keywords or browsing by categories. After you locate an asset, review the Import Options (shown below) and click Import into Project to import it as a Prefab.
Import at run time
The Poly Toolkit includes an example called HelloPoly
Assets/PolyToolkit/ExampleScenes) that demonstrates how to
import an asset at runtime with the Poly Toolkit API.
This section describes how to run the example.
Get an API key
If you aren't already signed in, you'll be asked to sign in with a Google account or create one.
In the dialog box, either select an existing API Console project or create a new project
Click Next to enable the Poly API and receive your API key. The API key is used to identify your app and enforce usage limits.
You can also create, view, and manage your projects, APIs, and API keys at the Google APIs Console.
Run the example
Enter the API key. In Unity menu, select Poly > Poly Toolkit Settings. The Poly Toolkit settings (shown below) will appear in the Inspector window. If it does not appear, make sure the inspector window is already visible. Then, select the Runtime section, and paste your API key.
Open the scene. In the Project window, find and open the
Now run the project by pressing the Play button in Unity.
After a small delay while the example queries the Poly API, you should see a model of a piano at the center of the scene.
To learn more about using the Poly Toolkit, see the Poly Toolkit Guide.
Common import issues
If you see errors after importing Poly Toolkit, check if they correspond to one of the common cases below:
Auto-updating obsolete APIs: If you are using Unity 2017 or newer, you may be prompted to automatically upgrade API calls. In this case, make a backup of your project, then click the button labeled "I made a backup. Go ahead." to automatically upgrade Poly Toolkit for compatibility with your version of Unity.
Compilation errors due to the
unsafekeyword: Some combinations of Unity version and C# compiler don't allow
unsafeblocks in C# code by default, and these blocks are required by Poly Toolkit for performance reasons. If you see compilation errors related
unsafeblocks, create the files
Assetsfolder with each file containing the single line
-unsafe(note the leading dash). This tells the compiler to allow
unsafeblocks in code.
Mobile build issues
If your project is configured to build using the IL2CPP script backend (default for mobile platforms like iOS), make sure that you have .NET 2.0 selected as your API compatibility level in Player Settings. The default, .NET 2.0 Subset, is incompatible with Poly Toolkit and may cause runtime errors.