void OnButton() { int cStep = toolManager.GetCurrentStep(); if ((controledIndex + 1) <= steps.Length && toolManager.CheckStep(steps[controledIndex])) //操作步骤正确 { //换鼠标指针 toolManager.kCursorCur = kCursor; //隐藏上一步场景 if (kLastScene != null) { kLastScene.SetActive(false); } //显示当前步骤 kControledObjs[controledIndex].SetActive(true); kLastScene = kControledObjs[controledIndex]; //步骤7以后需要隐藏kDM_A if (kDM_A != null) { if (steps[controledIndex] >= 7) { kDM_A.SetActive(false); } else { kDM_A.SetActive(true); } } controledIndex++; } else //操作步骤错误 { toolManager.kMotion.transform.SetParent(transform); toolManager.kMotion.transform.localPosition = new Vector3(0, 200, 0); toolManager.kMotion.Show(); toolManager.GetComponent <AudioSource>().Play(); } }
void OnToolChange(bool isOn) { if (isOn) { toolManager.kCursorCur = kCursor; for (int i = 0; i < steps.Length; i++) { if (toolManager.GetCurrentStep() == steps[i]) { controledIndex = i; kControledObjs[controledIndex].SetActive(true); break; } else if (toolManager.GetCurrentStep() < steps[i]) { controledIndex = i; kControledObjs[controledIndex].SetActive(true); break; } } //7-10需要隐藏kDM_A if (steps[controledIndex] > 7 && toolManager.GetCurrentStep() <= steps[controledIndex]) { kDM_A.SetActive(false); } else { kDM_A.SetActive(true); } } else { Animator[] anims = kControledObjs[controledIndex].GetComponentsInChildren <Animator>(); for (int i = 0; i < anims.Length; i++) { anims[i].enabled = false; } Debug.Log("toolManager.GetCurrentStep(): " + toolManager.GetCurrentStep()); Debug.Log("steps[controledIndex]: " + steps[controledIndex]); if (toolManager.GetCurrentStep() <= steps[controledIndex]) { kControledObjs[controledIndex].SetActive(false); } for (int i = steps.Length; i > 0; i--) { //如果当前工具对应的最大步骤已经操作过了,则隐藏对应的物体 //主要解决kControledObjs有两个,当操作到第二个的时候隐藏的是第一个的问题 //if (toolManager.GetCurrentStep() >= steps[i - 1]) //{ // kControledObjs[i - 1].SetActive(false); // break; //} //else //{ // kControledObjs[i - 1].SetActive(false); //} //尝试下将所有的物体都隐藏 //kControledObjs[i - 1].SetActive(false); } //Debug.Log("controledIndex: " + controledIndex); //kControledObjs[controledIndex].SetActive(false); } //if (isOn) //{ // if (!kControledObj.activeSelf) // { // toolManager.kCursorCur = kCursor; // kControledObj.SetActive(true); // } //} //else //{ // Animator[] anims = kControledObj.GetComponentsInChildren<Animator>(); // for (int i = 0; i < anims.Length; i++) // { // anims[i].enabled = false; // } // kControledObj.SetActive(false); //} }