質問編集履歴

3

再追記

2020/08/04 12:39

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -473,3 +473,11 @@
473
473
  ![イメージ説明](80b6606ac3583db7d94daaf30261055c.png)
474
474
 
475
475
  ![![イメージ説明](4e3d9d1e26e23ae0fd994bd1bf61f801.png)
476
+
477
+
478
+
479
+ 【再追記】
480
+
481
+
482
+
483
+ エディター上では、色漏れが見えないのですが、ビルドして、ゲームを配布形式にすると、謎の線が生じる現象が起きます。

2

修正

2020/08/04 12:39

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -472,4 +472,4 @@
472
472
 
473
473
  ![イメージ説明](80b6606ac3583db7d94daaf30261055c.png)
474
474
 
475
- ![![イメージ説明](4e3d9d1e26e23ae0fd994bd1bf61f801.png)](05de09abe6c9e8cdfe770eba735e5b03.png)
475
+ ![![イメージ説明](4e3d9d1e26e23ae0fd994bd1bf61f801.png)

1

追記と画像の追加

2020/08/04 12:27

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -185,3 +185,291 @@
185
185
 
186
186
 
187
187
  ![イメージ説明](dbf113073dc9f57999044c7f47ae79f9.png)
188
+
189
+
190
+
191
+ 【追記】
192
+
193
+
194
+
195
+ CameraのorthographicSizeを変更したときに、謎の線やちらつきが生じるようです。
196
+
197
+
198
+
199
+ ```C#
200
+
201
+ using System.Collections;
202
+
203
+ using System.Collections.Generic;
204
+
205
+ using UnityEngine;
206
+
207
+ using System.Diagnostics;
208
+
209
+ using System;
210
+
211
+
212
+
213
+ public class CameraScript : MonoBehaviour
214
+
215
+ {
216
+
217
+ private Camera m_cam;
218
+
219
+ private float zoomSpeed = 10f * 3;
220
+
221
+ private float scrollSpeed = 20f * 5;
222
+
223
+ private float dragSpeed = 0.5f;
224
+
225
+ public Vector2 zoom = new Vector2(3f, 100f);
226
+
227
+ [HideInInspector]
228
+
229
+ public float targetZoom;
230
+
231
+ private bool wait = true;
232
+
233
+ public int size;
234
+
235
+ [NonSerialized]
236
+
237
+ public bool editor = true;
238
+
239
+ public Camera cam
240
+
241
+ {
242
+
243
+ get
244
+
245
+ {
246
+
247
+ if (this.m_cam == null)
248
+
249
+ {
250
+
251
+ this.m_cam = base.GetComponent<Camera>();
252
+
253
+ }
254
+
255
+ return this.m_cam;
256
+
257
+ }
258
+
259
+ }
260
+
261
+ public float currentZoom
262
+
263
+ {
264
+
265
+ get
266
+
267
+ {
268
+
269
+ return this.cam.orthographicSize;
270
+
271
+ }
272
+
273
+ set
274
+
275
+ {
276
+
277
+ if (this.cam.orthographicSize == value)
278
+
279
+ {
280
+
281
+ return;
282
+
283
+ }
284
+
285
+ this.cam.orthographicSize = value;
286
+
287
+ }
288
+
289
+ }
290
+
291
+ private void Start()
292
+
293
+ {
294
+
295
+ Application.targetFrameRate = 60;
296
+
297
+ this.currentZoom = 300;
298
+
299
+ this.targetZoom = size;
300
+
301
+ base.transform.position = new Vector3(base.transform.position.x, base.transform.position.y,
302
+
303
+ -this.currentZoom);
304
+
305
+ base.StartCoroutine("Starter");
306
+
307
+ }
308
+
309
+ [DebuggerHidden]
310
+
311
+ private IEnumerator Starter()
312
+
313
+ {
314
+
315
+ this.zoomSpeed /= 2f;
316
+
317
+ yield return new WaitForSeconds(1f);
318
+
319
+ this.targetZoom = size;
320
+
321
+ /*while(this.currentZoom > 33f)
322
+
323
+ {
324
+
325
+ yield return new WaitForSeconds(0.333f);
326
+
327
+ }*/
328
+
329
+ this.zoomSpeed *= 2f;
330
+
331
+ this.wait = false;
332
+
333
+ }
334
+
335
+ private void Update()
336
+
337
+ {
338
+
339
+ if (!this.wait)
340
+
341
+ {
342
+
343
+ this.MovementKeyboardGame();
344
+
345
+ this.MovementMouseGame();
346
+
347
+ this.ZoomMouse();
348
+
349
+ }
350
+
351
+
352
+
353
+ if (editor)
354
+
355
+ {
356
+
357
+ float xPos = Mathf.Clamp(transform.position.x, 0, 200);
358
+
359
+ float yPos = Mathf.Clamp(transform.position.y, 0, 200);
360
+
361
+
362
+
363
+ transform.position = new Vector3(xPos, yPos, -currentZoom);
364
+
365
+ }
366
+
367
+ }
368
+
369
+ private void FixedUpdate()
370
+
371
+ {
372
+
373
+ this.GoToTargetZoom();
374
+
375
+ }
376
+
377
+ private void MovementMouseGame()
378
+
379
+ {
380
+
381
+ if (Input.GetMouseButton(2))
382
+
383
+ {
384
+
385
+ base.transform.Translate(-new Vector3(Input.GetAxis("Mouse X") * this.dragSpeed * Time.deltaTime * 100f, Input.GetAxis("Mouse Y") * this.dragSpeed * Time.deltaTime * 100f, 0f));
386
+
387
+ }
388
+
389
+ }
390
+
391
+
392
+
393
+ private void MovementKeyboardGame()
394
+
395
+ {
396
+
397
+ base.transform.Translate(new Vector3(Input.GetAxis("Horizontal") * this.scrollSpeed * Time.deltaTime, Input.GetAxis("Vertical") * this.scrollSpeed * Time.deltaTime, 0f));
398
+
399
+ }
400
+
401
+
402
+
403
+ private void ZoomMouse()
404
+
405
+ {
406
+
407
+ if (Input.GetAxis("Mouse ScrollWheel") != 0f)
408
+
409
+ {
410
+
411
+ this.targetZoom -= Input.GetAxis("Mouse ScrollWheel") * this.zoomSpeed;
412
+
413
+ this.targetZoom = Mathf.Clamp(this.targetZoom, this.zoom.x, this.zoom.y);
414
+
415
+ }
416
+
417
+ }
418
+
419
+
420
+
421
+ private void GoToTargetZoom()
422
+
423
+ {
424
+
425
+ if (this.currentZoom != this.targetZoom)
426
+
427
+ {
428
+
429
+ float num = Mathf.Clamp(Mathf.Abs(this.currentZoom - this.targetZoom), 0.3f, 0.5f);
430
+
431
+ float t = Time.deltaTime * this.zoomSpeed * num;
432
+
433
+ float num2 = Mathf.Lerp(this.currentZoom, this.targetZoom, t);
434
+
435
+ if (Mathf.Abs(num2 - this.targetZoom) < 0.01f)
436
+
437
+ {
438
+
439
+ this.currentZoom = this.targetZoom;
440
+
441
+ }
442
+
443
+ else
444
+
445
+ {
446
+
447
+ this.currentZoom = num2;
448
+
449
+ }
450
+
451
+ if (this.currentZoom >= 5f && this.currentZoom != -base.transform.position.z)
452
+
453
+ {
454
+
455
+ base.transform.Translate(new Vector3(0f, 0f, -(this.currentZoom + base.transform.position.z)));
456
+
457
+ }
458
+
459
+ }
460
+
461
+ }
462
+
463
+ }
464
+
465
+ ```
466
+
467
+
468
+
469
+ 【色漏れが起こっているテクスチャの画像】
470
+
471
+
472
+
473
+ ![イメージ説明](80b6606ac3583db7d94daaf30261055c.png)
474
+
475
+ ![![イメージ説明](4e3d9d1e26e23ae0fd994bd1bf61f801.png)](05de09abe6c9e8cdfe770eba735e5b03.png)