注:本文提及到的代码示例下载地址 > How to build an "Hello World" 2D app in HololLens.
HoloLens 是微软的一款MR Glass(混合现实全息眼镜), 国内某非著名SQ主播出了个片子介绍它,有兴趣的点这里:http://v.youku.com/v_show/id_XMTcxNjIzNzQ2MA==.html?from=y1.7-1.2
HoloLens中可用的App大致分为两种类型:
2D:阉割版的UWP app(一些特性不支持)
关于哪里被阉了?英文好的同学可以直接点这里:Current limitations for apps using APIs from the shell
3D:HoloLens专用的Holographic app
API很酷,但是难上手(文档有点抽象),熟悉Unity 3D的同学比较容易上手。
文档点这里:Documentation for HoloLens
开发的前期准备:
你的VS版本必须是VS 2015或以上(推荐 vs 2015 update 3及以上),不然没有Win10 UWP开发套件的。下载地址点这里:https://www.visualstudio.com/vs-2015-product-editions
public sealed partial class MainPage : Page
{
public MainPageViewModel ViewModel = new MainPageViewModel();
public MainPage()
{
this.InitializeComponent();
this.DataContext = ViewModel;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ViewModel.ClickCount++;
}
}
public class MainPageViewModel : BindableBase
{
private int _clickCount;
public int ClickCount
{
get { return _clickCount; }
set { SetProperty(ref _clickCount, value); }
}
}
[Windows.Foundation.Metadata.WebHostHidden]
public abstract class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] String propertyName = null)
{
if (object.Equals(storage, value)) return false;
storage = value;
this.OnPropertyChanged(propertyName);
return true;
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
修复掉引用错误:在划红线的位置点击,出现小灯泡后选择小灯泡里的选项即可。
到此,该演示就结束了,是不是有种受骗上当的感觉?TMD这不就是UWP吗?
是的,其实他就是UWP,只是阉割版而已,重说三:阉割版,阉割版,阉割版,也就是有些UWP的特性在HoloLens现阶段中是不支持的,这一点才是真正需要你注意的地方。详细的列表请查阅微软官方文档:Current limitations for apps using APIs from the shell
HoloLens 3D入门教程请戳http://www.cnblogs.com/onecodeonescript/p/5925906.html