|
|
@ -24,6 +24,9 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
protected Vector3 startingPosition; |
|
|
|
protected Vector3 startingPosition; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected bool updatePosition = false; |
|
|
|
|
|
|
|
protected Vector3 newPosition; |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnMouseDown() |
|
|
|
protected virtual void OnMouseDown() |
|
|
|
{ |
|
|
|
{ |
|
|
|
startingPosition = transform.position; |
|
|
|
startingPosition = transform.position; |
|
|
@ -45,10 +48,20 @@ namespace Fungus |
|
|
|
float y = Input.mousePosition.y; |
|
|
|
float y = Input.mousePosition.y; |
|
|
|
float z = transform.position.z; |
|
|
|
float z = transform.position.z; |
|
|
|
|
|
|
|
|
|
|
|
Vector3 newPosition = Camera.main.ScreenToWorldPoint(new Vector3(x, y, 10f)); |
|
|
|
newPosition = Camera.main.ScreenToWorldPoint(new Vector3(x, y, 10f)); |
|
|
|
newPosition.z = z; |
|
|
|
newPosition.z = z; |
|
|
|
|
|
|
|
updatePosition = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void LateUpdate() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// iTween will sometimes override the object position even if it should only be affecting the scale, rotation, etc. |
|
|
|
|
|
|
|
// To make sure this doesn't happen, we force the position change to happen in LateUpdate. |
|
|
|
|
|
|
|
if (updatePosition) |
|
|
|
|
|
|
|
{ |
|
|
|
transform.position = newPosition; |
|
|
|
transform.position = newPosition; |
|
|
|
|
|
|
|
updatePosition = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnMouseUp() |
|
|
|
protected virtual void OnMouseUp() |
|
|
|