| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL.Builder; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class BIWTranslateGizmos : BIWGizmos |
| | 7 | | { |
| | 8 | | // Start is called before the first frame update |
| 146 | 9 | | public override void SetSnapFactor(SnapInfo snapInfo) { snapFactor = snapInfo.position; } |
| | 10 | |
|
| | 11 | | public override float TransformEntity(Transform entityTransform, IBIWGizmosAxis axis, float axisValue) |
| | 12 | | { |
| 1 | 13 | | Vector3 initialEntityPosition = entityTransform.position; |
| 1 | 14 | | if (snapFactor > 0) |
| 1 | 15 | | initialEntityPosition = GetPositionRoundedToSnapFactor(entityTransform.position, axisValue); |
| | 16 | |
|
| 1 | 17 | | Vector3 move = activeAxis.axisTransform.forward * axisValue; |
| 1 | 18 | | Vector3 position = initialEntityPosition + move; |
| | 19 | |
|
| 1 | 20 | | entityTransform.position = position; |
| | 21 | |
|
| 1 | 22 | | return axisValue; |
| | 23 | | } |
| | 24 | |
|
| | 25 | | private Vector3 GetPositionRoundedToSnapFactor(Vector3 position, float axisValue) |
| | 26 | | { |
| 1 | 27 | | Vector3 activeAxisVector = GetActiveAxisVector(); |
| | 28 | |
|
| 1 | 29 | | position = new Vector3( |
| | 30 | | activeAxisVector == Vector3.right ? (axisValue >= 0 ? Mathf.Floor(position.x / snapFactor) : Mathf.Ceil(posi |
| | 31 | | activeAxisVector == Vector3.up ? (axisValue >= 0 ? Mathf.Floor(position.y / snapFactor) : Mathf.Ceil(positio |
| | 32 | | activeAxisVector == Vector3.back ? (axisValue >= 0 ? Mathf.Floor(position.z / snapFactor) : Mathf.Ceil(posit |
| | 33 | |
|
| 1 | 34 | | return position; |
| | 35 | | } |
| | 36 | | } |