Exemplo n.º 1
0
        /// <summary>
        /// 计算适口偏移值
        /// </summary>
        /// <returns>The offset position.</returns>
        /// <param name="handPosition">Hand position.</param>
        /// <param name="grabObject">Grab object.</param>
        public static Vector3 GetOffsetPosition(Vector3 handPosition, GameObject grabObject)
        {
            var     offset       = Vector3.zero;
            Vector3 screenDevice = MUtility.MainWorldToScreenPoint(grabObject.transform.position);
            Vector3 vPos         = MUtility.MainScreenToWorldPoint(new Vector3(handPosition.x, handPosition.y, screenDevice.z));

            offset = vPos - grabObject.transform.position;

            return(offset);
        }
Exemplo n.º 2
0
        public static void SetObjectGrab(GameObject target, int handIndex = 0)
        {
            var operate = GetOperateHand(handIndex);

            if (operate == null)
            {
                return;
            }

            Vector3 tempPos = MUtility.MainWorldToScreenPoint(target.transform.position - new Vector3(0, 0, MUtility.MainCamera.transform.position.z));

            tempPos = MUtility.MainScreenToWorldPoint(tempPos);

            operate.SetObjectGrab(target, tempPos.z);
        }