Run AI prediction functions in Unity Engine.
npm install ai.fxn.fxn3dRun Python functions (a.k.a "predictors") locally in your Unity apps and games, with full GPU acceleration and zero dependencies. In a few steps:
Packages/manifest.json:json
{
"scopedRegistries": [
{
"name": "Function",
"url": "https://registry.npmjs.com",
"scopes": ["ai.fxn"]
}
],
"dependencies": {
"ai.fxn.fxn3d": "0.0.41"
}
}
`Retrieving your Access Key
Head over to fxn.ai to create an account by logging in. Once you do, generate an access key:Then add it to your Unity project in
Project Settings > Function:Making a Prediction
First, create a Function client:
`csharp
using Function;// Create a Function client
var fxn = FunctionUnity.Create();
`Then make a prediction:
`csharp
// Make a prediction
var prediction = await fxn.Predictions.Create(
tag: "@fxn/greeting",
inputs: new () { ["name"] = "Roberta" }
);
// Log the result
Debug.Log(prediction.results[0]);
``___
Thank you very much!