teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

5

コードの追加

2018/12/02 12:58

投稿

dragontown
dragontown

スコア16

title CHANGED
File without changes
body CHANGED
@@ -39,4 +39,40 @@
39
39
  resultMin = new Vector2(Mathf.Min(v0Rot.x, v1Rot.x, v2Rot.x, v3Rot.x), Mathf.Min(v0Rot.y, v1Rot.y, v2Rot.y, v3Rot.y));
40
40
  resultMax = new Vector2(Mathf.Max(v0Rot.x, v1Rot.x, v2Rot.x, v3Rot.x), Mathf.Max(v0Rot.y, v1Rot.y, v2Rot.y, v3Rot.y));
41
41
  }
42
+
43
+
44
+ 他に該当箇所かも知れない部分です。
45
+
46
+ if (Mathf.Approximately(mouseScrollDelta, 0) == false) {
47
+ if(isEditorInputRotate == true) {
48
+ if(EnableRotation == true) {
49
+ Vector3 rotationAxis = GetRotationAxis();
50
+ Vector3 intersectionScreenCenter = GetIntersectionPoint(Cam.ScreenPointToRay(Input.mousePosition));
51
+ Transform.RotateAround(intersectionScreenCenter, rotationAxis, mouseScrollDelta * 100);
52
+ ComputeCamBoundaries();
53
+ }
54
+ } else if(isEditorInputTilt == true) {
55
+ if(EnableTilt == true) {
56
+ UpdateCameraTilt(mouseScrollDelta * 100);
57
+ }
58
+ } else {
59
+ float editorZoomFactor = 15;
60
+ if (Cam.orthographic) {
61
+ editorZoomFactor = 15;
62
+ } else {
63
+ if (IsTranslationZoom) {
64
+ editorZoomFactor = 30;
65
+ } else {
66
+ editorZoomFactor = 100;
67
+ }
68
+ }
69
+ float zoomAmount = mouseScrollDelta * editorZoomFactor;
70
+ float camSizeDiff = DoEditorCameraZoom(zoomAmount);
71
+ Vector3 intersectionScreenCenter = GetIntersectionPoint(Cam.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0)));
72
+ Vector3 pinchFocusVector = GetIntersectionPoint(Cam.ScreenPointToRay(Input.mousePosition)) - intersectionScreenCenter;
73
+ float multiplier = (1.0f / CamZoom * camSizeDiff);
74
+ Transform.position += pinchFocusVector * multiplier;
75
+ }
76
+ }
77
+
42
78
  ```

4

タイトルなど変更

2018/12/02 12:58

投稿

dragontown
dragontown

スコア16

title CHANGED
@@ -1,1 +1,1 @@
1
- 【Unity】画面の回転90°毎にぴったり止まるように制限をつけたい
1
+ 【Unity】画面の回転90°毎にぴったり止まるように制限をつけたい
body CHANGED
File without changes

3

説明の修正

2018/12/02 04:21

投稿

dragontown
dragontown

スコア16

title CHANGED
@@ -1,1 +1,1 @@
1
- 【Unity】画面の回転を90°毎にぴったり止まるようにたい
1
+ 【Unity】画面の回転を90°毎にぴったり止まるように制限をつけたい
body CHANGED
@@ -3,8 +3,8 @@
3
3
  Unityで、ピンチズームやスクロール機能をつけることができるAssetを購入して
4
4
  Main Cameraに貼ってあります。
5
5
  その中の機能に「Enable Rotation」という項目があって、
6
- これをオンにして作ると、スマホの画面を回転させることができるのですが、
6
+ これをオンにして作ると、指でスマホの画面を回転させることができるのですが、
7
- 細かな角度まで調節できてしまい、真横、真っすぐに合わせるのが難しいので、
7
+ 任意の細かな角度まで調節できてしまい、真横、真っすぐに合わせるのが難しいので、
8
8
  90°毎にピタリと合うように
9
9
 
10
10
  ̠315°~45°:0°

2

コードの訂正

2018/12/01 20:18

投稿

dragontown
dragontown

スコア16

title CHANGED
File without changes
body CHANGED
@@ -37,5 +37,6 @@
37
37
  Vector2 v2Rot = RotateVector2(v2, rotationDegrees);
38
38
  Vector2 v3Rot = RotateVector2(v3, rotationDegrees);
39
39
  resultMin = new Vector2(Mathf.Min(v0Rot.x, v1Rot.x, v2Rot.x, v3Rot.x), Mathf.Min(v0Rot.y, v1Rot.y, v2Rot.y, v3Rot.y));
40
- resultMax = new Vector2(Mathf.Max(v0Rot.x, v1Rot.x, v2Rot.x, v3Rot.x), Mathf.Max(v0Rot.y, v1Rot.y, v2Rot.y, v3Rot.y)); ```
40
+ resultMax = new Vector2(Mathf.Max(v0Rot.x, v1Rot.x, v2Rot.x, v3Rot.x), Mathf.Max(v0Rot.y, v1Rot.y, v2Rot.y, v3Rot.y));
41
+ }
41
42
  ```

1

説明の修正

2018/12/01 20:02

投稿

dragontown
dragontown

スコア16

title CHANGED
@@ -1,1 +1,1 @@
1
- 【Unity】画面の回転を45°毎にぴったり止まるようにしたい
1
+ 【Unity】画面の回転を90°毎にぴったり止まるようにしたい
body CHANGED
@@ -1,11 +1,19 @@
1
1
  ### 前提・実現したいこと
2
2
  ```
3
- Unityで、ピンチズームやスクロール機能をつけることができるAssetを購入し
3
+ Unityで、ピンチズームやスクロール機能をつけることができるAssetを購入し
4
+ Main Cameraに貼ってあります。
4
- Main Camera貼って「Enable Rotation」という項目をオンにすると
5
+ その中の機能に「Enable Rotation」という項目があって、
5
- 二本指で画面を回転させることができるのですが、
6
+ これをオンにして作ると、スマホの画面を回転させることができるのですが、
6
7
  細かな角度まで調節できてしまい、真横、真っすぐに合わせるのが難しいので、
7
- 45°毎にピタリと合うように変更したいと思っています。
8
+ 90°毎にピタリと合うように
8
9
 
10
+ ̠315°~45°:0°
11
+ 45°~135°:90°
12
+ 135°~225°:180°
13
+ 225°~315°:270°
14
+
15
+ というような感じにしたいです。
16
+
9
17
  スクリプトをどのように編集したらいいのか教えてください。
10
18
  よろしくお願いします。
11
19
  ```