How to use System.Speech in Unity? - c#

I want to use System.Speech to implement a text-to-speech to my unity desktop application. I don't get how to implement the System.Speech. When I type using System.Speech; in my C# file, it gives error : The type or namespace name System.Speech could not be found (are you missing a using directive or an assembly reference?)
I have copy the System.Speech.dll from C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0 to the asset folder, but it doesn't work.
When I add it using Nuget, it says that it doesn't compatible with any framework.
Can someone explain how to add the reference, to make it works?
Thank you very much.

you cant use this assembly directly in Unity, you have to have a wrapper
you could find a solution Wrapper For unity

Related

Visual Studio Understands but Unity Doesn't?

I've installed the Microsoft.Identity.Client in Visual Studio and can now declare using Microsoft.Identity.Client; within the code. Visual Studio is happy. Unity, however, is not.
Assets\Scripts\AutoKhan.cs(8,17): error CS0234: The type or namespace name 'Identity' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
What must I do to make Unity similarly happy?
I have run into similar issues when using external libraries. Often there is a dll to add to your project because of how Unity compiles your project.
This may be useful.
How to use an external dll

Bitmap not found in System.Drawing in Unity3D

Maybe just an oversight on my part, but I can't make sense of this:
I have the reference to System.Drawing in my project tree within the references
I have the correct using statement using System.Drawing;
I can access other members of this namepace
According to the docs, bitmap should be within this namespace.
However, if I try use a bitmap, I get the following error:
Error CS0246 The type or namespace name 'Bitmap' could not be found
(are you missing a using directive or an assembly reference?)
VS19-IntelliSense suggests to install the package System.Drawing.Common, however if I do that, I get yet another error, stating:
The type name 'Bitmap' could not be found in the namespace
'System.Drawing'. This type has been forwarded to assembly
'System.Drawing.
How can I resolve this issue to actually use the Bitmap class?
Copy the System.Drawing.dll from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 into your Unity project folder. I put mine under Assets/Plugins/System.Drawing.dll.
This version will contain the Bitmap class. You will still have an error in the editor, but everything will compile fine and you should be able to use Bitmap in Visual Studio.
A problem you may now encounter when using certain types from this dll (e.g. Color, RectangleF) is that Unity gets confused between the 4.0 and 2.0 versions of the dll files. The only solution I found to resolve this is to change Api compatibility Level from .NET Standard 2.0 to 4.0 under Edit > Project Settings... > Player. .
If you choose not to do this, you will find that there is System.Drawing in the C:/Program Files/Unity/Hub/Editor/2020.2.0f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll. Removing this dll will cause Unity to complain until you restore it.
There are solutions suggesting to modify C:\Program Files\Unity\Hub\Editor\2020.2.0f1\Editor\Data\NetStandard\compat\2.0.0\shims\netfx\System.Drawing.dll or C:\Program Files\Unity\Hub\Editor\2020.2.0f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5\System.Drawing.dll, but I would advice against this as it would impact other projects using the same Unity version.

Namespace or type 'Twilio' could not be found

I'm trying to use the Twilio API in my unity project but when I try to build in unity I get the error: namespace or type 'Twilio' could not be found (are you missing using directive or reference?)
Now I've loaded the twilio package (v 5.27.2) through Visual studio and it works fine there its just Unity that can't seem to find it.
Can someone explain to me whats going on and how to fix this?
I've provided some screenshots showing the error,
code ,and Unity configuration settings
Your application code is compiled by Unity itself, not by Visual Studio. You need to make Unity aware of any external DLL libraries. To make Unity aware of an external DLL, just place it inside of the Assets directory in your Unity Project.

DLL not found in Hololens project. (are you missing a using directive or an assembly reference?)

I have created a Unity (2018.2.13f1) project, and I want to add a DLL to get information from an external device thru WiFi to plog information in the HoloLens.
I add the .dll file in the assets folder. When I create a script to get info form my costume package and plog it, it recognizes as a reference, and it builds alone.
but when taring to build in unity, it appears the following
I tried with other versions of unity, 2017.2.xx and 2017.4.xx but it appeases the same errors.
I'm currently trying to fix this problem too by following this tutorial.

Error after adding reference to my project(TlGallioAddOn.dll)

I have added the reference TlGallioAddOn.dll to our sample c# application. I have using that reference like using TlGallioAddOn;. When using that reference of that dll it shows the following error.
The type or namespace name 'TlGallioAddOn' could not be found (are you missing a using directive or an assembly reference?)
Could u all please help me to resolve that.
Right click the project in your Solution Explorer. Click 'Add Reference' then find your DLL. It will import the DLL and resolve the error.
Check the framework target of both projects.
Project defaults are now .NET 4.0 Client. If you've compiled the addon project against .NET 4.0 (Full), you'll need to modify the project for which you're adding a reference to use .NET 4.0 (Full) also.

Categories