我试图弄清楚如何在Unity3D 5.3.4f中使用oculus遥控器。我已经找到了一些 有关OVR映射的文档,但似乎无法弄清楚。
我要实现的是单击中间按钮(Button.One)。
我现在使用的是这一行代码
if (OVRInput.GetUp(OVRInput.Button.One))
{
Debug.Log("remote click");
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行该应用程序时,出现此错误。
NullReferenceException:对象引用未设置为对象OVRInput.GetUp(按钮virtualMask,控制器controllerMask)的实例(在Assets / OVR / Scripts / OVRInput.cs:600上)menuButtonHandler.Update()(在Assets / menuButtonHandler.cs:136上) )
可以在此脚本中找到
/// <summary>
/// Gets the current up state of the given virtual button mask with the given controller mask.
/// Returns true if any masked button was released this frame on any masked controller and no other masked button is still down this frame.
/// </summary>
public static bool GetUp(Button virtualMask, Controller controllerMask = Controller.Active) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将datagridview用于购物篮.我有它显示客户的篮子,但我希望它显示价格列的货币,但我也有一个数量列,所以如果我把默认样式作为货币,那么它将更改两个列货币格式.
我想要做的是将货币格式添加到价格列,但不添加到数量列.
这是显示购物篮的代码(Form_load)
using (var con = new SqlConnection(connectionString))
{
SqlDataAdapter dataadapter =
new SqlDataAdapter(
"select p.productname 'Product Name', b.productquantity 'Quantity', c.categoryname 'Category', p.price 'Current Price' " +
"from basket b join products p on b.productid = p.productid " +
"join Categories c on c.categoryid = p.categoryid " +
$"where b.customerid = {CustomerId}", con);
DataSet ds = new DataSet();
con.Open();
dataadapter.Fill(ds);
con.Close();
dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
Run Code Online (Sandbox Code Playgroud)
CustomerId是从存储CustomerId的txt文件中收集的.
如果您想要查看更多代码然后发表评论,我将添加它.
我正在尝试输出数组的奇数和偶数,我已经完成了所有工作但由于某种原因,当我创建一个foreach循环并输出每个数字是奇数/甚至它从零开始?
设置方式是用户输入10个数字,每个字母之间用逗号(以字符串开头),然后删除逗号并将数字转换为int并将其放入int数组中,然后用于另一堂课.我输入1,2,3,4,5,6,7,8,9,1来测试它.
Odds(ai.Odds);
Evens(ai.Evens);
Console.ReadKey();
}
public static void Odds(int[] odds)
{
Console.WriteLine("\nOdds:");
foreach (var odd in odds)
{
Console.Write(odd + " ");
}
}
public static void Evens(int[] evens)
{
Console.WriteLine("\nEvens:");
foreach (var even in evens)
{
Console.Write(even + " ");
}
}
Run Code Online (Sandbox Code Playgroud)
并在单独的类做魔术:
public int[] Odds
{
get
{
int count = 0;
int[] odds = new int[NumArray.Length];
string[] oddNums = {"1", "3", "5", "7", "9"};
foreach (int num in NumArray)
{
foreach (string oddNum in oddNums)
{ …Run Code Online (Sandbox Code Playgroud) 我正在为我的C#应用程序创建一个帐户页面.我设置了大量不同的编辑按钮以获得不同的细节,我的目的是减少生成和创建1方法的麻烦,这种方法会将表单更改为需要的方式.
这是我的代码,我希望将停止代码重用.
private void OnEditButton(string boxSelected, Size size)
{
if (doneBtn.Visible)
{
MessageBox.Show("Must edit current detail before editting a new one");
return;
}
lnametxt.Enabled = true;
lnameLink.Visible = false;
doneBtn.Visible = true;
doneBtn.Location = new Point(size);
TextBoxSelected = boxSelected;
}
Run Code Online (Sandbox Code Playgroud)
TextBoxSelected属性告诉数据库它们将要更改的列,因此这是一个参数,因为它将针对每个编辑链接进行更改.
我想做什么?-我试图将Size作为参数传递给此方法.这是调用该方法的代码.
private void lnameLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
OnEditButton("lname", (495, 55));
}
Run Code Online (Sandbox Code Playgroud)
在"(495,55)"它有一个错误我已经把第二批括号试图看看它是否适用于那里,而不是自己拥有它.两者都显示它有3个参数.
这是我想要的想法,但没有参数:
private void OnEditButton()
{
if (doneBtn.Visible)
{
MessageBox.Show("Must edit current detail before editting a new one");
return;
}
lnametxt.Enabled = true;
lnameLink.Visible = false; …Run Code Online (Sandbox Code Playgroud)