質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -475,3 +475,221 @@
|
|
475
475
|
}
|
476
476
|
|
477
477
|
```
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
##追記(新しいカメラのスクリプト)
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
```cs
|
486
|
+
|
487
|
+
using System.Collections;
|
488
|
+
|
489
|
+
using System.Collections.Generic;
|
490
|
+
|
491
|
+
using UnityEngine;
|
492
|
+
|
493
|
+
using UnityEngine.EventSystems;
|
494
|
+
|
495
|
+
using UnityEngine.UI;
|
496
|
+
|
497
|
+
using DG.Tweening;
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
public class CamContorl : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerDownHandler, IPointerUpHandler
|
502
|
+
|
503
|
+
{
|
504
|
+
|
505
|
+
public GameObject MainCamera;
|
506
|
+
|
507
|
+
public GameObject TargetObject;
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
private Vector3 lastMousePosition;
|
512
|
+
|
513
|
+
private Vector2 lastTouchPosition;
|
514
|
+
|
515
|
+
private Vector3 newAngle = new Vector3(0, 0, 0);
|
516
|
+
|
517
|
+
public Text text1;
|
518
|
+
|
519
|
+
public Text text2;
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
int touchID = -10;
|
524
|
+
|
525
|
+
bool doble = false;
|
526
|
+
|
527
|
+
double clickTimeAt;
|
528
|
+
|
529
|
+
// ダブルクリックと判定するクリック間隔
|
530
|
+
|
531
|
+
double asDoubleClickTime = 0.2;
|
532
|
+
|
533
|
+
public void Start()
|
534
|
+
|
535
|
+
{
|
536
|
+
|
537
|
+
DOTween.Init(false, true, LogBehaviour.ErrorsOnly);
|
538
|
+
|
539
|
+
clickTimeAt = Time.time;
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
public void OnBeginDrag(PointerEventData eventData)
|
544
|
+
|
545
|
+
{
|
546
|
+
|
547
|
+
if(touchID == -10)
|
548
|
+
|
549
|
+
{
|
550
|
+
|
551
|
+
touchID = eventData.pointerId;
|
552
|
+
|
553
|
+
}
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
public void OnEndDrag(PointerEventData eventData)
|
560
|
+
|
561
|
+
{
|
562
|
+
|
563
|
+
if(touchID == eventData.pointerId)
|
564
|
+
|
565
|
+
{
|
566
|
+
|
567
|
+
touchID = -10;
|
568
|
+
|
569
|
+
}
|
570
|
+
|
571
|
+
}
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
public void OnPointerDown(PointerEventData eventData)
|
576
|
+
|
577
|
+
{
|
578
|
+
|
579
|
+
if (Input.GetMouseButtonDown(0)) // エディタで実行中
|
580
|
+
|
581
|
+
{
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
// キーを押した間隔を時間から算出
|
586
|
+
|
587
|
+
double interval = Time.time - clickTimeAt;
|
588
|
+
|
589
|
+
text1.text = ("time:" + clickTimeAt.ToString("f2"));
|
590
|
+
|
591
|
+
text2.text = ("click:" + interval.ToString("f2"));
|
592
|
+
|
593
|
+
|
594
|
+
|
595
|
+
// 間隔がダブルクリック判定時間以下であれば
|
596
|
+
|
597
|
+
if (interval < asDoubleClickTime)
|
598
|
+
|
599
|
+
{
|
600
|
+
|
601
|
+
doble = true;
|
602
|
+
|
603
|
+
}
|
604
|
+
|
605
|
+
// クリックした時間を保存
|
606
|
+
|
607
|
+
clickTimeAt = Time.time;
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
}
|
612
|
+
|
613
|
+
newAngle = MainCamera.transform.localEulerAngles;
|
614
|
+
|
615
|
+
lastMousePosition = Input.mousePosition;
|
616
|
+
|
617
|
+
}
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
public void OnPointerUp(PointerEventData eventData)
|
622
|
+
|
623
|
+
{
|
624
|
+
|
625
|
+
lastMousePosition = Input.mousePosition;
|
626
|
+
|
627
|
+
}
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
public void OnDrag(PointerEventData eventData)
|
632
|
+
|
633
|
+
{
|
634
|
+
|
635
|
+
if (DCTF.doble == true)return;
|
636
|
+
|
637
|
+
else
|
638
|
+
|
639
|
+
{
|
640
|
+
|
641
|
+
if(lastMousePosition.y >= Screen.height * 0.28f || lastMousePosition.x >= Screen.width * 0.25f)
|
642
|
+
|
643
|
+
{
|
644
|
+
|
645
|
+
newAngle.y += (Input.mousePosition.x - lastMousePosition.x) * 0.01f;
|
646
|
+
|
647
|
+
newAngle.x -= (Input.mousePosition.y - lastMousePosition.y) * 0.01f;
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
newAngle.x = Mathf.Clamp(newAngle.x, -60, 60);//ここ
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
MainCamera.gameObject.transform.localEulerAngles = newAngle;
|
656
|
+
|
657
|
+
}
|
658
|
+
|
659
|
+
}
|
660
|
+
|
661
|
+
}
|
662
|
+
|
663
|
+
|
664
|
+
|
665
|
+
void Update()
|
666
|
+
|
667
|
+
{
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
if (doble == true)
|
672
|
+
|
673
|
+
{
|
674
|
+
|
675
|
+
Quaternion RY2 = TargetObject.transform.rotation;
|
676
|
+
|
677
|
+
RY2.z = 0;
|
678
|
+
|
679
|
+
RY2.x = 0;
|
680
|
+
|
681
|
+
TargetObject.transform.DORotateQuaternion(RY2,0.3f)
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
.OnComplete(() => doble = false);
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
}
|
690
|
+
|
691
|
+
}
|
692
|
+
|
693
|
+
}
|
694
|
+
|
695
|
+
```
|
2
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
こちらで実際にお試しいただ
|
13
|
+
こちらで実際にお試しいただけます。タッチ可能デバイスで稼働してください。
|
14
14
|
|
15
15
|
[**touch test**](https://unityroom.com/games/tuchtest)
|
16
16
|
|
1
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -396,61 +396,59 @@
|
|
396
396
|
|
397
397
|
{
|
398
398
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
399
|
+
if (Input.touchCount > 0) // タッチされているかチェック
|
400
|
+
|
401
|
+
{
|
402
|
+
|
403
|
+
Touch touch = Input.GetTouch(0); // タッチ情報の取得
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
if (touch.phase == TouchPhase.Began)
|
408
|
+
|
409
|
+
{
|
410
|
+
|
411
|
+
newAngle = MainCamera.transform.localEulerAngles;
|
412
|
+
|
413
|
+
lastTouchPosition = touch.position;
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
if (touch.phase == TouchPhase.Moved)
|
420
|
+
|
421
|
+
{
|
422
|
+
|
423
|
+
if (DCTF.doble == true)return;
|
424
|
+
|
425
|
+
else
|
426
|
+
|
427
|
+
{
|
428
|
+
|
429
|
+
if(lastTouchPosition.y >= Screen.height * 0.28f || lastTouchPosition.x >= Screen.width * 0.25f)
|
430
|
+
|
431
|
+
{
|
432
|
+
|
433
|
+
newAngle.y += (touch.position.x - lastTouchPosition.x) * 0.1f;
|
434
|
+
|
435
|
+
newAngle.x -= (touch.position.y - lastTouchPosition.y) * 0.1f;
|
436
|
+
|
437
|
+
MainCamera.gameObject.transform.localEulerAngles = newAngle;
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
lastTouchPosition = touch.position;
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
}
|
446
|
+
|
447
|
+
}
|
448
|
+
|
449
|
+
}
|
450
|
+
|
451
|
+
|
454
452
|
|
455
453
|
if (DCTF.doble == true)
|
456
454
|
|