private void OnGoogleStreetViewSuccess(GoogleStreetViewRequest request) { string panoID = request.panoID; currentRequest = null; if (!request.hasErrors) { if (panoRenderer == null) { map.control.allowUserControl = false; panoRenderer = SphericalPanoRenderer.CreateSphere(request.texture, radius, segments); panoRenderer.shader = Shader.Find("Unlit/Texture"); panoRenderer.gameObject.AddComponent <KeyboardControl>(); panoRenderer.gameObject.AddComponent <MouseControl>(); panoRenderer.gameObject.AddComponent <Limits>(); if (closeButtonPrefab != null && closeButtonInstance == null) { Canvas canvas = CanvasUtils.GetCanvas(); if (canvas != null) { closeButtonInstance = Instantiate(closeButtonPrefab); closeButtonInstance.transform.SetParent(canvas.transform, false); closeButtonInstance.GetComponentInChildren <Button>().onClick.AddListener(Close); } } } else { if (panoRenderer.texture != null) { Destroy(panoRenderer.texture); } panoRenderer.texture = request.texture; } } else { Debug.Log(request.error); } if (zoom < 3) { zoom++; currentRequest = new GoogleStreetViewRequest(googleApiKey, panoID, zoom, panoRenderer.texture as Texture2D); currentRequest.OnComplete += OnGoogleStreetViewSuccess; } }
private void OnGoogleStreetViewSuccess(GoogleStreetViewRequest request) { currentRequest = null; if (request.hasErrors) { Debug.Log(request.error); return; } string panoID = request.panoID; if (panoRenderer == null) { map.control.allowUserControl = false; panoRenderer = SphericalPanoRenderer.CreateSphere(request.texture, radius, segments); if (useRotation && OnlineMapsCameraOrbit.instance != null) { panoRenderer.pano.pan = OnlineMapsCameraOrbit.instance.rotation.y; } else { panoRenderer.pano.pan = 0; } panoRenderer.shader = shader != null ? shader : Shader.Find("Unlit/Texture"); panoRenderer.gameObject.AddComponent <DirectionManager>(); panoRenderer.gameObject.AddComponent <HotSpotManager>(); panoRenderer.gameObject.AddComponent <KeyboardControl>(); panoRenderer.gameObject.AddComponent <MouseControl>(); panoRenderer.gameObject.AddComponent <Limits>(); if (closeButtonPrefab != null && closeButtonInstance == null) { Canvas canvas = CanvasUtils.GetCanvas(); if (canvas != null) { closeButtonInstance = Instantiate(closeButtonPrefab); closeButtonInstance.transform.SetParent(canvas.transform, false); closeButtonInstance.GetComponentInChildren <Button>().onClick.AddListener(Close); } } StartShowTransition(); } else { if (panoRenderer.texture != null) { Destroy(panoRenderer.texture); } panoRenderer.texture = request.texture; } DirectionManager directionManager = panoRenderer.GetComponent <DirectionManager>(); if (request.meta != null) { meta = request.meta; float pan = panoRenderer.pano.pan; panoRenderer.pano.northPan = meta.northPan; panoRenderer.pano.pan = pan; CreateDirections(directionManager); } if (zoom < panoramaMaxZoom) { zoom++; currentRequest = new GoogleStreetViewRequest(googleApiKey, panoID, zoom); currentRequest.OnComplete += OnGoogleStreetViewSuccess; } }