Commit 9aebf21d authored by KenzyAshour2's avatar KenzyAshour2

images added

parent 16918072
This diff is collapsed.
using UnityEngine;
public class DraggableObjects : MonoBehaviour
{
private Vector3 mOffset;
private float mZCoord;
void OnMouseDown()
{
mZCoord = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
mOffset = gameObject.transform.position - GetMouseAsWorldPoint();
}
void OnMouseDrag()
{
transform.position = GetMouseAsWorldPoint() + mOffset;
}
private Vector3 GetMouseAsWorldPoint()
{
Vector3 mousePoint = Input.mousePosition;
mousePoint.z = mZCoord;
return Camera.main.ScreenToWorldPoint(mousePoint);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: a988a7abe4883994ea526b4fb710800b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment