static GameObject dialogShown; /* a single one for now */ public void ShowPopup(Controller ctr, ref GameObject shown) { bool should_hide = false; if (dialogShown != null && dialogShown) { should_hide = (shown == dialogShown); GameObject.Destroy(dialogShown); } shown = dialogShown = null; ctr.SetPointer(null); if (should_hide) { CancelBuildDialog(); return; } Dialog dialog = BuildDialog(); Transform transform = dialog.transform; Vector3 head_forward = ctr.position - BaroqueUI.GetHeadTransform().position; Vector3 forward = ctr.transform.forward + head_forward.normalized; forward.y = 0; transform.forward = forward; transform.position = ctr.position + 0.15f * transform.forward; dialog.DisplayDialog(); shown = dialogShown = dialog.gameObject; }
void OnTouchScroll(Controller controller, Vector2 position_difference) { bool in_bounds = UpdateCurrentPoint(controller.position); if (in_bounds) { const float TOUCHPAD_SCROLL_FACTOR = 100f; const float TOUCHPAD_SCROLL_SPACE_EDGE = 0.04f; GameObject target = pevent.pointerCurrentRaycast.gameObject; pevent.scrollDelta = position_difference * TOUCHPAD_SCROLL_FACTOR; //Debug.Log("scroll: " + pevent.scrollDelta.x + " " + pevent.scrollDelta.y); GameObject go = ExecuteEvents.ExecuteHierarchy(target, pevent, ExecuteEvents.scrollHandler); //Debug.Log("scroll: sent to " + target.name + ", result = " + (go == null ? "NULL" : go.name)); if (go == null && scrollWholeDialog) { /* not sent anywhere. Move the whole dialog box around, if we're not close to the edge */ float delta_x = pevent.scrollDelta.x > 0 ? -TOUCHPAD_SCROLL_SPACE_EDGE : TOUCHPAD_SCROLL_SPACE_EDGE; float delta_y = pevent.scrollDelta.y > 0 ? -TOUCHPAD_SCROLL_SPACE_EDGE : TOUCHPAD_SCROLL_SPACE_EDGE; if (UpdateCurrentPoint(controller.position - delta_x * transform.right) && UpdateCurrentPoint(controller.position - delta_y * transform.up)) { transform.position -= (pevent.scrollDelta.x * transform.right + pevent.scrollDelta.y * transform.up) / unitsPerMeter; } } } controller.SetPointer(""); }
protected virtual void OnEnter(Controller controller) { locals.Add(new Local { ctrl = controller, touchpad_down = controller.touchpadPressed ? 2 : controller.touchpadTouched ? 1 : 0 }); controller.SetPointer("Red Ball"); is_active = 3; }
void UpdateCursor(Controller controller) { float distance_to_plane = transform.InverseTransformPoint(controller.position).z * -0.06f; if (distance_to_plane < 1) { distance_to_plane = 1; } Transform tr = controller.SetPointer("Cursor"); tr.rotation = transform.rotation; tr.localScale = new Vector3(1, 1, distance_to_plane); }
protected virtual void OnLeave(Controller controller) { for (int i = 0; i < locals.Count; i++) { if (locals[i].ctrl == controller) { locals.RemoveAt(i); break; } } UpdateAltGr(); controller.SetPointer(""); if (locals.Count == 0) { is_active = 1; } }
protected virtual void OnEnter(Controller controller) { bool found = false; for (int i = 0; i < locals.Count; i++) { if (locals[i].ctrl == controller) { found = true; } } if (!found) { locals.Add(new Local { ctrl = controller, touchpad_down = TouchpadPressed(controller) ? 2 : TouchpadTouched(controller) ? 1 : 0 }); } controller.SetPointer("Red Ball"); is_active = 3; }
public override void OnMoveOver(Controller controller) { // handle enter and exit events (highlight) GameObject new_target = null; if (UpdateCurrentPoint(controller)) { new_target = pevent.pointerCurrentRaycast.gameObject; } UpdateHoveringTarget(new_target); float distance_to_plane = transform.InverseTransformPoint(controller.position).z * -0.06f; if (distance_to_plane < 1) { distance_to_plane = 1; } GameObject go = controller.SetPointer("Cursor"); /* XXX */ go.transform.rotation = transform.rotation; go.transform.localScale = new Vector3(1, 1, distance_to_plane); }
public override void OnLeave(Controller controller) { UpdateHoveringTarget(null); pevent = null; controller.SetPointer(null); }