- Home /
Question by
$$anonymous$$ · Apr 07, 2016 at 12:52 AM ·
viewrefresh
How to refresh the view ?
Here is the code for a sphere :
#pragma strict
var distance_to_screen : float;
var pos_move : Vector3;
function OnMouseDrag()
{
distance_to_screen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen ));
transform.position = new Vector3( pos_move.x, pos_move.y, pos_move.z );
}
function Update()
{
var hit:RaycastHit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButton(0) && Physics.Raycast( ray, hit, 200 ))
{
hit.transform.localScale.x+=Input.GetAxis("Mouse ScrollWheel")* Time.deltaTime*20;
transform.localScale.y=transform.localScale.z=transform.localScale.x;
}
}
function Start () {
}
The problem is when I transform the position or the scale of my sphere using my mouse, the old view of this sphere stays on the screen. Here is an image of the view when I move my sphere. I tried to solve this problem with SceneView.RepaintAll(); but it doesn't work.
Thank you
[1]: /storage/temp/67458-unity.jpg
unity.jpg
(110.1 kB)
Comment
Your answer

Follow this Question
Related Questions
Unity freezes when window inactive - any workaround? 1 Answer
How can I know if a gameObject is 'seen' by a particular camera? 11 Answers
Object material showing in scene but not game view 2 Answers
Changing the appearance of particles from another player's view 4 Answers
Can't See Anything 1 Answer