I'm trying to set up a basic UWP project in Unity and use parts of the Windows namespace.*
However, no matter which part of the Windows namespace I try to import in my script, I always get
CS0246: The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
Build support both for Windows and UWP is set up in Visual Studio and Unity and Windows 10 SDK (10.0.19041.0) is installed. Any other ideas how to fix this?
Based on https://forum.unity.com/threads/windows-storage-is-missing-when-building-for-uwp-hololens.541415/ I would have assumed that Windows is available in Unity for UWP as they were able to fix it there?
Thanks
*In the long run, I am trying to use 'Windows.Devices.Input.Preview' to access Gaze Input in a project that also uses Vuforia and thus needs to be UWP. Other tips on how to combine Gaze Tracking and Marker recognition in Unity are also welcome.
The Windows namespace in Unity is made for Windows PC build only. It won't work for other systems. On the top of the script try to add a
#if UNITY_STANDALONE_WIN
You should add the whole declaration like
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
Use SpeechRecognitionEngine class
#endif
If you are building for android or ios you will need also to add:
#if UNITY_ANDROID
Use SpeechRecognizer class
#endif
#if UNITY_IOS
Use SFSpeechRecognizer class
#endif
Related
Hi I have some C# code in a .NET class library that I wrote a while back. If I want to reference that code in a Unity script (Unity 2018.4.19f1 if that matters), how do I go about that?
If I add a project reference to my Unity Assembly-CSharp project in Visual Studio, it doesn't seem to work. I get;
Script.cs(3,7): error CS0246: The type or namespace name
'other-project-namespace' could not be found (are you missing a using
directive or an assembly reference?)
Does the class .NET class library need to be target a particular framework/platform? Ideally I'd like to use the same library across platforms if possible.
you need to build it, then it gave you a DLL file
import that in unity and use it
I'm trying to set up a brand new Xamarin Android project where I can use Xamarin.Forms (with .NET Standard 2.0) for the UI and can use Xamarin Live Player to preview XAML/run it. I've been getting a strange error that I don't know how to resolve.
I create a New Project > Cross-Platform App (Xamarin) leaving the default name of "App1". I select a Blank App, with UI Technology set to Xamarin.Forms and Code Sharing Strategy to Portable Class Library (PCL).
The moment the solution is generated, I proceed to delete the iOS and UWP projects. I build the project and preview in Xamarin Live Player just fine.
Next, I create Add > New Project to the solution. I select a .NET Standard > Class Library (.NET Standard). I leave the default name as "ClassLibrary1". I click OK. I right-click the ClassLibrary1 project and Manage NuGet Packages..., then browse and install Xamarin.Forms (which is the same version as the PCL, which is 2.4.0.280).
Next, I copy and paste App.xaml and MainPage.xaml from the PCL (named App1 (Portable) into the ClassLibrary1 project.
Next, I delete the App1 (Portable) PCL project. This causes an error in the MainActivity.cs of App1.Android because the reference to App is not found. I right-click and add the ClassLibrary1 reference in App1.Android. Additionally, in MainActivity.cs, I add using ClassLibrary1;
This is what my App1.Android now looks like:
using System;
using ClassLibrary1;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App1.Droid
{
[Activity(Label = "App1", Icon = "#drawable/icon", Theme = "#style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
}
}
The project builds just fine. But when I go to preview it in Xamarin Live Player, I get this weird error message:
The following errors were encountered when building and running your
app:
• MainActivity.cs: The type or namespace name 'ClassLibrary1' could
not be found (are you missing a using directive or an assembly
reference?) • MainActivity.cs: The type or namespace name 'App' could
not be found (are you missing a using directive or an assembly
reference?)
Can anyone tell me anything I can do to fix this error and get Xamarin Live Player to work?
I've additionally, tried doing a NuGet update on everything in the solution (nothing pre-release though) with no success.
I'm running Visual Studio 15.4.2. I've tried going to 15.5 (preview) and have had no luck.
Unfortunately, The Live player does not yet work on .Net Standard.
Ref: https://forums.xamarin.com/discussion/comment/303636
I think you need to add your newly created .netstandard project as a reference each of the platform specific project. Follow these two steps
Step 1:
Step 2:
17a: Right click Project(eg. Android project) -> 17b: Add -> 17c: Reference -> 18a: Tick the newly created project and click OK (this will basically tell your project that, it needs to add the .NETStandard project as a reference) and 18b: click OK to add as reference.
Repeat the same for Android, UWP & iOS.
At the same time, you have to ensure all projects installed with same version of Xamarin.Forms & .NET Standard 2.0.
You can refer to my written post on "Create Cross Platform Mobile App with .NET Standard 2.0" for steps that will guide you converting Xamarin.Forms from PCL to .NET Standard.
I am looking for System.speech to work in unity? Is there any way how to include this DLL in unity and MonoDevelop?
Because I'm trying to make a sound text to speech without spend the money from asset store. If System.Speech Library DLL could handle this why not. Just how to make it work with unity 5.3.5 ?
Also I have already try speechLib.dll. It is work while in editor but when Build to APK it is error and can't build.
Dlls files don't work on Android or iOS unless it is an unmanaged dll file without Windows specified API. If it is a Windows API or a managed dll then it won't work on Android or iOS.
You have two options: Buy a plugin or make your own. If you are only targeting Android and iOS then go for this Easy TTS which cost $5.
If you want to make one yourself then the process is very similar to my Speech to Text solution. The only difference are the classes used. Making one your self is easy. The only downside is that it is time consuming to make one for each platform.
Android:
TextToSpeech class.
iOS:
AVSpeechSynthesizer class
MacOS:
NSSpeechSynthesizer class
Windows:
ISpVoice class
There are tons of examples of how to use these on the internet. You have to make plugin for the Android class using Java, Objective-C for the iOS and MacOs classes. C++ for the Windows class.
For putting them together, you should use Unity's directive to do that.
class TextToSpeech
{
#if UNITY_ANDROID
Use TextToSpeech class
#endif
#if UNITY_IOS
Use AVSpeechSynthesizer class
#endif
#if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
Use NSSpeechSynthesizer class
#endif
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
Use ISpVoice class
#endif
}
FYI: I am using unity4.5.1f3 pro free version as of now.
My app is using ARCamera and I have migrated unity project for "vuforia-unity-android-ios-3-0-6 by following steps mentioned over here : [https://developer.vuforia.com/resources/dev-guide/migrating-your-unity-project]
After that I am receiving an error as below:
Type DefaultTrackableEventHandler' does not contain a definition forar_detected' and no extension method ar_detected' of typeDefaultTrackableEventHandler' could be found (are you missing a using directive or an assembly reference?)
In older version there is a bool flag of "ar_detected" in DefaultTrackableEventHandler.cs located at plugin path : Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs and in new version vuforia-unity-android-ios-3-0-6 this flag is not available, I am getting stucked with this change to identify what change will I required to do in my C# script,
Is there any other dependency I have missed when migrating to new version of Qualcomm Augmented Reality?
any one who can guide me on this?
Thanks,
Kiran
I got the solution for migration issue of Qualcomm Augmented Reality for vuforia-unity-android-ios-3-0-6 version,
Actually when older version is there other developer makes some change inside the DefaultTrackableEventHandler.cs to get ride for Augmented Reality for Camera feature,
I did same changes with new DefaultTrackableEventHandler.cs and got no error and it working fine now :)
I finally upgraded my WP7 app to WP8. Everything worked fine and the process was smooth. Unfortunately, it seems like the Microsoft.Xna.Framework.Graphics.Viewport namespace cannot be found anymore.
The type or namespace name 'Viewport' could not be found (are you
missing a using directive or an assembly reference?)
Unfortunately, I have no idea how to resolve this issue, as I need this viewport stuff in my augmented reality app to define the final monitor image...
Any ideas? Thank you very much!
There is no Viewport class available in Windows Phone 8. But there was the same problemn for GART toolkit, and it was solved by implementing own Viewport class.
Being your app an Augmented Reality app too, I think their solution will be valid for you too. You can get the source code here:
http://gart.codeplex.com/SourceControl/latest#GeoARToolkit/NonXnaUtils/Viewport.cs
Microsoft has deprecated the XNA Framework in Windows Phone 8. Some XNA assemblies can still be referenced but not Microsoft.Xna.Framework.Graphics.dll.
Here is the list of assemblies that can still be referenced:
Microsoft.Xna.Framework.dll Microsoft.Xna.Framework.GamerServices.dll
Microsoft.Xna.Framework.GamerServicesExtensions.dll
Microsoft.Xna.Framework.Input.Touch.dll
Microsoft.Xna.Framework.Media.dll
Microsoft.Xna.Framework.MediaLibraryExtensions.dll
For more information, check out the MSDN page on this topic.