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);
        }
Example #2
0
 // Use this for initialization
 void Start()
 {
     psManager = GetComponentInParent <PhotosphereManager> ();
 }
Example #3
0
    // Use this for initialization
    void Start()
    {
        gameObject.name    = photosphereImage.name;
        photosphereManager = FindObjectOfType <PhotosphereManager> ();

        //apply overrides or get info from manager
        if (smallSizeOverride == 0)
        {
            if (photosphereManager)
            {
                smallSize = photosphereManager.smallSize;
            }
            else
            {
                smallSize = .1f;
            }
        }
        else
        {
            smallSize = smallSizeOverride;
        }
        if (largeSizeOverride == 0f)
        {
            if (photosphereManager)
            {
                largeSize = photosphereManager.largeSize;
            }
            else
            {
                largeSize = 40f;
            }
        }
        else
        {
            largeSize = largeSizeOverride;
        }
        if (animationTimeOverride == 0f)
        {
            if (photosphereManager)
            {
                animationTime = photosphereManager.animationTime;
            }
            else
            {
                animationTime = 2f;
            }
        }
        else
        {
            animationTime = animationTimeOverride;
        }
        if (basePhotosphereMaterialOverride == null)
        {
            if (photosphereManager)
            {
                basePhotosphereMaterial = photosphereManager.basePhotosphereMaterial;
            }
            else
            {
                basePhotosphereMaterial = new Material(Shader.Find("Standard"));
            }
        }
        else
        {
            basePhotosphereMaterial = basePhotosphereMaterialOverride;
        }
        if (selectedSphereMaterialOverride == null)
        {
            if (photosphereManager)
            {
                selectedSphereMaterial = photosphereManager.selectedSphereMaterial;
            }
            else
            {
                selectedSphereMaterial       = new Material(Shader.Find("Standard"));
                selectedSphereMaterial.color = new Color(.5f, 1, 1, .5f);
            }
        }
        else
        {
            selectedSphereMaterial = selectedSphereMaterialOverride;
        }



        //setup materials
        largeMaterial = GenerateSphereMaterial(basePhotosphereMaterial, photosphereImage);
        if (photosphereThumbnail != null)
        {
            smallMaterial = GenerateSphereMaterial(basePhotosphereMaterial, photosphereThumbnail);
        }
        else
        {
            try
            {
                photosphereThumbnail = GenerateThumbnail(photosphereImage);
                smallMaterial        = GenerateSphereMaterial(basePhotosphereMaterial, photosphereThumbnail);
            }
            catch (System.Exception ex)
            {
                Debug.LogWarning(photosphereImage.name + " is not read/write enabled. " +
                                 "Defaulting to large image on both large and small spheres. " +
                                 "This will hurt performance. Please go to import settinss and " +
                                 "'enable read/write' under 'Advanced'. System Exception: " + ex);
                smallMaterial = GenerateSphereMaterial(basePhotosphereMaterial, photosphereImage);
            }
        }

        //setup selected sphere stuff
        selectedSphere.name = gameObject.name + " Selected";
        selectedSphere.transform.position   = transform.position;
        selectedSphere.transform.localScale = new Vector3(smallSize * .9f, smallSize * .9f, smallSize * .9f);
        MeshFilter meshFilter = selectedSphere.AddComponent <MeshFilter>();

        meshFilter.mesh = GetComponent <MeshFilter>().mesh;
        MeshRenderer meshRenderer = selectedSphere.AddComponent <MeshRenderer>();

        meshRenderer.material = selectedSphereMaterial;
        selectedSphere.AddComponent <SphereCollider>();
        selectedSphere.layer = gameObject.layer;
        //make button on selected sphere to close it
        selectedSphere.AddComponent <SpatialButton>();
        SpatialButton selectedSphereButton = selectedSphere.GetComponent <SpatialButton>();

        selectedSphereButton.calledOnClick.AddListener(DeselectSphere);

        //sets the current sphere to the small material
        GetComponent <MeshRenderer>().material = smallMaterial;

        //apply default settings to all the balls
        foreach (var item in FindObjectsOfType <PhotosphereBall>())
        {
            item.Shrink();
        }
    }