// Update is called once per frame void Update() { Ray rayToMouse = viewCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(rayToMouse, out hitInfo, 1.0e8f)) { hoverToken = hitInfo.collider.gameObject.GetComponent<Token>(); }else { hoverToken = null; } if ( hoverToken != null ) Debug.Log( "Hover " + hoverToken.movieName ); // if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) ) // { // if ( hoverToken != null ) // { // tempToken = hoverToken; // // left click // if( Input.GetMouseButtonDown(0) ) // { // tempDragToken = tempToken; // tempDragToken.BeginMove(hitInfo.point); // // tempToken.BeginMove( hitInfo.point ); // moveDistance = hitInfo.distance; // StartCoroutine( WaitForMouseUp( clickTime , hitInfo.point , true) ); // }else // //rightclick // if ( Input.GetMouseButtonDown( 1 )) // { // StartCoroutine( WaitForMouseUp( clickTime , hitInfo.point, false) ); // } // } //// if (!Physics.Raycast(ray, hitInfo.distance - 0.01f)) //// StartCoroutine(coHandleButtonPress(-1)); // } if (Input.GetMouseButtonDown(0) ) { if ( hoverToken != null ) { tempToken = hoverToken; tempDragToken = tempToken; tempDragToken.BeginMove(hitInfo.point); moveDistance = hitInfo.distance; StartCoroutine( WaitForMouseUp( clickTime , hitInfo.point , true) ); } } if ( Input.GetMouseButtonDown(1)) { if ( hoverToken != null ) { tempToken = hoverToken; tempDeleteToken = tempToken; StartCoroutine( WaitForMouseUp( clickTime , hitInfo.point, false) ); } } if ( Input.GetMouseButtonUp(0) && tempDragToken != null ) { tempDragToken.EndMove(); tempDragToken = null; } // move drag if ( tempDragToken != null ) { Vector3 position = rayToMouse.GetPoint( moveDistance ); tempDragToken.Move( position ); } //delete if ( tempDeleteToken != null ) { if ( tempDeleteToken.Delete() ) tempDeleteToken = null; } //managee the TokenCreation tempTime += Time.deltaTime; while( tempTokenInfoIndex < TimeLine.tokenInfoList.Count ) { if ( TimeLine.tokenInfoList[tempTokenInfoIndex].time > tempTime ) break; // Debug.Log("Index = " + tempTokenInfoIndex.ToString() ); // Debug.Log("movieName" + TimeLine.tokenInfoList[tempTokenInfoIndex].name); if ( tempTime - 1f < TimeLine.tokenInfoList[tempTokenInfoIndex].time ) CreateNewToken( TimeLine.tokenInfoList[tempTokenInfoIndex] ); tempTokenInfoIndex++; } //exit game if ( Input.GetKeyDown(KeyCode.Escape)) Application.Quit(); }