PolyToolkit. PolyApi
This is the main entry point for the Poly Toolkit Runtime API.
Summary
This class covers:
- Authentication and properties of the signed-in user.
- Wrappers around the Poly REST API endpoints.
- Importing assets and thumbnails.
- Managing the cache of assets.
Properties |
|
---|---|
AccessToken
|
static string
Returns the current user's access token, if a user is authenticated, or null if not.
|
IsAuthenticated
|
static bool
Returns whether or not a user is currently authenticated.
|
IsAuthenticating
|
static bool
Returns whether or not we are currently in the process of authenticating.
|
IsInitialized
|
static bool
Returns whether or not the API is initialized.
|
RefreshToken
|
static string
Returns the current user's refresh token, if a user is authenticated, or null if not.
|
UserIcon
|
static Sprite
Returns the current user's profile icon, if a user is authenticated, or null if not.
|
UserName
|
static string
Returns the current user's display name, if a user is authenticated, or null if not.
|
Public static functions |
|
---|---|
Authenticate(bool interactive, Action< PolyStatus > callback)
|
void
Attempts to authenticate a user.
|
Authenticate(string accessToken, string refreshToken, Action< PolyStatus > callback)
|
void
Alternative form of Authenticate() that allows usage of existing auth tokens.
|
CancelAuthentication()
|
void
Cancels the current authentication flow, if there's one in progress.
|
ClearCache()
|
void
Clears the local web cache.
|
FetchFormatFiles(PolyAsset asset, PolyFormatType format, FetchFormatFilesCallback callback)
|
void
Retrieves information about the given asset in the given format, then calls the given callback.
|
FetchThumbnail(PolyAsset asset, FetchThumbnailCallback callback)
|
void
Fetches the thumbnail for the given asset.
|
GenerateAttributions(bool includeStatic, List< PolyAsset > runtimeAssets)
|
string
Generates a list of attribution information of each asset passed, including the names of the authors and links to the original creations.
|
GetAsset(string name, GetAssetCallback callback)
|
void
Gets an asset by name (id).
|
Import(PolyAsset asset, PolyImportOptions options, ImportCallback callback)
|
void
Imports the given asset as a GameObject.
|
Init(PolyAuthConfig? authConfig, PolyCacheConfig? cacheConfig)
|
void
Initializes the Poly Toolkit runtime API.
|
ListAssets(PolyListAssetsRequest request, ListAssetsCallback callback)
|
void
Requests a listing of assets according to the specified parameters.
|
ListLikedAssets(PolyListLikedAssetsRequest request, ListAssetsCallback callback)
|
void
Requests a listing of liked assets according to the specified parameters.
|
ListUserAssets(PolyListUserAssetsRequest request, ListAssetsCallback callback)
|
void
Requests a listing of the logged-in user's own assets according to the specified parameters.
|
SignOut()
|
void
Signs out, deleting the current authentication token.
|
Public functions |
|
---|---|
FetchFormatFilesCallback(PolyAsset asset, PolyStatus status)
|
delegate void
Delegate type for the callback of FetchFormatFiles
|
FetchThumbnailCallback(PolyAsset asset, PolyStatus status)
|
delegate void
Delegate type for the callback of FetchThumbnail.
|
GetAssetCallback(PolyStatusOr< PolyAsset > result)
|
delegate void
Delegate type for the callback of GetAsset.
|
ImportCallback(PolyAsset asset, PolyStatusOr< PolyImportResult > result)
|
delegate void
Delegate type for the callback of Import.
|
ListAssetsCallback(PolyStatusOr< PolyListAssetsResult > result)
|
delegate void
Delegate type for the callback of ListAssets.
|
Properties
AccessToken
static string AccessToken
Returns the current user's access token, if a user is authenticated, or null if not.
IsAuthenticated
static bool IsAuthenticated
Returns whether or not a user is currently authenticated.
IsAuthenticating
static bool IsAuthenticating
Returns whether or not we are currently in the process of authenticating.
IsInitialized
static bool IsInitialized
Returns whether or not the API is initialized.
RefreshToken
static string RefreshToken
Returns the current user's refresh token, if a user is authenticated, or null if not.
UserIcon
static Sprite UserIcon
Returns the current user's profile icon, if a user is authenticated, or null if not.
UserName
static string UserName
Returns the current user's display name, if a user is authenticated, or null if not.
Public static functions
Authenticate
void Authenticate( bool interactive, Action< PolyStatus > callback )
Attempts to authenticate a user.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Authenticate
void Authenticate( string accessToken, string refreshToken, Action< PolyStatus > callback )
Alternative form of Authenticate() that allows usage of existing auth tokens.
Use this method only if you are implementing your own authentication/authorization flow, and need to provide Poly Toolkit with tokens to use. This method should be used INSTEAD of Authenticate() and will have the same effect, except that instead of launching the auth flow, the provided tokens will be used instead.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
CancelAuthentication
void CancelAuthentication()
Cancels the current authentication flow, if there's one in progress.
Does nothing if there is no authentication flow in progress.
ClearCache
void ClearCache()
Clears the local web cache.
This is asynchronous (the cache will be cleared in the background).
FetchFormatFiles
void FetchFormatFiles( PolyAsset asset, PolyFormatType format, FetchFormatFilesCallback callback )
Retrieves information about the given asset in the given format, then calls the given callback.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
FetchThumbnail
void FetchThumbnail( PolyAsset asset, FetchThumbnailCallback callback )
Fetches the thumbnail for the given asset.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
GenerateAttributions
string GenerateAttributions( bool includeStatic, List< PolyAsset > runtimeAssets )
Generates a list of attribution information of each asset passed, including the names of the authors and links to the original creations.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
GetAsset
void GetAsset( string name, GetAssetCallback callback )
Gets an asset by name (id).
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Import
void Import( PolyAsset asset, PolyImportOptions options, ImportCallback callback )
Imports the given asset as a GameObject.
This includes fetching any necessary files and importing them. The end result will be a GameObject that represents the imported asset. It will be placed at the origin with identity rotation and scale.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
Init
void Init( PolyAuthConfig? authConfig, PolyCacheConfig? cacheConfig )
Initializes the Poly Toolkit runtime API.
This will be called by PolyToolkitManager on its Awake method, you shouldn't need to call this method directly.
ListAssets
void ListAssets( PolyListAssetsRequest request, ListAssetsCallback callback )
Requests a listing of assets according to the specified parameters.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
ListLikedAssets
void ListLikedAssets( PolyListLikedAssetsRequest request, ListAssetsCallback callback )
Requests a listing of liked assets according to the specified parameters.
Currently, only the logged-in user's own likes are supported.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
ListUserAssets
void ListUserAssets( PolyListUserAssetsRequest request, ListAssetsCallback callback )
Requests a listing of the logged-in user's own assets according to the specified parameters.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
SignOut
void SignOut()
Signs out, deleting the current authentication token.
Public functions
FetchFormatFilesCallback
delegate void FetchFormatFilesCallback( PolyAsset asset, PolyStatus status )
Delegate type for the callback of FetchFormatFiles
Details | |||||
---|---|---|---|---|---|
Parameters |
|
FetchThumbnailCallback
delegate void FetchThumbnailCallback( PolyAsset asset, PolyStatus status )
Delegate type for the callback of FetchThumbnail.
If this callback reports success, then the thumbnail will be available in the asset's PolyAsset.thumbnailTexture field.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
GetAssetCallback
delegate void GetAssetCallback( PolyStatusOr< PolyAsset > result )
Delegate type for the callback of GetAsset.
Details | |||
---|---|---|---|
Parameters |
|
ImportCallback
delegate void ImportCallback( PolyAsset asset, PolyStatusOr< PolyImportResult > result )
Delegate type for the callback of Import.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
ListAssetsCallback
delegate void ListAssetsCallback( PolyStatusOr< PolyListAssetsResult > result )
Delegate type for the callback of ListAssets.
Details | |||
---|---|---|---|
Parameters |
|