Search code examples
c#visual-studiounity-game-engineclarifai

Testing ClarifAI and seeing "The type or namespace name 'Clarifai' could not be found" in the Unity console


I performed the following steps to test ClarifAI image recognition in a new project and am having issues. These are the steps I took:

  • Created a new Unity 2020.3.8f1 project
  • Created a test C# script called AItest and opened it in Visual Studio 2022
  • Used the Nuget Package Manager to run 'Install-Package ClarifaiGrpc' (per https://github.com/Clarifai/clarifai-csharp-grpc) which ran ok.
  • Added code (per instructions at https://github.com/Clarifai/clarifai-csharp-grpc)

Visual Studio gives no issues with the code, however, in the Unity console I see: 

enter image description here  

Here is the code:

using UnityEngine;
using System;
using System.Collections.Generic;
using Clarifai.Api;
using Clarifai.Channels;
using Grpc.Core;
using StatusCode = Clarifai.Api.Status.StatusCode;
using UnityEngine.Profiling.Memory.Experimental;

public class AItest : MonoBehaviour
{
    void Start()
    {
        var client = new V2.V2Client(ClarifaiChannel.Grpc());

        var metadata = new Metadata
        {
            {"Authorization", "Key {YOUR_PERSONAL_TOKEN}"}
        };
    }
}

Usually, when I see that error, I also see underlines in the using statements but not this time. I also tried uninstalling and reinstalling ClarifaiGrpc but that didn't help.

I already have an API key and will replace YOUR_PERSONAL_TOKEN with it in the code when I can overcome these errors.

Any assistance to resolve this would be greatly appreciated, thank you.


Solution

  • I'm not sure nuget package are fully compatible with Unity? You may want to look at NuGet packages in Unity