Some pitfalls of Hololens Development
Microsoft provides two common methods for HoloLens development: VS2015 and Unity HoloLens. Among them, the VS method can use the general Windows template Holographic DX11 App to generate the Framework Code, and the Unity method can import the HoloToolkit, an officially recommended tool set, to accelerate development.
HoloLens runs in the Win10 system and its application is UWP App. the permissions of such apps are limited. When using APIs, you must apply for the corresponding permissions in Package. appxmanifest or unity settings. In addition, because the HoloLens ecosystem is not yet mature, Microsoft has made more restrictions on it. These restrictions are generally caused by the particularity of the device or the absence of integration of functions, some restrictions will be removed in future versions. For the current restrictions, refer:
1. Current limitations for apps using APIs from the shell
2. App model
In addition, the following are some detailed problems encountered in actual operations for your reference. Note: You have experienced exceptions in the old version of the API, but the API is available after the system is updated. Therefore, different results may occur in different versions. The environment used to record problems is as follows:
Development Environment: Win10 X64 10586, VS 2015 update3, Unity 5.4.0b24-HTP
HoloLens: 10.0.14342.1018
I. File System
A. Similarities and Differences of KnownFolder path acquisition methods
UWP uses the Windows. Storage namespace API for file operations. The most common class is KnownFolders. This class includes attributes of common directories and methods for obtaining directories. For example, the camera film directory can be obtained in either of the following ways: StorageFolder.
Currently, the MSDN document does not describe the differences between the two. In actual use, the path fields in the returned values are different:
Method 1: C: \ Data \ Users \ DefaultAccount \ Pictures \ Camera Roll
Method 2: C: \ Data \ Users \ DefaultAccount \ AppData \ Roaming \ Microsoft \ Windows \ Libraries \ CameraRoll. library-ms
Note:
For example, if you use the File class StorageFile of Windows. Storage to operate files in the enumerated directory, there is no difference between the two. If the file path is not affected by the directory path, the path shown in method 1 will be obtained. For example, (xxxFolder is set to the return value of the previous step ):
IReadOnlyList <StorageFile> fileList = await xxxFolder. GetFilesAsync ();
Foreach (StorageFile file in fileList) {/* file. path is the same */}
However, if you need to use the directory path to spell the path, you must note that! For example, for Unity WWW, path parameters are required. The directory path here must use the return path of method 1. Using B will cause invalid parameter errors.
B. Common directories that cannot be operated at the moment
Result: An exception is indicated after reading.
KnownFolderId. HomeGroup
KnownFolderId. MediaServerDevices
KnownFolderId. RemovableDevices
C. An error occurred while copying the API.
Result: An exception occurs when the copied file is included in the target directory.
For example, copy xFile to xFolder:
XFile. CopyAsync (xFolder) // Exeption if xFolder already has xFile
To forcibly copy a file, use the following method:
XFile. CopyAsync (xFolder, xName, NameCollisionOption. ReplaceExisting );
HoweverThe preceding API exception occurs when xFile is in the xFolder directory.
D. DP permission issues
Use DevicePortal to import the HoloLens file from the computer. The permission settings are incorrect and normal apps are not authorized to access the file. System. UnauthorizedAccessException.
For example, if you pass in a qualified Photo to the camera directory, the Hololens built-in Photo application will not be able to see the Photo.
Ii. Permission issues
A. Location permission
Call the GPS-related API. The manifest of the Program specifies the Location permission, and a confirmation is still required during the first operation. The Hololens App can call Launcher. launchiliasync (new Uri ("ms-settings: privacy-location") pops up the privacy page set by the system, allowing the user to choose to allow. After the operation, you can obtain accurate latitude and longitude information in the simulator.
B. User Account Information permission
Although this function is not listed in the official Hololens restriction list, during actual measurement, we found that the user account information could not be enumerated, but the same code can be obtained successfully on a normal Win10 device. This is also a try-out of the current difference.