//Returns value when button pressed. private void ReceiveResult(string result) { bool check = result.EndsWith(", CHECKED_TRUE"); bool yes = result.StartsWith(yesValue); bool no = result.StartsWith(noValue); if (saveChecked) { if (saveCondition == SaveCondition.Both || (saveCondition == SaveCondition.YesOnly && yes) || (saveCondition == SaveCondition.NoOnly && no)) { defaultChecked = check; SavePrefs(); } } if (yes) { if (OnYes != null) { OnYes.Invoke(yesValue, check); } } else if (no) { if (OnNo != null) { OnNo.Invoke(noValue, check); } } }
//Returns value when button pressed. private void ReceiveResult(string result) { if (result == yesValue) { if (OnYes != null) { OnYes.Invoke(yesValue); } } else if (result == noValue) { if (OnNo != null) { OnNo.Invoke(noValue); } } }
void RecognizeNo() { if (recogInterval[Gesture.No] > 0) { return; } try { var nextType = 0; //0: unknown, 1: pos, 2: neg var diffSum = 0.0f; var shakeCount = 0; const float minShake = 40.0f; var beforeY = hdms.First().eulerAngles.y; var index = 0; foreach (var hdm in hdms) { if (index < recogIndex[Gesture.No]) { continue; } index++; diffSum += GetAngleDiff(beforeY, hdm.eulerAngles.y); beforeY = hdm.eulerAngles.y; if (nextType == 0) { if (diffSum > minShake || diffSum < -minShake) { if (diffSum > minShake) { nextType = 2; } else if (diffSum < -minShake) { nextType = 1; } shakeCount += 1; } } else if (nextType == 1) { if (diffSum > minShake) { nextType = 2; shakeCount += 1; } } else if (nextType == 2) { if (diffSum < -minShake) { nextType = 1; shakeCount += 1; } } } if (shakeCount >= 2) { if (NoHandler != null) { NoHandler.Invoke(); } recogInterval[Gesture.No] = gestureInterval; recogIndex[Gesture.No] = hdms.Count; } } catch (InvalidOperationException) { // pass } }