自从更新到最新版本的 Unity 5.4.0f3 后,每当我双击脚本时,它都会启动 Visual Studio 和 Monodevelop,但我收到一条错误消息,指出此版本的 VS (Community 2015) 无法打开我的项目. Monodevelop 显示它自己的,不太清楚的错误消息。请查看下面的屏幕截图。
我仍然可以使用 Visual Studio 的文件菜单手动打开我的脚本,但智能感知代码完成不再有效。有人知道怎么修这个东西吗?我安装了 Visual Studio 的 Unity 工具。
所以我正在使用do while循环显示菜单,如下所示,我希望用户通过菜单提示,直到他们进行有效选择 - 输入数字1,2,3或4.我想要使用switch case语句来识别用户选择并执行相关的代码块.但是,当涉及输入验证时,我如何考虑用户输入字母而不是数字?下面的代码成功地继续下一次迭代,以便在用户输入字母时重新启动用户,除了它进入连续循环.
int selection;
do{
cout << "Which option would you like to select? (select 1, 2, or 3)";
cout << "1: Option 1" << endl;
cout << "2: Option 2" << endl;
cout << "3: Option 2" << endl;
if(!(cin >> selection)){
cout << "Please select an integer from 1-4." << endl;
cin.clear()
}
}while(selection != (1) or (2) or (3) or (4));
Run Code Online (Sandbox Code Playgroud)
我尝试使用istringstream插入下面的代码,将用户响应从字符串流式传输到while循环中的int,作为尝试解决问题的替代方法,但无济于事.
string temp;
cin >> temp;
clearInputBuffer();
istringstream is(temp);
is >> selection;
Run Code Online (Sandbox Code Playgroud)
更新的代码 …