Scene view我需要一些帮助来为Hololens制作一个简单的原型。
我在场景中有9个接近UI的可触摸交互按钮,如移动键盘。我希望他们随机地突出显示一个。我将按下突出显示的按钮,下一个随机按钮应突出显示,依此类推。我已经成功制作了用于VR的相同类型的应用,但是在MRTK中,很难突出显示按钮。如果有人帮助我提供示例代码,我将非常感谢。
我还附加了我的场景视图。 我已使用以下代码突出显示VR中的代码,但如何在MRTK中使用该代码。它不起作用。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Diagnostics;
using UnityEngine.UI;
public class Randomcolor : MonoBehaviour
{
public static GameObject B1,B2,B3,B4,B5,B6,B7,B8,B9,BX,ST;
public static int r,r_prev;
void Start()
{
B1 = GameObject.Find("Button1");
B2 = GameObject.Find("Button2");
B3 = GameObject.Find("Button3");
B4 = GameObject.Find("Button4");
B5 = GameObject.Find("Button5");
B6 = GameObject.Find("Button6");
B7 = GameObject.Find("Button7");
B8 = GameObject.Find("Button8");
B9 = GameObject.Find("Button9");
ST = GameObject.Find("ButtonSRT");
B1.getcomponent<Button>().interactable = true;
B2.getcomponent<Button>().interactable = true;
B3.getcomponent<Button>().interactable = true;
B4.getcomponent<Button>().interactable = true;
B5.getcomponent<Button>().interactable = true;
B6.getcomponent<Button>().interactable = true;
B7.getcomponent<Button>().interactable = true;
B8.getcomponent<Button>().interactable = true;
B9.getcomponent<Button>().interactable = true;
}
public void clickB1()
{
Color_Highlight();
}
public void Color_Highlight()
{
System.Random random_number = new System.Random();
r = random_number.Next(9) + 1;
while (r == r_prev)
{
r = random_number.Next(9) + 1;
}
r_prev = r;
if (r == 1) { BX = B1; }
if (r == 2) { BX = B2; }
if (r == 3) { BX = B3; }
if (r == 4) { BX = B4; }
if (r == 5) { BX = B5; }
if (r == 6) { BX = B6; }
if (r == 7) { BX = B7; }
if (r == 8) { BX = B8; }
if (r == 9) { BX = B9; }
var colors = BX.getcomponent<Button>().colors;
colors.normalColor = Color.cyan;
BX.getcomponent<Button>().colors = colors;
}
public void Color_Reset()
{
var colors = BX.getcomponent<Button>().colors;
colors.normalColor = new Color32(69,154,43,255);
BX.getcomponent<Button>().colors = colors;
}
}