extern public static ErrorCodes XGrabPointer( IntPtr display, IntPtr grab_window, bool owner_events, int event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, int time );
/// <summary> /// Returns a cursor. Sets the _mode. Sets the _activeGraSquare (if there is one). /// </summary> /// <param name="location">The point to check. (0, 0) is upper left of the form</param> /// <returns>An approbiate Cursor or the default Cursor (the cached cursor of the Form)</returns> private Cursor checkForActiveRegionChangeCursor(Point location) { Console.WriteLine("checkForActiveRegionChangeCursor() " + location); //over Grabsqares? GrabSquare gs = null; bool isInsideGrabSquare = false; for (int i = 0; i < _grabSquares.Count; i++) { gs = _grabSquares[i]; isInsideGrabSquare = gs.isInside(location); if (isInsideGrabSquare) { break; } } if (isInsideGrabSquare) { //change forms cursor _activeGrabSquare = gs; _mouseOverMode = GrabMode.DRAG; return(_activeGrabSquare._cursor); } //over Rectangle himself? if (_rectangle.Contains(location)) { _activeGrabSquare = null; _lastMovePosition = location; _mouseOverMode = GrabMode.MOVE; return(_insideCursor); } else { _activeGrabSquare = null; _mouseOverMode = GrabMode.NONE; return(_defaultCursor); } }
// Use this for initialization void Start() { block_prefab = new List <GameObject>(); block_prefab.Add(Resources.Load("BookShelfBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("DirtBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("GrassBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("WoolBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("ChestBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("BrickBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("HayBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("PumpkinBlock", typeof(GameObject)) as GameObject); block_prefab.Add(Resources.Load("TntBlock", typeof(GameObject)) as GameObject); block_panel.SetActive(false); geometry_panel.SetActive(false); toggle_panel.SetActive(false); grabMode = GrabMode.Empty; /*blockToggle = null; * * blocks = new List<GameObject>(); */ }
public extern static int XGrabKeyboard(IntPtr display, IntPtr window, bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr timestamp);
extern internal static ErrorCodes GrabKeyboard(Display display, IntPtr grab_window, bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode, int time);
public static int XGrabButton(IntPtr display, int button, uint modifiers, IntPtr grab_window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor);
internal extern static int XGrabPointer(IntPtr display, IntPtr window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, IntPtr timestamp);
public void onMouseDown(MouseEventArgs e) { _lastMovePosition = e.Location; //initialize for move _mode = _mouseOverMode; }
public void SetGrabImageMode(GrabMode mode) { }
public static extern Status XGrabKey(IntPtr display, KeyCode keycode, KeyButtonMask modifiers, Window grab_window, bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode);
extern public static ErrorCodes XGrabKeyboard(IntPtr display, IntPtr grab_window, bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode, int time);
public static extern Status XGrabPointer(IntPtr display, Window grab_window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, Window confine_to, Cursor cursor, ulong time);
public static extern Status XGrabButton(IntPtr display, Button button, KeyButtonMask modifiers, Window grab_window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, Window confine_to, FontCursor cursor);
extern public static int XGrabKeyboard(IntPtr display, IntPtr grab_window, bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode, int time);
void Update() { Transform camera = Camera.main.transform; Ray ray = new Ray(camera.position, Vector3.Normalize(camera.rotation * Vector3.forward)); RaycastHit hit; mount_panel.text = setMountPanel(); if (cubeCanvas != null && geometryTargetObj != null) { cubeCanvas.transform.rotation = Quaternion.identity; cubeCanvas.transform.position = geometryTargetObj.transform.position; cubeCanvas.transform.Translate(0, 0, -0.05f); } if (left_hand.isActiveAndEnabled && right_hand.isActiveAndEnabled) { if (left_hand.GetLeapHand().GrabStrength > 0.99 && right_hand.GetLeapHand().GrabStrength > 0.99) { grabMode = GrabMode.Both; } else if (left_hand.GetLeapHand().GrabStrength > 0.99) { grabMode = GrabMode.LeftOnly; } else if (right_hand.GetLeapHand().GrabStrength > 0.99) { grabMode = GrabMode.RightOnly; } else { grabMode = GrabMode.Empty; } } switch (grabMode) { case GrabMode.Empty: if (Physics.Raycast(ray, out hit)) // Hit { if (hitObject == hit.collider.gameObject) // 같은 블럭 { if (grabMode == GrabMode.Empty) { hitObject.transform.localScale = new Vector3(1f, 1f, 1f); } if (!cubeAlphaObj.activeSelf) { countdown = timeToSelect; cubeAlphaObj.SetActive(true); } else { countdown -= Time.deltaTime; if (countdown < 0.0f) { cubeCanvas.SetActive(true); countdown = timeToSelect; } } } else if (hitObject != null) // 다른 블럭 { if (blockToggle.isOn) { //nothing } else { cubeAlphaObj.SetActive(false); cubeCanvas.SetActive(false); cubeAlphaObj = null; cubeCanvas = null; blockToggle = null; hitObject = hit.collider.gameObject; cubeAlphaObj = hitObject.transform.GetChild(6).gameObject; cubeCanvas = hitObject.transform.GetChild(7).gameObject; blockToggle = cubeCanvas.transform.GetChild(0).GetChild(0).GetComponent <Toggle>(); } } else // null 블럭 { hitObject = hit.collider.gameObject; cubeAlphaObj = hitObject.transform.GetChild(6).gameObject; cubeCanvas = hitObject.transform.GetChild(7).gameObject; blockToggle = cubeCanvas.transform.GetChild(0).GetChild(0).GetComponent <Toggle>(); } } else // no Hit { hitObject.transform.localScale = new Vector3(1f, 1f, 1f); if (hitObject != null) // previous hit block exist { if (blockToggle.isOn) { //nothing } else { //hitObject = null, effect = false&null hitObject = null; cubeAlphaObj.SetActive(false); cubeCanvas.SetActive(false); cubeAlphaObj = null; cubeCanvas = null; } } else { } } break; case GrabMode.LeftOnly: Debug.Log("left"); if (Vector3.Distance(hitObject.gameObject.transform.position, UnityVectorExtension.ToVector3(left_hand.GetLeapHand().Fingers[0].TipPosition)) < 0.15f && !blockToggle.isOn) { hitObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); Vector3 newPosition = UnityVectorExtension.ToVector3(left_hand.GetLeapHand().Fingers[0].TipPosition); hitObject.transform.position = new Vector3(truncate(newPosition.x), truncate(newPosition.y), truncate(newPosition.z)); } break; case GrabMode.RightOnly: Debug.Log("right"); if (Vector3.Distance(hitObject.gameObject.transform.position, UnityVectorExtension.ToVector3(right_hand.GetLeapHand().Fingers[0].TipPosition)) < 0.15f && !blockToggle.isOn) { hitObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f); Vector3 newPosition = UnityVectorExtension.ToVector3(right_hand.GetLeapHand().Fingers[0].TipPosition); hitObject.transform.position = new Vector3(truncate(newPosition.x), truncate(newPosition.y), truncate(newPosition.z)); } break; case GrabMode.Both: if (Vector3.Dot(UnityVectorExtension.ToVector3(left_hand.GetLeapHand().PalmNormal), Vector3.up) > 0 && Vector3.Dot(UnityVectorExtension.ToVector3(right_hand.GetLeapHand().PalmNormal), Vector3.up) > 0) { block_panel.SetActive(true); } //float palm_distance = Vector3.Distance(UnityVectorExtension.ToVector3(left_hand.GetLeapHand().PalmPosition), UnityVectorExtension.ToVector3(right_hand.GetLeapHand().PalmPosition)); //hitObject.transform.localScale = new Vector3(truncate(palm_distance), truncate(palm_distance), truncate(palm_distance)); break; } }
public extern static int XGrabButton(IntPtr display, int button, uint modifiers, Window grab_window, Bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, Window confine_to, Cursor cursor);
public void onMouseUp(MouseEventArgs e) { _mode = GrabMode.NONE; _color = doNothingColor; _parent.needRepaint(); }
public extern static int XGrabKey(IntPtr display, int keycode, uint modifiers, Window grab_window, bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode);
public static extern GrabMode WM_GrabInput(GrabMode mode);
internal static int XGrabPointer(IntPtr display, IntPtr window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, IntPtr timestamp) { DebugHelper.TraceWriteLine ("XGrabPointer"); return _XGrabPointer(display, window, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, timestamp); }
extern internal static ErrorCodes GrabPointer(Display display, IntPtr grab_window, bool owner_events, int event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, int time);
public extern static int XGrabPointer(IntPtr display, IntPtr window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, IntPtr timestamp);