using System.Collections; using System.Collections.Generic; using UnityEngine; using AX.MessageSystem; using AX.InputSystem; using System; [RequireComponent(typeof(CameraManager))] public class CameraScale : MonoBehaviour { private float timeStart; private float timeEnd; private CameraManager cameraManager; // Use this for initialization void Start() { cameraManager = GetComponent(); MessageDispatcher.AddListener("RecordStatusPause", changed); } private void changed(IMessage obj) { if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.pause) { if (timeStart != 0 && timeEnd == 0) { timeEnd = RecordManager.Instance.RecordTimer; cameraManager.AddRecordCamera(timeStart, timeEnd - timeStart); timeStart = 0; } } } // Update is called once per frame void Update() { } void OnEnable() { MessageDispatcher.AddListener("MIDDLE_MOUSE_SCROLL_COMMAND", Execute); } void OnDisable() { MessageDispatcher.RemoveListener("MIDDLE_MOUSE_SCROLL_COMMAND", Execute); } void OnDestroy() { MessageDispatcher.RemoveListener("MIDDLE_MOUSE_SCROLL_COMMAND", Execute); } private void Execute(IMessage obj) { var data = (CameraCmdArgs)obj.Data; cameraManager.UpdateCameraScaleData(data.mouseScroll, data.distance); if (data.mouseScroll != 0 && data.distance == 0) { timeStart = RecordManager.Instance.RecordTimer; } if (data.mouseScroll == 0) { timeEnd = RecordManager.Instance.RecordTimer; if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) { cameraManager.AddRecordCamera(timeStart, timeEnd - timeStart); timeStart = 0; timeEnd = 0; } } } }