Example #1
0
    private void OnEnable()
    {
        if (!_photosphereController)
        {
            _photosphereController = FindObjectOfType <PhotosphereController>();
        }

        _photosphereController.AddPhotosphere(this);
    }
Example #2
0
    private void CreateNewPhotosphereGroup()
    {
        PhotosphereController photosphereController = FindPhotosphereController();

        GameObject photosphereGroup = new GameObject();

        photosphereGroup.name = "Photosphere Group";

        photosphereGroup.transform.parent = photosphereController.transform;

        _autoConnectedPhotospheres = new List <Photosphere>();

        int zOffset = 0;

        string[] photoSphereAssets = AssetDatabase.FindAssets("t:texture, t:videoclip", new[] { photoSphereAssetsPath });

        // for each texture asset found,
        foreach (string asset in photoSphereAssets)
        {
            Type assetType = AssetDatabase.GetMainAssetTypeAtPath(AssetDatabase.GUIDToAssetPath(asset));

            if (assetType == typeof(Texture2D))
            {
                photoTexture      = (Texture)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(asset), typeof(Texture));
                photoTexture.name = Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(asset));
            }
            else if (assetType == typeof(VideoClip))
            {
                videoClip      = (VideoClip)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(asset), typeof(VideoClip));
                videoClip.name = Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(asset));
            }

            CreateNewPhotosphere(photosphereGroup.transform, zOffset);

            // space out photospheres 8 units apart
            zOffset = zOffset + 8;

            photoTexture = null;
            videoClip    = null;
        }

        if (autoConnectPhotospheres)
        {
            for (int i = 0; i < _autoConnectedPhotospheres.Count; i++)
            {
                // dont need to connect last photosphere as it will already be connected
                if (i < _autoConnectedPhotospheres.Count - 1)
                {
                    _selectedPhotospheres.Clear();
                    _selectedPhotospheres.Add(_autoConnectedPhotospheres[i]);
                    _selectedPhotospheres.Add(_autoConnectedPhotospheres[i + 1]);
                    ConnectPhotospheres();
                }
            }
        }
    }
Example #3
0
        // used in editor through photosphere editor
        public void SetDestination(GameObject target)
        {
            destinationSphereName = target.name;

            if (_photosphereController == null)
            {
                _photosphereController = transform.root.GetComponent <PhotosphereController>();
            }

            _destinationTransform = _photosphereController.FindPhotosphereTransform(destinationSphereName);

            Debug.Log(_destinationTransform);
        }
Example #4
0
        private void Awake()
        {
            _photosphere = transform.parent.parent.GetComponent <Photosphere>();

            if (_VRInteractiveItem == null)
            {
                _VRInteractiveItem = GetComponent <VRInteractiveItem>();
            }

            if (Application.isPlaying)
            {
                _material = GetComponent <MeshRenderer>().material;
            }

            if (_photosphereController == null)
            {
                _photosphereController = transform.root.GetComponent <PhotosphereController>();
            }
        }
