Example #1
0
    private DirectionXYZ CheckDirectionalHitRayCast(RaycastHit hit)
    {
        for (int i = 0; i < MESH_COUNT; ++i)
        {
            Vector3 normalDir, meshCenter;
            int     div2 = i / 2;
            int     mod2 = i - div2 * 2;
            bool    cross1, cross2;
            float   halfScale = ObjectDefine.UNIT_VOXEL_SCALE * 0.5f;

            switch (div2)
            {
            case 0:
                normalDir  = mod2 == 0 ? Vector3.up : Vector3.down;
                meshCenter = _targetTransform.position + normalDir * halfScale;
                if (hit.point.y != meshCenter.y)
                {
                    continue;
                }
                cross1 = meshCenter.x - halfScale <= hit.point.x && hit.point.x < meshCenter.x + halfScale;
                cross2 = meshCenter.z - halfScale <= hit.point.z && hit.point.z < meshCenter.z + halfScale;
                break;

            case 1:
                normalDir  = mod2 == 0 ? Vector3.forward : Vector3.back;
                meshCenter = _targetTransform.position + normalDir * halfScale;
                if (hit.point.z != meshCenter.z)
                {
                    continue;
                }
                cross1 = meshCenter.x - halfScale <= hit.point.x && hit.point.x < meshCenter.x + halfScale;
                cross2 = meshCenter.y - halfScale <= hit.point.y && hit.point.y < meshCenter.y + halfScale;
                break;

            case 2:
                normalDir  = mod2 == 0 ? Vector3.left : Vector3.right;
                meshCenter = _targetTransform.position + normalDir * halfScale;
                if (hit.point.x != meshCenter.x)
                {
                    continue;
                }
                cross1 = meshCenter.y - halfScale <= hit.point.y && hit.point.y < meshCenter.y + halfScale;
                cross2 = meshCenter.z - halfScale <= hit.point.z && hit.point.z < meshCenter.z + halfScale;
                break;

            default:
                InstantLog.StringLogError("Invalid Mesh Count");
                return(DirectionXYZ.None);
            }

            if (cross1 && cross2)
            {
                return((DirectionXYZ)(i + 1));
            }
        }

        InstantLog.StringLogError("Invalid RayCast Hit");
        return(DirectionXYZ.None);
    }
Example #2
0
 public override async UniTask Initialize()
 {
     PhotonNetwork.autoJoinLobby = true;
     var connect = await PhotoTask.ConnectUsingSettings(RoomDefine.CONNECTING_SETTING);
     if (connect.IsFailure)
     {
         InstantLog.StringLogError(connect.ToFailure.Value);
         return;
     }
 }
Example #3
0
        public void ResolveAnchorFromId(string cloudAnchorId)
        {
            XPSession.ResolveCloudAnchor(cloudAnchorId).ThenAction((System.Action <CloudAnchorResult>)(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    InstantLog.StringLogError("Failed to host anchor");
                    return;
                }

                _anchorModel.SetResolvedAnchorInfo(result.Anchor);
            }));
        }
Example #4
0
 private async UniTask FailureHandlingPhotonTask(Task<IResult<FailureReason, bool>> task, Action<IResult<FailureReason, bool>> onSuccess = null, Action<IResult<FailureReason, bool>> onFailure = null)
 {
     var result = await task;
     if(result.IsSuccess)
     {
         InstantLog.ObjectLog($"Photon Network Success : {result}", StringExtensions.TextColor.cyan);
         onSuccess?.Invoke(result);
     }
     else
     {
         InstantLog.ObjectLog($"Photon Network Error : {result}", StringExtensions.TextColor.magenta);
         onFailure?.Invoke(result);
     }
 }
Example #5
0
        /// <summary>
        /// Hosts the user placed cloud anchor and associates the resulting Id with the current room.
        /// </summary>
        public void HostLastPlacedAnchor()
        {
#if !UNITY_IOS
            var anchor = (Anchor)_anchorModel.PlacedAnchorRoot.Value;
#else
            var anchor = (UnityEngine.XR.iOS.UnityARUserAnchorComponent)_anchorModel.PlacedAnchorRoot.Value;
#endif
            XPSession.CreateCloudAnchor(anchor).ThenAction(result =>
            {
                if (result.Response != CloudServiceResponse.Success)
                {
                    InstantLog.StringLogError("Failed to host anchor");
                    return;
                }

                _anchorModel.SetPlacedAnchorRoot(true, result.Anchor);
            });
        }