/*public void SetStateObject(bool changeToStatedObject) * { * isMultipleStateObject = changeToStatedObject; * } */ /* public void DefineAsStateObject () * { * isMultipleStateObject = true; * * } * * public void DefineAsRegularGif() * { * isMultipleStateObject = false; * } */ void OnMouseDown() { // Prevent click when the GUI is blocking /*if (EventSystem.current.IsPointerOverGameObject()) * { * return; * }*/ if (MyIsPointerOverGameObject.IsPointerOverGameObject()) { return; } if (m_UIManager != null) { if (m_UIManager.IsRoomDialogOnScreen()) { return; } } if (!m_preventClic) { toNextSprite = true; } }
// fonction pendant que on est en train de "drag" void OnMouseDrag() { // Prevent click when the GUI is blocking /*if (EventSystem.current.IsPointerOverGameObject ()) { * return; * }*/ if (MyIsPointerOverGameObject.IsPointerOverGameObject()) { return; } if (m_UIManager != null) { if (m_UIManager.IsRoomDialogOnScreen()) { return; } } m_touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); MovePuzzlePiece(m_touchPosition - m_offset); }
void OnMouseOver() { if (MyIsPointerOverGameObject.IsPointerOverGameObject()) { return; } if (!m_preventClic && m_isReadyToBeClicked) { Cursor.SetCursor(MouseCursorGlobal.instance.GetInteractableTexture(), MouseCursorGlobal.instance.GetTopMiddleHotSpot(), CursorMode.Auto); } }
// Update is called once per frame void Update() { if (Input.touchCount >= 2) { return; } // Prevents the clic to be taken into account when the user is actually interacting with the GUI /*if (EventSystem.current.IsPointerOverGameObject()) { * return; * }*/ if (MyIsPointerOverGameObject.IsPointerOverGameObject()) { return; } //if(Input.GetMouseButtonUp(0)){ Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Collider2D currentCollider = gameObject.GetComponent <Collider2D> (); if (currentCollider != null) { if (currentCollider.OverlapPoint(mousePosition)) { if (Input.GetMouseButtonDown(0)) { ComputeAndSendClic(Input.mousePosition); } m_isMouseOver = true; if (m_mustChangeCursor) { Cursor.SetCursor(MouseCursorGlobal.instance.GetInteractableTexture(), MouseCursorGlobal.instance.GetTopMiddleHotSpot(), CursorMode.Auto); } } else { if (m_isMouseOver) { if (m_mustChangeCursor) { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } m_isMouseOver = false; } } } }
//Vector3 newGoCenter; //lorsque que l'on clique : void OnMouseDown() { if (!m_isDragDropEnable) { return; } // Prevent click when the GUI is blocking /*if (EventSystem.current.IsPointerOverGameObject()) * { * return; * }*/ if (MyIsPointerOverGameObject.IsPointerOverGameObject()) { return; } if (m_UIManager != null) { if (m_UIManager.IsRoomDialogOnScreen()) { return; } } // on récupère la position du curseur et on l'assigne à l'objet sur lequel on clique m_goCenter = this.transform.position; //on prends la position de la souris m_touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); // on calcule le "offset" qui est notre point de départ m_offset = m_touchPosition - m_goCenter; m_z -= 0.001f; this.transform.localPosition = new Vector3(this.transform.position.x, this.transform.position.y, m_z); }