private void InvokeStops(GestureAction lastAction) { switch (lastAction) { case GestureAction.Tap: break; case GestureAction.Idle: break; case GestureAction.Dragging: gestures.OnDragStop?.Invoke(state.dragState); break; case GestureAction.Zooming: gestures.OnZoomStop?.Invoke(state.zoomState); break; case GestureAction.Twisting: gestures.OnTwistStop?.Invoke(state.twistState); break; default: throw new ArgumentOutOfRangeException(); } }
public GestureActionListPickerItem(GestureAction action) : base(GestureActionHelper.Text(action)) { DefaultStyleKey = typeof(GestureActionListPickerItem); Action = action; Icon = GestureActionHelper.IconStyle(action); }
public void Start() { currentAction = GestureAction.Idle; if (Camera.main == null) { throw new Exception("no camera in scene, cannot gesture"); } state = new GestureState() { zoomState = new GestureZoomState(), dragState = new GestureDragState(), twistState = new GestureTwistState(), tapState = new GestureTapState(), }; if (MousePlatforms.Contains(Application.platform)) { platform = new GesturePlatformMouse(gestures.config.mouse, keys, state, Camera.main, eventSystem); state.platformName = "Mouse"; return; } platform = new GesturePlatformTouch(state, Camera.main, gestures.config.touch); state.platformName = "Touch"; }
public override Action AddAction() { var result = new GestureAction(); actions.Add(result); return(result); }
//### GestureAction登録 ### private GestureAction CreateGestureAction(UnityAction <InputStatus> action) { GestureAction gesture = new GestureAction(); gesture.AddListener(action); return(gesture); }
private void Postpone(TaskModel task, DateTime?due, GestureAction action) { task.DueDate = due; App.Tasks.Update(task); UpdateGroupedTasks(); Toast.Show(string.Format(AppResources.ToastPostponedUntil, task.DueDate), GestureActionHelper.IconStyle(action)); }
protected void ActionInvoke(GestureAction action) { if (action == null) { return; } SetInputStatus(); action.Invoke(inputStatus); }
private GameObject _axisY; //代表Y轴的物体 void Start() { gesAction = FindObjectOfType <GestureAction>(); //将头作为第一个模型 _displayModel = Instantiate(Models[0], Models[0].transform.position, Models[0].transform.rotation); _axisY = GameObject.Find("AxisY"); _displayModel.transform.parent = _axisY.transform; _indexOfModels = 0; }
private void InitGesturesPicker(ListPicker picker, GestureAction action) { picker.ItemsSource = CreateGestureList(); picker.SelectedIndex = 0; for (int i = 0; i < picker.Items.Count; i++) { if (((GestureActionListPickerItem)picker.Items[i]).Action == action) { picker.SelectedIndex = i; break; } } }
void GestureObjectsActionSet(bool state) { if (gestureActionRotObject == null) { gestureActionRotObject = GestureScaleObject.GetComponent <GestureAction>(); } if (gestureActionScaleObject == null) { gestureActionScaleObject = GestureMoveRotObject.GetComponent <GestureAction>(); } gestureActionScaleObject.SetGesture(state); gestureActionRotObject.SetGesture(state); }
public void Update() { if (state == null) { return; } platform?.Update(); var lastAction = currentAction; currentAction = state.action; if (lastAction == currentAction) { InvokeContinues(); return; } switch (currentAction) { case GestureAction.Tap: gestures.OnTap?.Invoke(state.tapState); break; case GestureAction.Idle: InvokeStops(lastAction); break; case GestureAction.Dragging: gestures.OnDragStart?.Invoke(state.dragState); break; case GestureAction.Zooming: gestures.OnZoomStart?.Invoke(state.zoomState); break; case GestureAction.Twisting: gestures.OnTwistStart?.Invoke(state.twistState); break; default: throw new ArgumentOutOfRangeException(); } }
public static string Text(GestureAction action) { switch (action) { case GestureAction.Complete: return(AppResources.GestureActionComplete); case GestureAction.Delete: return(AppResources.GestureActionDelete); case GestureAction.DueToday: return(AppResources.GestureActionDueToday); case GestureAction.DueTomorrow: return(AppResources.GestureActionDueTomorrow); case GestureAction.PostponeDay: return(AppResources.GestureActionPostponeDay); case GestureAction.PostponeWeek: return(AppResources.GestureActionPostponeWeek); case GestureAction.None: default: return(AppResources.GestureActionNone); } }
public static Style IconStyle(GestureAction action) { switch (action) { case GestureAction.Complete: return(App.IconStyle("CheckBox")); case GestureAction.Delete: return(App.IconStyle("Delete")); case GestureAction.DueToday: return(App.IconStyle("DueToday")); case GestureAction.DueTomorrow: return(App.IconStyle("DueTomorrow")); case GestureAction.PostponeDay: return(App.IconStyle("PostponeOneDay")); case GestureAction.PostponeWeek: return(App.IconStyle("PostponeOneWeek")); case GestureAction.None: default: return(App.IconStyle("BoldClose")); } }
static T DoGesture <T, TA>(List <Transform> list, GestureAction <T, TA> action, TA arg) where TA : TouchArg where T : class, IGesture { foreach (var item in list) { var gestures = item.GetComponents(typeof(T)); foreach (var component in gestures) { var gesture = component as T; var behaviour = gesture as Behaviour; if (IsEnabled(behaviour)) { action(gesture, arg); if (arg.handled) { return(gesture); } } } } return(null); }
private void ExecuteGesture(GestureAction action, TaskSubtaskEventArgs e) { if (e.Task == null || e.Subtask == null) { return; } switch (action) { case GestureAction.Complete: VibrateHelper.Short(); ToggleComplete(e.Task, e.Subtask); break; case GestureAction.Delete: VibrateHelper.Short(); e.Delete = true; Toast.Show(AppResources.ToastSubtaskDeleted, App.IconStyle("Delete")); break; default: break; } }
public void SetPinchAction(UnityAction <InputStatus> action) { pinchAction = CreateGestureAction(action); }
private void OverlayAction(Action <TaskModel, DateTime?, GestureAction> action, TaskModel task, DateTime?date, GestureAction gestureAction) { PageOverlayTransitionShow.BeginTime = TimeSpan.Zero; PageOverlayTransitionShow.Begin(); EventHandler overlayHandler = null; overlayHandler = (s, e) => { action(task, date, gestureAction); PageOverlayTransitionHide.Begin(); PageOverlayTransitionShow.Completed -= overlayHandler; }; PageOverlayTransitionShow.Completed += overlayHandler; }
private void ExecuteGesture(GestureAction action, TaskEventArgs e) { if (e.Task == null) { return; } TaskModel task = e.Task; switch (action) { case GestureAction.Complete: VibrateHelper.Short(); ToggleComplete(task); break; case GestureAction.Delete: VibrateHelper.Short(); OverlayAction(() => { e.Item.ResetDelete(); App.Tasks.Delete(e.Task); }); e.Delete = true; Toast.Show(AppResources.ToastTaskDeleted, App.IconStyle("Delete")); break; case GestureAction.DueToday: case GestureAction.DueTomorrow: VibrateHelper.Short(); if (!task.HasRepeats) { DateTime?oldDue = task.DueDate; DateTime newDue = (action == GestureAction.DueToday ? DateTimeExtensions.Today : DateTimeExtensions.Tomorrow); newDue = newDue.SetTime(oldDue ?? Settings.Current.DefaultTime); OverlayAction(SetDueDate, task, newDue, action); } else { Toast.Show(AppResources.GestureCantWithRepeats, App.IconStyle("Warning")); } break; case GestureAction.PostponeDay: case GestureAction.PostponeWeek: VibrateHelper.Short(); if (!task.HasRepeats) { if (task.HasDueDate) { OverlayAction(Postpone, task, task.DueDate.Value.AddDays((action == GestureAction.PostponeDay ? 1 : 7)), action); } else { OverlayAction(Postpone, task, DateTimeExtensions.Today.AddDays((action == GestureAction.PostponeDay ? 1 : 7)).SetTime(Settings.Current.DefaultTime), action); } } else { Toast.Show(AppResources.GestureCantWithRepeats, App.IconStyle("Warning")); } break; case GestureAction.None: default: break; } }
private void SetDueDate(TaskModel task, DateTime?due, GestureAction action) { task.DueDate = due; App.Tasks.Update(task); UpdateGroupedTasks(); }
public void SetTwistingAction(UnityAction <InputStatus> action) { twistingAction = CreateGestureAction(action); }
public void SetTapAction(UnityAction <InputStatus> action) { tapAction = CreateGestureAction(action); }
void BuildLayer(AnimationLayer layerType, string layerName, List <GestureAction> actions, MenuActions.MenuAction parentAction) { var controller = GetController(layerType); //Add parameter if (side == GestureSide.Left || side == GestureSide.Both) { AddParameter(controller, "GestureLeft", AnimatorControllerParameterType.Int, 0); } if (side == GestureSide.Right || side == GestureSide.Both) { AddParameter(controller, "GestureRight", AnimatorControllerParameterType.Int, 0); } //Prepare layer var layer = GetControllerLayer(controller, layerName); layer.stateMachine.entryTransitions = null; layer.stateMachine.anyStateTransitions = null; layer.stateMachine.states = null; layer.stateMachine.entryPosition = StatePosition(-1, 0); layer.stateMachine.anyStatePosition = StatePosition(-1, 1); layer.stateMachine.exitPosition = StatePosition(-1, 2); //Default state AnimatorState defaultState = null; GestureAction defaultAction = null; var unusedGestures = new List <GestureEnum>(); unusedGestures.Add(GestureEnum.Neutral); unusedGestures.Add(GestureEnum.Fist); unusedGestures.Add(GestureEnum.OpenHand); unusedGestures.Add(GestureEnum.FingerPoint); unusedGestures.Add(GestureEnum.Victory); unusedGestures.Add(GestureEnum.RockNRoll); unusedGestures.Add(GestureEnum.HandGun); unusedGestures.Add(GestureEnum.ThumbsUp); //Build states int actionIter = 0; foreach (var action in this.actions) { //Check if valid if (!action.gestureTable.IsModified()) { EditorUtility.DisplayDialog("Build Warning", $"Simple Gesture {action.name} has no selected conditions.", "Okay"); continue; } //Build var state = layer.stateMachine.AddState(action.name, StatePosition(0, actionIter + 1)); state.motion = action.GetAnimation(layerType, true); actionIter += 1; //Conditions AddGestureCondition(GestureEnum.Neutral); AddGestureCondition(GestureEnum.Fist); AddGestureCondition(GestureEnum.OpenHand); AddGestureCondition(GestureEnum.FingerPoint); AddGestureCondition(GestureEnum.Victory); AddGestureCondition(GestureEnum.RockNRoll); AddGestureCondition(GestureEnum.HandGun); AddGestureCondition(GestureEnum.ThumbsUp); void AddGestureCondition(BaseActions.GestureEnum gesture) { if (!action.gestureTable.GetValue(gesture)) { return; } //Transition var transition = layer.stateMachine.AddAnyStateTransition(state); transition.hasExitTime = false; transition.exitTime = 0; transition.duration = action.fadeIn; if (side == GestureSide.Left || side == GestureSide.Both) { transition.AddCondition(AnimatorConditionMode.Equals, (int)gesture, "GestureLeft"); } if (side == GestureSide.Right || side == GestureSide.Both) { transition.AddCondition(AnimatorConditionMode.Equals, (int)gesture, "GestureRight"); } //Parent if (parentAction != null && gesture != GestureEnum.Neutral) { parentAction.AddCondition(transition, true); } //Cleanup unusedGestures.Remove(gesture); } //Default if (action.gestureTable.neutral) { defaultState = state; defaultAction = action; } } //Default state if (defaultState == null) { defaultState = layer.stateMachine.AddState("Neutral", StatePosition(0, 0)); } layer.stateMachine.defaultState = defaultState; //Animation Layer Weight var layerWeight = defaultState.AddStateMachineBehaviour <VRC.SDK3.Avatars.Components.VRCAnimatorLayerControl>(); layerWeight.goalWeight = 1; layerWeight.layer = GetLayerIndex(controller, layer); layerWeight.blendDuration = 0; layerWeight.playable = VRC.SDKBase.VRC_AnimatorLayerControl.BlendableLayer.FX; //Default transitions foreach (var gesture in unusedGestures) { //Transition var transition = layer.stateMachine.AddAnyStateTransition(defaultState); transition.hasExitTime = false; transition.exitTime = 0; transition.duration = defaultAction != null ? defaultAction.fadeIn : 0f; if (side == GestureSide.Left || side == GestureSide.Both) { transition.AddCondition(AnimatorConditionMode.Equals, (int)gesture, "GestureLeft"); } if (side == GestureSide.Right || side == GestureSide.Both) { transition.AddCondition(AnimatorConditionMode.Equals, (int)gesture, "GestureRight"); } } //Parent if (parentAction != null) { var transition = layer.stateMachine.AddAnyStateTransition(defaultState); transition.hasExitTime = false; transition.exitTime = 0; transition.duration = defaultAction != null ? defaultAction.fadeIn : 0f; parentAction.AddCondition(transition, false); } }
Gesture(GestureAction act, string desc, Keys[] keys) { ActionCode = act; Descroption = desc; KeySeq = keys; }
public void SetLongTapLevelAction(UnityAction <InputStatus> action) { longTapLevelAction = CreateGestureAction(action); }
public void SetReleaseAction(UnityAction <InputStatus> action) { releaseAction = CreateGestureAction(action); }
public void SetFlickAction(UnityAction <InputStatus> action) { flickAction = CreateGestureAction(action); }
// Use this for initialization void Start() { timeLastHit = 0.0f; timeRemove = 0.0f; timeLimit = 5.0f; isReady = true; radialObjects = GameObject.FindGameObjectsWithTag("hasRadialChildren"); pointerScale = new Vector3(0.005f, 0.005f, 0.005f); GameObject nohand1 = GameObject.Find("noHandCross1"); GameObject nohand2 = GameObject.Find("noHandCross2"); noHand1Renderer = nohand1.GetComponent <Renderer>(); noHand2Renderer = nohand2.GetComponent <Renderer>(); originalColor = GameObject.Find("RadialLevel2_1_2 (9)").GetComponent <Renderer>().material.color; isManipCursor3Renderer = GameObject.Find("isManipulatingObject3").GetComponent <Renderer>(); isManipCursor4Renderer = GameObject.Find("isManipulatingObject4").GetComponent <Renderer>(); isManipCursor5Renderer = GameObject.Find("isManipulatingObject5").GetComponent <Renderer>(); isManipCursor6Renderer = GameObject.Find("isManipulatingObject6").GetComponent <Renderer>(); isManipCursor7Renderer = GameObject.Find("isManipulatingObject7").GetComponent <Renderer>(); isManipCursor8Renderer = GameObject.Find("isManipulatingObject8").GetComponent <Renderer>(); isManipCursor9Renderer = GameObject.Find("isManipulatingObject9").GetComponent <Renderer>(); isManipCursor10Renderer = GameObject.Find("isManipulatingObject10").GetComponent <Renderer>(); progressCircleRenderer = GameObject.Find("ProgressCirlce").GetComponent <Renderer>(); staticCircleRenderer = GameObject.Find("staticCircle").GetComponent <Renderer>(); staticCircleRenderer.enabled = false; sceneCreation = GameObject.Find("sceneCreation"); simpleRadial = sceneCreation.GetComponent <simpleRadialSceneCreation>(); gazeMode = simpleRadial.condition; cursorPlaneIntersect = GameObject.Find("CursorPlaneIntersect"); gestureAction = gameObject.GetComponent <GestureAction>(); cursorScale = transform.localScale; cursorAvgX = new MovingAverage(filterSamples); cursorAvgY = new MovingAverage(filterSamples); cursorAvgZ = new MovingAverage(filterSamples); setCursorManipEnabled(true); eyeReticle = GameObject.Find("EyeReticle"); if (eyeReticle != null) { eyeGazeTransform = eyeReticle.transform; eyeGazeRenderer = eyeReticle.GetComponent <EyeGazeRenderer>(); //targetSelection.setParticipant(eyeGazeRenderer.m_participantNum, eyeGazeRenderer.m_conditionNum); } //Mikko disabled //#if WINDOWS_UWP //hide reticle // calibReticle.enabled = false; //#endif progressCircleRenderer.enabled = false; headPointer = GameObject.Find("HeadPointer"); eyePointer = GameObject.Find("EyePointer"); }
public void SetPressingAction(UnityAction <InputStatus> action) { pressingAction = CreateGestureAction(action); }
void Start() { gestureText = this.GetComponentInChildren <Text>(); gesAction = FindObjectOfType <GestureAction>(); }
public void SetDragingAction(UnityAction <InputStatus> action) { dragingAction = CreateGestureAction(action); }