C# Can';我的计数器不能正常工作
这应该是直截了当的,但我不明白,很可能我已经看了太久的东西没有休息,但我可以用另一套眼睛在这方面。我试图创建一个计数器,跟踪拍摄的照片数C# Can';我的计数器不能正常工作,c#,unity3d,operators,counter,C#,Unity3d,Operators,Counter,这应该是直截了当的,但我不明白,很可能我已经看了太久的东西没有休息,但我可以用另一套眼睛在这方面。我试图创建一个计数器,跟踪拍摄的照片数GameManager.CurrentStep,然后在达到所需照片总数GameManager.instance.FloftNumSteps后禁用照片按钮。由于某些原因,在结尾处有一个额外的步骤,例如,如果步骤总数为6,则相机不会禁用并显示GameManager.instance.floftinstructionContext.text=“Drift Comple
GameManager.CurrentStep
,然后在达到所需照片总数GameManager.instance.FloftNumSteps
后禁用照片按钮。由于某些原因,在结尾处有一个额外的步骤,例如,如果步骤总数为6,则相机不会禁用并显示GameManager.instance.floftinstructionContext.text=“Drift Completed!!”代码>直到第七步
public void CapturePhoto(float latitude, float longitude)
{
// If all photos have been taken
if (GameManager.CurrentStep <= GameManager.instance.driftNumSteps - 1)
{
// When a photo gets taken increment by 1
GameManager.CurrentStep++;
// Get the next drift step
EventManager.GetDriftStep(GameManager.CurrentStep);
// Insert photo data into SQL record
GetComponent<SQLiteActions>().InsertPhotoData(GameManager.CurrentDriftID, "texture path", 78.33f, 87.1765f);
/*if (PhoneCamera.backCam != null)
{
Texture2D photo = new Texture2D(PhoneCamera.backCam.width, PhoneCamera.backCam.height);
photo.SetPixels(PhoneCamera.backCam.GetPixels());
photo.Apply();
SavePhotoToCameraRoll(photo); // Save photo to camera roll gallery
//SavePhotoToLocalStorage(photo); // Save photo to local app storage
Debug.Log("Photo Captured!");
}
else
{
Debug.Log("Phone Camera Not Found!");
}*/
}
else
{
// Tell user their drift is done!
GameManager.instance.driftInstructionText.text = "Drift Completed!!";
// Fade camera button maybe?
Debug.Log("Drift is complete!!");
UIActions.EnableButton(GameManager.instance.newDriftBtn); // Enable create new drift button
UIActions.DisableButton(GameManager.instance.takePhotoBtn); // Disable photo button button
}
Debug.Log(GameManager.CurrentStep + " out of " + GameManager.instance.driftNumSteps + " steps.");
}
public void CapturePhoto(浮动纬度、浮动经度)
{
//如果所有的照片都拍了
if(GameManager.CurrentStep谢谢你的反馈!我解决了问题。我从列表中检索到的是1而不是0。有一次我调整了返回到返回GameManager.Drift[CurrentStep-1].floftStep;一切正常。假设CurrentStep初始化为0,代码似乎与您描述的一样。换句话说,如果floftNumSteps==6,并且CurrentStep仅在上述函数中递增,则CurrentStep不应大于6。而0..6是7的范围,则GetFloftStep(在函数中)应该只调用6次(范围为1..6)。我知道这可能没有帮助,但至少现在设置了_of_eyes++Debug.Log的第一个输出是什么(GameManager.CurrentStep+“out of”+GameManager.instance.floftnumsteps+“steps”);
?