質問編集履歴

3

句読点を追記。

2018/11/04 12:11

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -142,7 +142,7 @@
142
142
 
143
143
  //ポインタ位置差分を求めた後で、現在のポインタ位置をprevPosに代入し、次回のUpdate実行に備える。
144
144
 
145
- //この「現在のポインタ位置」が、次フレームでは「前フレームのポインタ位置」となる
145
+ //この「現在のポインタ位置」が、次フレームでは「前フレームのポインタ位置」となる
146
146
 
147
147
  prevPos = Input.mousePosition;
148
148
 

2

追記

2018/11/04 12:11

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -109,3 +109,45 @@
109
109
  }
110
110
 
111
111
  ```
112
+
113
+
114
+
115
+ ### MEMO
116
+
117
+
118
+
119
+ タッチのdeltaPositionを、マウスで表現すると下記のようなmouseDeltaPositionになる。
120
+
121
+ ```C#
122
+
123
+ void Update()
124
+
125
+ {
126
+
127
+ if (Input.GetMouseButtonDown(0))
128
+
129
+ {
130
+
131
+ prevPos = Input.mousePosition;
132
+
133
+ }
134
+
135
+ else if (Input.GetMouseButton(0))
136
+
137
+ {
138
+
139
+ mouseDeltaPosition = Input.mousePosition - prevPos;
140
+
141
+
142
+
143
+ //ポインタ位置差分を求めた後で、現在のポインタ位置をprevPosに代入し、次回のUpdate実行に備える。
144
+
145
+ //この「現在のポインタ位置」が、次フレームでは「前フレームのポインタ位置」となる
146
+
147
+ prevPos = Input.mousePosition;
148
+
149
+
150
+
151
+ (省略)
152
+
153
+ ```

1

追記作成。

2018/11/04 12:06

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -67,3 +67,45 @@
67
67
  }
68
68
 
69
69
  ```
70
+
71
+ ### 追記。
72
+
73
+ タッチの場合は、なぜRotateで実装できたのでしょうか?
74
+
75
+ 可能ならば、なるべくこれに近いコード(Rotateを使ったコード)で、エディタの方も実装したいです。
76
+
77
+
78
+
79
+ ```
80
+
81
+ int touchCount = Input.touches.Count(t => t.phase != TouchPhase.Ended && t.phase != TouchPhase.Canceled);
82
+
83
+
84
+
85
+ if (touchCount == 1)
86
+
87
+ {
88
+
89
+ Touch t = Input.touches.First();
90
+
91
+ switch (t.phase)
92
+
93
+ {
94
+
95
+ case TouchPhase.Moved:
96
+
97
+
98
+
99
+ xAngle = (t.deltaPosition.y/Screen.height)*90;
100
+
101
+ yAngle = -(t.deltaPosition.x/Screen.width)*90;
102
+
103
+ break;
104
+
105
+ }
106
+
107
+ this.transform.Rotate(xAngle, yAngle, zAngle, Space.World);
108
+
109
+ }
110
+
111
+ ```