Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ai.fxn.fxn3d

fxnai1.1kApache-2.00.0.39

Run AI prediction functions in Unity Engine.

fxn, natml, machine learning, ml, aritificial intelligence, ai, computer vision, opencv, android, ios, macos, windows, coreml, nnapi, directml, tensorflow, pytorch, torch, llm

readme

Function for Unity Engine

function logo

Run Python functions (a.k.a "predictors") locally in your Unity apps and games, with full GPU acceleration and zero dependencies. In a few steps:

Installing Function

Add the following items to your Unity project's Packages/manifest.json:

{
  "scopedRegistries": [
    {
      "name": "Function",
      "url": "https://registry.npmjs.com",
      "scopes": ["ai.fxn"]
    }
  ],
  "dependencies": {
    "ai.fxn.fxn3d": "0.0.39"
  }
}

Retrieving your Access Key

Head over to fxn.ai to create an account by logging in. Once you do, generate an access key:

generate access key

Then add it to your Unity project in Project Settings > Function:

add access key to Unity

Making a Prediction

First, create a Function client:

using Function;

// Create a Function client
var fxn = FunctionUnity.Create();

Then make a prediction:

// Make a prediction
var prediction = await fxn.Predictions.Create(
    tag: "@fxn/greeting",
    inputs: new () { ["name"] = "Roberta" }
);
// Log the result
Debug.Log(prediction.results[0]);

Requirements

  • Unity 2022.3+

Supported Platforms

  • Android API Level 24+
  • iOS 14+
  • macOS 12+ (Apple Silicon and Intel)
  • Windows 10+ (64-bit only)
  • WebGL:
    • Chrome 91+
    • Firefox 90+
    • Safari 16.4+

Thank you very much!