I on the function of the implementation of the first point: there is a stick (already hold the left mouse button can be accomplished by the rods were to follow the mouse), stick on the panel of UGUI, stick is a 3 d object, with the Cube to the simple model, and now need to implement, the mouse to click on the left and right sides endpoint at one end, don't let go, and then the mouse up and down sliding implementation sticks around the center of rotation! Troublesome everybody a great god can give hints, or have a code! The younger brother grateful!
CodePudding user response:
With the X-ray testing first selected objects, and then monitored the Z axis input, and then let the object rotationCodePudding user response:
Thank you very much for your answer! Recently the company's project is more, colleagues are busy, take time to help me to solve today!CodePudding user response:
Questions of have a little roundWhether the mouse on the left and right sides at both ends, get on the screen after the click of a mouse click on the location of the judge, will give you a reference code
void onm ouseDown () {
ScreenPosition=Camera. Main. WorldToScreenPoint (transform. The position);
The position=the transform. The position - Camera. The main ScreenToWorldPoint (
New Vector3 (Input) mousePosition) x,
Input. MousePosition. Y, screenPosition. Z));
StartCoroutine (ChangePosition ());
}
IEnumerator ChangePosition () {
While (Input. GetMouseButton (0)) {
TempPosition=Camera. Main. ScreenToWorldPoint (new Vector3 (Input) mousePosition) x, Input the mousePosition. Y, screenPosition. Z));
The transform. The position=tempPosition + position;
Yield return null;
}
}
CodePudding user response:
This problem...CodePudding user response:
Public Camera Camera;