예제 #1
0
 /// <summary>
 /// On component draw GUI.
 /// </summary>
 protected virtual void OnGUI()
 {
     if (CheckFocusEnter())
     {
         var ray = targetCamera.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out RaycastHit hitInfo, maxDistance, layerMask))
         {
             var alignMark = hitInfo.transform.GetComponent <AlignMark>();
             if (alignMark)
             {
                 if (IsFocus == false)
                 {
                     defaultAlign = new AlignTarget(alignCamera.target, alignCamera.CurrentAngles,
                                                    alignCamera.CurrentDistance, alignCamera.angleRange, alignCamera.distanceRange);
                     IsFocus = true;
                 }
                 alignCamera.AlignVeiwToTarget(alignMark.alignTarget);
             }
         }
     }
     else if (IsFocus && CheckFocusExit())
     {
         alignCamera.AlignVeiwToTarget(defaultAlign);
         IsFocus = false;
     }
 }
        /// <summary>
        /// Align camera veiw to target.
        /// </summary>
        /// <param name="alignTarget">Target of camera align.</param>
        public void AlignVeiwToTarget(AlignTarget alignTarget)
        {
            AlignVeiwToTarget(alignTarget.center, alignTarget.angles, alignTarget.distance);

            //Override range.
            angleRange    = alignTarget.angleRange;
            distanceRange = alignTarget.distanceRange;
        }
예제 #3
0
 private void AlignCameraToMark(AlignMark alignMark)
 {
     if (isAlign == false)
     {
         isAlign      = true;
         defaultAlign = new AlignTarget(alignCamera.target, alignCamera.CurrentAngles,
                                        alignCamera.CurrentDistance, alignCamera.angleRange, alignCamera.distanceRange);
     }
     alignCamera.AlignVeiwToTarget(alignMark.alignTarget);
 }
예제 #4
0
 /// <summary>
 /// Reset component.
 /// </summary>
 protected virtual void Reset()
 {
     //Reset align target.
     alignTarget = new AlignTarget(transform, new Vector2(30, 0), 5, new Range(-90, 90), new Range(1, 10));
 }