英文:
Testing ClarifAI and seeing "The type or namespace name 'Clarifai' could not be found" in the Unity console
问题
我执行了以下步骤来测试在一个新项目中使用ClarifAI图像识别,但出现了问题。以下是我所采取的步骤:
- 创建了一个新的Unity 2020.3.8f1项目。
- 创建了一个名为AItest的测试C#脚本,并在Visual Studio 2022中打开它。
- 使用Nuget包管理器运行'Install-Package ClarifaiGrpc'(参考https://github.com/Clarifai/clarifai-csharp-grpc),运行正常。
- 添加了代码(按照https://github.com/Clarifai/clarifai-csharp-grpc中的说明)。
在Visual Studio中,代码没有问题,但在Unity控制台中,我看到:
以下是代码:
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}"}
};
}
}
通常情况下,当我看到这个错误时,使用语句下面会有下划线,但这次没有。我也尝试卸载和重新安装ClarifaiGrpc,但没有帮助。
我已经有一个API密钥,一旦我解决了这些错误,就会在代码中将YOUR_PERSONAL_TOKEN替换为它。
非常感谢您提供的帮助,谢谢。
1: https://i.stack.imgur.com/Ant7f.png
英文:
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:
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.
答案1
得分: 1
我不确定NuGet包是否与Unity完全兼容?您可以查看https://stackoverflow.com/questions/53447595/nuget-packages-in-unity。
英文:
I'm not sure nuget package are fully compatible with Unity? You may want to look at https://stackoverflow.com/questions/53447595/nuget-packages-in-unity
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论