60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Animations;
|
|
|
|
public class CameraState : MonoBehaviour
|
|
{
|
|
public float TargetTime;
|
|
private float timer;
|
|
private Animator animator;
|
|
private Vector3 mouseStartPosition;
|
|
private bool hasMouseMoved = false;
|
|
void Start()
|
|
{
|
|
animator = GetComponent<Animator>();
|
|
animator.enabled = true;
|
|
GetComponent<MoveCameraByMouse>().ison = false;
|
|
}
|
|
bool ison;
|
|
void Update()
|
|
{
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
mouseStartPosition = Input.mousePosition;
|
|
hasMouseMoved = false;
|
|
}
|
|
if (Input.GetMouseButtonUp(0))
|
|
hasMouseMoved = false;
|
|
if (Input.GetMouseButton(0))
|
|
{
|
|
if (!hasMouseMoved && Vector3.Distance(mouseStartPosition, Input.mousePosition) > 1f)
|
|
{
|
|
hasMouseMoved = true;
|
|
}
|
|
}
|
|
if (hasMouseMoved || Input.GetAxis("Mouse ScrollWheel") != 0)
|
|
{
|
|
ison = false;
|
|
timer = 0;
|
|
animator.enabled = false;
|
|
GetComponent<MoveCameraByMouse>().ison = true;
|
|
}
|
|
else
|
|
timer += Time.deltaTime;
|
|
if (timer >= TargetTime)
|
|
{
|
|
if (!ison)
|
|
{
|
|
BrideWebView.Instance.webViewPrefab.WebView.PostMessage("无操作标识");
|
|
ison = true;
|
|
}
|
|
animator.enabled = true;
|
|
GetComponent<MoveCameraByMouse>().ison = false;
|
|
//Debug.Log("启动动画");
|
|
}
|
|
}
|
|
}
|