private void LoadFromJSON()
        {
            //Load and Parse JSON
            string json = File.ReadAllText(Application.persistentDataPath + "/hotspots2.json");

            print(json);
            HotspotScene hs = JsonUtility.FromJson <HotspotScene>(json);

            GameObject hotspotHolder = GameObject.Find("Hotspots");

            if (hotspotHolder == null)
            {
                hotspotHolder      = new GameObject();
                hotspotHolder.name = "Hotspots";
            }


            foreach (HotspotSaveable hotspot in hs.hotspots)
            {
                //Instantiate Hotspot
                var hotspotObject = Instantiate(hotspotPrefab);
                hotspotObject.transform.parent = hotspotHolder.transform;

                // Works out which camera is associated with the surface hotspot appears on.
                // Also provides the position of the hotspot on that surface in pixels.
                var(cam, pos) = immersiveCamera.FindCameraFromScreenPosition(hotspot.position);
                if (cam == null)
                {
                    return;
                }

                //Make hotspot face camera
                HotspotScript hotScript = hotspotObject.GetComponent <HotspotScript>();

                // Cast ray through screen point and place hotspot 2 units from the camera.
                Ray ray = cam.ScreenPointToRay(new Vector3(pos.x, pos.y));
                hotspotObject.transform.position = ray.GetPoint(2);
            }
        }
예제 #2
0
        //Find referenced objects
        private void OnEnable()
        {
            hotspot = (HotspotScript)target;
            if (hotspot.imagePopUpDataModel.popUpSetting.background.sprite != null)
            {
                _popUpImageResolution = hotspot.imagePopUpDataModel.popUpSetting.background.sprite.rect.size;
            }

            //currentPopUpSettingDictionary           = new Dictionary<string, SerializedProperty>();
            hotspotDataModelDictionary = new Dictionary <string, SerializedProperty>();

            textPopUpDataModelDictionary          = new Dictionary <string, SerializedProperty>();
            quizPopUpDataModelDictionary          = new Dictionary <string, SerializedProperty>();
            imagePopUpDataModelDictionary         = new Dictionary <string, SerializedProperty>();
            imageSequencePopUpDataModelDictionary = new Dictionary <string, SerializedProperty>();
            videoPopUpDataModelDictionary         = new Dictionary <string, SerializedProperty>();
            audioPopUpDataModelDictionary         = new Dictionary <string, SerializedProperty>();
            sceneLinkDataModelDictionary          = new Dictionary <string, SerializedProperty>();
            splitPopUpDataModelDictionary         = new Dictionary <string, SerializedProperty>();

            //HotspotSettings
            hotspotDataModel = serializedObject.FindProperty(nameof(hotspot.hotspotDataModel));
            GetChildren(hotspotDataModel, hotspotDataModelDictionary);

            //Image Settings
            imagePopUpDataModel = serializedObject.FindProperty(nameof(hotspot.imagePopUpDataModel));
            GetChildren(imagePopUpDataModel.FindPropertyRelative(nameof(hotspot.imagePopUpDataModel.popUpSetting)), imagePopUpDataModelDictionary);

            //Image Sequence Settings
            imageSequencePopUpDataModel = serializedObject.FindProperty(nameof(hotspot.imageSequencePopUpDataModel));
            GetChildren(imageSequencePopUpDataModel.FindPropertyRelative(nameof(hotspot.imageSequencePopUpDataModel.popUpSetting)), imageSequencePopUpDataModelDictionary);

            //Video Settings
            videoPopUpDataModel = serializedObject.FindProperty(nameof(hotspot.videoPopUpDataModel));
            GetChildren(videoPopUpDataModel.FindPropertyRelative(nameof(hotspot.videoPopUpDataModel.popUpSetting)), videoPopUpDataModelDictionary);

            //Text Settings
            textPopUpDataModel = serializedObject.FindProperty(nameof(hotspot.textPopUpDataModel));
            GetChildren(textPopUpDataModel.FindPropertyRelative(nameof(hotspot.textPopUpDataModel.popUpSetting)), textPopUpDataModelDictionary);

            //Q&A Settings
            quizPopUpDataModel = serializedObject.FindProperty(nameof(hotspot.quizPopUpDataModel));
            GetChildren(quizPopUpDataModel.FindPropertyRelative(nameof(hotspot.quizPopUpDataModel.popUpSetting)), quizPopUpDataModelDictionary);

            //SceneLink Settings
            sceneLinkDataModel = serializedObject.FindProperty(nameof(hotspot.sceneLinkDataModel));
            GetChildren(sceneLinkDataModel.FindPropertyRelative(nameof(hotspot.sceneLinkDataModel.popUpSetting)), sceneLinkDataModelDictionary);

            //Reveal or Hide Settings
            objectsToHide   = serializedObject.FindProperty("objectsToHide");
            objectsToReveal = serializedObject.FindProperty("objectsToReveal");

            //Audio popup Settings
            audioPopUpDataModel = serializedObject.FindProperty(nameof(hotspot.audioPopUpDataModel));
            GetChildren(audioPopUpDataModel.FindPropertyRelative(nameof(hotspot.audioPopUpDataModel.popUpSetting)), audioPopUpDataModelDictionary);

            //Split popup Settings
            splitDataModel = serializedObject.FindProperty(nameof(hotspot.splitPopupDataModel));
            GetChildren(splitDataModel.FindPropertyRelative(nameof(hotspot.splitPopupDataModel.popUpSetting)), splitPopUpDataModelDictionary);

            //PopUp Prefabs
            videoPopUpPrefab         = serializedObject.FindProperty(nameof(hotspot.videoPopUpPrefab));
            imagePopUpPrefab         = serializedObject.FindProperty(nameof(hotspot.imagePopUpPrefab));
            imageSequencePopUpPrefab = serializedObject.FindProperty(nameof(hotspot.imageSequencePopUpPrefab));
            textPopUpPrefab          = serializedObject.FindProperty(nameof(hotspot.textPopUpPrefab));
            qAndAPopUpPrefab         = serializedObject.FindProperty(nameof(hotspot.qAndAPopUpPrefab));
            audioPopUpPrefab         = serializedObject.FindProperty(nameof(hotspot.audioPopUpPrefab));
            splitPopupPrefab         = serializedObject.FindProperty(nameof(hotspot.splitPopupPrefab));
        }