HiddenMonk / Unity3DRuntimeTransformGizmo

A runtime transform gizmo similar to unitys editor so you can translate (move, rotate, scale) objects at runtime.
MIT License
707 stars 129 forks source link

Rotation arrows #15

Closed craftercis closed 5 years ago

craftercis commented 5 years ago

Hey,

Sorry this is hopefully my last question for a loooong time =D.

How can I made the rotation arrow of the first picture into the second picture. The protrusions have to turn around with the movement you make

screenshot_2 screenshot_1

craftercis commented 5 years ago

test

I have now this. But i want to edit the green line his position and only when i hit the protrusions he may rotate. How can I do that?

craftercis commented 5 years ago

Do you know how I can solve this?

HiddenMonk commented 5 years ago

Im not too sure, I am not great at math and rotations scare me =)

One idea is to have you be able to use any gizmo you want instead of the default gizmos. You could probably do this by disabling any drawing of the TransformGizmo stuff in OnPostRender(), then remove the call to SetNearAxis() in the Update() method, and finally make the "Axis nearAxis" variable public. Now, you can make any gizmo you want, such as a sprite or mesh gizmo like you have in your image, and when you detect the player has clicked it through a raycast, you can set the TransformGizmo nearAxis to the axis you want to start translating in and everything should just work. Then when they are done you should set the nearAxis back to None, or better yet just set it to None in the TransformSelected method at the end (I should probably do that as well). You should also make the "totalRotationAmount" variable public so you can have your custom gizmo follow the rotation.

craftercis commented 5 years ago

Thnx for this. I would try It. But is it also possible to move the green Gizmo down and make it invisible that would be the simpele solution tot this

HiddenMonk commented 5 years ago

I dont think its reliable to try to move the gizmo and hide it.

I created another branch with an example of a custom gizmo like I explained above. You will be able to view all the changes needed to be made, as well as there is a example project in a zip in that branch as well called TransformGizmoCustomGizmoExample.zip Be sure that when trying to bring these changes to your project that you take note of all the changes, even the small ones such as the rotationSpeedMultiplier variable. Since that variable is on a monobehaviour, you will need to remember to change it in your scene or your rotations might be too fast.

https://github.com/HiddenMonk/Unity3DRuntimeTransformGizmo/tree/customGizmo

I Think the changes were basically just adding TransformGizmoCustomGizmo.cs as well as changes in TransformGizmo.cs https://github.com/HiddenMonk/Unity3DRuntimeTransformGizmo/commit/dac66bbcf94ef423e6fbe3621129fe98d476758d#diff-48a5f414e391de028e1063f1523f0afd https://github.com/HiddenMonk/Unity3DRuntimeTransformGizmo/commit/dcc13a4b7cc337e3ecf248ff2bfcfdf8acafee89#diff-48a5f414e391de028e1063f1523f0afd