protected virtual void OnGUI() { if (CheckFocusEnter()) { var ray = targetCamera.ScreenPointToRay(Input.mousePosition); var hitInfo = new RaycastHit(); if (Physics.Raycast(ray, out hitInfo, maxRayDistance, layerMask)) { var alignMark = hitInfo.transform.GetComponent <AlignMarkTarget>(); if (alignMark) { if (IsFocus == false) { defaultAlign = new AlignTarget(alignCamera.GetTarget(), alignCamera.CurrentAngles, alignCamera.CurrentDistance, alignCamera.angleRange, alignCamera.distanceRange); IsFocus = true; } alignCamera.AlignVeiwToTarget(alignMark.alignTarget); } } } else if (IsFocus && CheckFocusExit()) { alignCamera.AlignVeiwToTarget(defaultAlign); IsFocus = false; } }
//private void ChangeCameraTarget(GameObject target,Vector3) //{ // mouseTranslate.SetTranslatePosition(mouseTranslatePro.areaSettings.center.position); // GameObject factory = GameObject.Find("PowerPlantPark"); // cameraControl.AlignVeiwToTarget(factory.transform, angles, distance); //} /// <summary> /// 退出全景模式 /// </summary> private void ExitFullView() { MouseTranslate.enabled = true; CameraControl.enabled = true; //MouseTranslate.areaSettings.center = FactoryPositon.transform; MouseTranslate.areaSettings.SetCenter(FactoryPositon.transform); MouseTranslate.SetTranslatePosition(FactoryPositon.transform.position); CameraControl.AlignVeiwToTarget(MouseTranslate.transform, DefaultAngles, DefaultDistance); CameraControl.gameObject.SetActive(false); FullViewCanvas.SetActive(false); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { mouseTranslatePro.SetTranslatePosition(mouseTranslatePro.areaSettings.GetPos()); aroundAlignCamera.AlignVeiwToTarget(aroundAlignCamera.GetTarget(), angles, distance); //aroundAlignCamera.CurrentAngles = angles; //aroundAlignCamera. //CurrentOffset = Vector3.Lerp(CurrentOffset, targetOffset, damper * Time.deltaTime); //aroundAlignCamera.target.position = Vector3.Lerp(aroundAlignCamera.target.position, Center.position, middleDamper * Time.deltaTime); //aroundAlignCamera.target.position = Center.position; } }
/// <summary> /// 恢复到初始视角 /// </summary> public void ReturnToDefaultAlign(Action onComplete = null, Action onBreakAction = null) { OnAlignEndAction = onComplete; if (OnBreakAction != null) { OnBreakAction(); } OnBreakAction = onBreakAction; IsFocus = false; IsMouseTranslateSet = true; mouseTranslate.ResetTranslateOffset(); AreaSize = new Vector2(defaultTranslatePro.areaSettings.length, defaultTranslatePro.areaSettings.width); mouseTranslate.areaSettings = defaultTranslatePro.areaSettings; mouseTranslate.mouseSettings = defaultTranslatePro.mouseSettings; mouseTranslate.targetCamera = defaultTranslatePro.targetCamera; //mouseTranslate.SetTranslatePosition(mouseTranslate.areaSettings.center.position); alignCamera.AlignVeiwToTarget(defaultAlign); }