【发布时间】:2017-03-03 20:00:27
【问题描述】:
我目前正在编写一个统一的c#脚本,主要思想是当我点击模型的某个部分时,该部分将被突出显示,现在我希望再次点击它恢复到原始状态。当我第三次单击同一部分时,它应该再次突出显示。
我不知道如何在 Update() 方法中实现它,因为每次点击都要花费几帧,我无法识别第二次点击、第三次点击等是哪一帧。
有什么方法可以在不统一考虑帧数的情况下识别点击次数?
void Update(){
if (Input.GetMouseButton(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)){
bone = hit.collider.transform;
if (boneList.Contains(bone) != true)
{
/* if the part is not chosen before, add it to the list and highlight all elements in the list */
boneList.Add(bone);
Highlight(boneList);
}/*cannot delete the element chosen repetitively*/
}
}}
【问题讨论】:
-
听起来你想要
Input.GetMouseButtonDown()(或Input.GetMouseButtonUp())而不是Input.GetMouseButton()? -
@squill25 没关系,程序员的回答看起来比我目前可以投入的时间要全面得多。只要问题得到解决。 =P