How to drag an object does not pass the camera's range in Unity C#. Pls Help Me.
public GameObject Dragon; public Transform PotisionSpawmDragon; private Vector3 screenPoint; private Vector3 offset; public Transform PotisionCamera; // Use this for initialization void Start () { print(GetInstanceID()); } // Update is called once per frame void Update () {
 }
 void OnMouseDown()
 {
     // Spawm Dragon
     Invoke ("SpawmDragon",0);
     // Turn off Camera and Check Potision Mouse
     ManagerCamera.checkDragCamera = false;
     screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
     offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
 }
 // Drag Home to potision new
 void OnMouseDrag()
 {
     ManagerCamera.checkDragCamera = false;
     Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
     Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
     transform.position = curPosition;
 }
 void SpawmDragon()
 {
     Instantiate (Dragon,PotisionSpawmDragon.position,PotisionSpawmDragon.rotation);
 }
 void OnMouseExit()
 {
     ManagerCamera.checkDragCamera = true;
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
UI Elements repositioning and resizing when playing game 1 Answer
Drag and Stay(Fly) 0 Answers
Camera out of position on building/cloning to other machine,Camera out of place on another machine 0 Answers
How get position from a game object? 5 Answers
Camera isn't move position? Why my camera isn't change position? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                