예제 #1
0
        public override void Awake()
        {
            base.Awake();

            processor = new UnityTexture2DProcessor();

            Find.Any(out loadingBar);
            Find.Any(out gps);
            if (!this.FindClosest(out photospheres))
            {
                photospheres = this.Ensure <PhotosphereManager>();
            }

            Find.Any(out avatar);
            navPlane = avatar.GroundPlane.Ensure <Clickable>();
            navPlane.Activate();
            navPointer = transform.Find("NavPointer");
            if (navPointer != null)
            {
                navPointer.Deactivate();
            }

            Find.Any(out input);

            cache = new CachingStrategy();

#if UNITY_EDITOR
            this.ReceiveCredentials();

            locationInput = this.Ensure <EditorTextInput>();
            locationInput.OnSubmit.AddListener(new UnityAction <string>(SetLocation));
            if (!string.IsNullOrEmpty(locationInput.value))
            {
                SetLocation(locationInput.value);
            }
            else if (gps != null && gps.HasCoord)
            {
                SetLocation(gps.Coord.ToString());
            }

            var userProfile    = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            var assetsRoot     = Path.Combine(userProfile, "Box", "VR Initiatives", "Engineering", "Assets");
            var oldCubemapPath = Path.Combine(assetsRoot, "GoogleMaps");
            var oldGmapsPath   = Path.Combine(oldCubemapPath, "streetview", "maps", "api");

            cache.AddBackup(new FileCacheLayer(oldCubemapPath));
            cache.AddBackup(new FileCacheLayer(oldGmapsPath));
#else
            if (gps != null && gps.HasCoord)
            {
                SetLocation(gps.Coord.ToString());
            }
#endif

            var newGmapsPath = Path.Combine(CachePrefix, "Google", "StreetView");
            cache.Add(new StreamingAssetsCacheLayer(newGmapsPath));
            codec = new UnityTexture2DCodec(MediaType.Image.Jpeg);

            var metadataDecoder  = new JsonFactory <MetadataTypeT>();
            var geocodingDecoder = new JsonFactory <GeocodingResponse>();

            gmaps = new GoogleMapsClient <MetadataTypeT>(gmapsApiKey, gmapsSigningKey, metadataDecoder, geocodingDecoder, cache);

            photospheres.CubemapNeeded += Photosphere_CubemapNeeded;

            photospheres.SetIO(cache, codec);
            photospheres.SetDetailLevels(searchFOVs);
        }