Example #5
0
    private void DisconnectPhotospheres()
    {
        Debug.Log("Disconnecting " + _selectedPhotospheres.Count + " Photospheres");

        PhotosphereController photosphereController = FindPhotosphereController();

        // for each selected photosphere
        for (int i = 0; i < _selectedPhotospheres.Count; i++)
        {
            // get teleporters
            TelportVrScript[] teleporters = _selectedPhotospheres[i].gameObject.transform.GetChild(1).GetComponentsInChildren <TelportVrScript>(true);

            // disconnect each teleporter
            for (int t = 0; t < teleporters.Length; t++)
            {
                if (teleporters[t].destinationSphereName != "")
                {
                    // store this as will be wiped in DisconnectTeleporter
                    string sphereDestinationName = teleporters[t].destinationSphereName;

                    DisconnectTeleporter(teleporters[t]);

                    // check all other photospheres and disconnect them if necessary
                    for (int j = 0; j < photosphereController.photospheres.Count; j++)
                    {
                        if (photosphereController.photospheres[j].gameObject.name == sphereDestinationName)
                        {
                            TelportVrScript[] otherTeleporters = photosphereController.photospheres[j].gameObject.transform.GetChild(1).GetComponentsInChildren <TelportVrScript>(true);

                            // disconnect each other teleporter if it matches the first one we disconnected
                            for (int y = 0; y < otherTeleporters.Length; y++)
                            {
                                if (otherTeleporters[y].destinationSphereName == _selectedPhotospheres[i].gameObject.name)
                                {
                                    DisconnectTeleporter(otherTeleporters[y]);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Example #6
0
    // Find any broken teleporter connections to photospheres that no longer exist
    private void CleanUpPhotospheres()
    {
        PhotosphereController photosphereController = FindPhotosphereController();

        for (int i = 0; i < photosphereController.photospheres.Count; i++)
        {
            // get teleporters, only need to check ones that are enabled
            TelportVrScript[] teleporters = photosphereController.photospheres[i].gameObject.transform.GetChild(1).GetComponentsInChildren <TelportVrScript>(false);

            // check each teleporter to find missing connection
            for (int t = 0; t < teleporters.Length; t++)
            {
                if (photosphereController.FindPhotosphereTransform(teleporters[t].destinationSphereName) == null)
                {
                    DisconnectTeleporter(teleporters[t]);
                }
            }
        }
    }
Example #7
0
    static void OnHierarchyChanged()
    {
        if (!Application.isPlaying && Resources.FindObjectsOfTypeAll(typeof(PhotosphereEditor)).Length > 0)
        {
            PhotosphereController photosphereController = GameObject.FindObjectOfType <PhotosphereController>();

            if (photosphereController != null)
            {
                photosphereController.RemoveMissingPhotospheres();

                PhotosphereEditor photosphereEditor = (PhotosphereEditor)EditorWindow.GetWindow(typeof(PhotosphereEditor));
                photosphereEditor.CleanUpPhotospheres();
            }
            else
            {
                Debug.LogWarning("No Photosphere Controller found, please select 'Create New Photosphere' if you want to ");
            }
        }
    }
Example #8
0
    public void CreateNewPhotosphere(Transform parentTransform, int zOffset)
    {
        PhotosphereController photosphereController = FindPhotosphereController();

        var        prefab         = AssetDatabase.LoadAssetAtPath("Assets/Photosphere/Prefabs/Photosphere.prefab", typeof(UnityEngine.Object)) as GameObject;
        GameObject newPhotosphere = Instantiate(prefab);

        Photosphere photosphere = newPhotosphere.GetComponent <Photosphere>();

        photosphere.SetPhotosphereImage(photoTexture);
        photosphere.SetPhotosphereVideo(videoClip);

        // set parent
        if (parentTransform == null)
        {
            newPhotosphere.transform.parent = photosphereController.transform;
        }
        else
        {
            newPhotosphere.transform.parent = parentTransform;
        }

        // set position
        photosphere.transform.position = new Vector3(0, 0, zOffset);

        // set name
        if (videoClip == null)
        {
            newPhotosphere.name = GetPhotosphereName(photosphereController, false);
        }
        else
        {
            newPhotosphere.name = GetPhotosphereName(photosphereController, true);
        }

        // temp fix
        if (_autoConnectedPhotospheres != null)
        {
            _autoConnectedPhotospheres.Add(photosphere);
        }
    }
Example #9
0
    public void RecalcutePercentageExplored()
    {
        if (_photoSphereController == null)
        {
            _photoSphereController = GameObject.FindObjectOfType <PhotosphereController>();
        }

        photoSpheresExplored = 0f;

        for (int i = 0; i < _photoSphereController.photospheres.Count; i++)
        {
            if (_photoSphereController.photospheres[i].HasBeenVisited)
            {
                photoSpheresExplored++;
            }
        }

        percentageOfSceneExplored = 100f / _photoSphereController.photospheres.Count;
        percentageOfSceneExplored = percentageOfSceneExplored * photoSpheresExplored;
        percentageOfSceneExplored = (float)Math.Round(percentageOfSceneExplored);
    }
Example #10
0
    private string GetPhotosphereName(PhotosphereController photosphereController, bool isVideoSphere)
    {
        // set photosphere name, should be unique but check anyway
        string photosphereName;

        if (isVideoSphere)
        {
            photosphereName = "Photosphere " + videoClip.name + " Video";
        }
        else
        {
            photosphereName = "Photosphere " + photoTexture.name;
        }

        int duplicates = 0;

        for (int i = 0; i < photosphereController.photospheres.Count; i++)
        {
            if (photosphereController.photospheres[i].name == photosphereName)
            {
                duplicates++;

                if (isVideoSphere)
                {
                    photosphereName = "Photosphere " + videoClip.name + " Video" + " " + duplicates;
                }
                else
                {
                    photosphereName = "Photosphere " + photoTexture.name + " " + duplicates;
                }
            }
        }

        if (duplicates > 0)
        {
            Debug.LogWarning("Duplicate Photosphere detected");
        }

        return(photosphereName);
    }
Example #11
0
    private void Start()
    {
        if (photosphereController == null)
        {
            photosphereController = GameObject.FindObjectOfType <PhotosphereController>();
        }

        if (GameObject.FindObjectOfType <SceneData>() != null)
        {
            _sceneData = GameObject.FindObjectOfType <SceneData>();
        }

#if !UNITY_EDITOR
        emulatePlatform = false;
#endif

        if (!emulatePlatform)
        {
#if UNITY_STANDALONE || UNITY_WEBGL
            ConfigureDesktopControls();
            Debug.Log("Desktop Controls Loaded");
#elif UNITY_ANDROID || UNITY_IOS
            // check the current XR settings. Oculus and Google VR SDKs cannot be both active at the same time so will require 2 seperate APKs
            // find which one is active and set the controller to that.
            if (XRSettings.supportedDevices[0] == "cardboard" || XRSettings.supportedDevices[0] == "daydream")
            {
                ConfigureGoogleVRControls();
            }
            else if (XRSettings.supportedDevices[0] == "Oculus")
            {
                ConfigureOculusControls();
            }
            else
            {
                Debug.LogError("No suitable Android device found, check XR SDK settings or device name");
            }
#else
            Debug.Debug.LogError("No Controls Set Up For This Platform");
#endif
        }
        else
        {
            // if the desktop
            if (buildEmulation == BuildEmulation.Desktop)
            {
                ConfigureDesktopControls();
            }

            if (buildEmulation == BuildEmulation.Android)
            {
                ConfigureGoogleVRControls();
            }

            if (buildEmulation == BuildEmulation.Oculus)
            {
                ConfigureOculusControls();
            }
        }

        if (_sceneData != null)
        {
            activeDolly.allowSceneSelection = _sceneData.allowSceneSelection;
        }
    }
Example #12
0
 private void Start()
 {
     _sceneProgression      = GameObject.FindObjectOfType <SceneProgression>();
     _photoSphereController = GameObject.FindObjectOfType <PhotosphereController>();
 }