コード例 #1
0
        //static SceneVersionCollection SceneVersionCollection;

        /// <summary>
        /// generate manifest from scene objects and upload to latest version of scene. should be done only after EditorCore.RefreshSceneVersion
        /// </summary>
        public static void UploadManifest(System.Action callback)
        {
            if (Manifest == null)
            {
                Manifest = new AggregationManifest();
            }
            //if (SceneVersionCollection == null) { Debug.LogError("SceneVersionCollection is null! Make sure RefreshSceneVersion was called before this"); return; }

            ObjectsInScene = null;

            AddOrReplaceDynamic(Manifest, GetDynamicObjectsInScene());

            if (Manifest.objects.Count == 0)
            {
                Debug.LogWarning("Aggregation Manifest has nothing in list!");
                return;
            }

            string json = "";

            if (ManifestToJson(out json))
            {
                var currentSettings = CognitiveVR_Preferences.FindCurrentScene();
                if (currentSettings != null && currentSettings.VersionNumber > 0)
                {
                    SendManifest(json, currentSettings.VersionNumber, callback);
                }
                else
                {
                    Util.logError("Could not find scene version for current scene");
                }
            }
        }
コード例 #2
0
        void Update()
        {
            if (!CognitiveVR_Preferences.Instance.SendDataOnHotkey)
            {
                return;
            }
            if (Input.GetKeyDown(CognitiveVR_Preferences.Instance.SendDataHotkey))
            {
                CognitiveVR_Preferences prefs = CognitiveVR_Preferences.Instance;

                if (prefs.HotkeyShift && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))
                {
                    return;
                }
                if (prefs.HotkeyAlt && !Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt))
                {
                    return;
                }
                if (prefs.HotkeyCtrl && !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl))
                {
                    return;
                }

                EndPlayerRecording();
            }
        }
コード例 #3
0
ファイル: EditorCore.cs プロジェクト: Jadewyh/cvr-sdk-unity
        private static void GetSceneVersionResponse(int responsecode, string error, string text)
        {
            if (responsecode != 200)
            {
                RefreshSceneVersionComplete = null;
                //internal server error
                Util.logDebug("GetSettingsResponse [ERROR] " + responsecode);
                return;
            }
            var settings = CognitiveVR_Preferences.FindCurrentScene();

            if (settings == null)
            {
                //this should be impossible, but might happen if changing scenes at exact time
                RefreshSceneVersionComplete = null;
                Debug.LogWarning("Scene version request returned 200, but current scene cannot be found");
                return;
            }

            var collection = JsonUtility.FromJson <SceneVersionCollection>(text);

            if (collection != null)
            {
                settings.VersionId     = collection.GetLatestVersion().id;
                settings.VersionNumber = collection.GetLatestVersion().versionNumber;
                EditorUtility.SetDirty(CognitiveVR_Preferences.Instance);
                AssetDatabase.SaveAssets();
            }

            if (RefreshSceneVersionComplete != null)
            {
                RefreshSceneVersionComplete.Invoke();
            }
        }
コード例 #4
0
        void UpdateSendHotkeyCheck()
        {
            CognitiveVR_Preferences prefs = CognitiveVR_Preferences.Instance;

            if (!prefs.SendDataOnHotkey)
            {
                return;
            }
            if (Input.GetKeyDown(prefs.SendDataHotkey))
            {
                if (prefs.HotkeyShift && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))
                {
                    return;
                }
                if (prefs.HotkeyAlt && !Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt))
                {
                    return;
                }
                if (prefs.HotkeyCtrl && !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl))
                {
                    return;
                }

                Core.SendDataEvent();
            }
        }
コード例 #5
0
        static void SendManifest(string json, int versionNumber, System.Action callback)
        {
            var settings = CognitiveVR_Preferences.FindCurrentScene();

            if (settings == null)
            {
                Debug.LogWarning("Send Manifest settings are null " + UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().path);
                string s = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
                if (string.IsNullOrEmpty(s))
                {
                    s = "Unknown Scene";
                }
                EditorUtility.DisplayDialog("Dynamic Object Manifest Upload Failed", "Could not find the Scene Settings for \"" + s + "\". Are you sure you've saved, exported and uploaded this scene to SceneExplorer?", "Ok");
                return;
            }

            string url = Constants.POSTDYNAMICMANIFEST(settings.SceneId, versionNumber);

            Util.logDebug("Send Manifest Contents: " + json);

            //upload manifest
            Dictionary <string, string> headers = new Dictionary <string, string>();

            if (EditorCore.IsDeveloperKeyValid)
            {
                headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
                headers.Add("Content-Type", "application/json");
            }
            PostManifestResponseAction = callback;
            EditorNetwork.Post(url, json, PostManifestResponse, headers, false);//AUTH
        }
コード例 #6
0
ファイル: EditorCore.cs プロジェクト: Jadewyh/cvr-sdk-unity
        //static System.Action RefreshSceneVersionComplete;
        /// <summary>
        /// get collection of versions of scene
        /// </summary>
        /// <param name="refreshSceneVersionComplete"></param>
        public static void RefreshMediaSources()
        {
            Debug.Log("refresh media sources");
            //gets the scene version from api and sets it to the current scene
            string currentSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
            var    currentSettings  = CognitiveVR_Preferences.FindScene(currentSceneName);

            if (currentSettings != null)
            {
                if (!IsDeveloperKeyValid)
                {
                    Debug.Log("Developer key invalid"); return;
                }

                if (currentSettings == null)
                {
                    Debug.Log("SendSceneVersionRequest no scene settings!");
                    return;
                }
                string url = CognitiveStatics.GETMEDIASOURCELIST();

                Dictionary <string, string> headers = new Dictionary <string, string>();
                if (EditorCore.IsDeveloperKeyValid)
                {
                    headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
                }

                EditorNetwork.Get(url, GetMediaSourcesResponse, headers, true, "Get Scene Version");//AUTH
            }
            else
            {
                Debug.Log("No scene versions for scene: " + currentSceneName);
            }
        }
コード例 #7
0
ファイル: EditorCore.cs プロジェクト: Jadewyh/cvr-sdk-unity
        /// <summary>
        /// Gets the cognitivevr_preferences or creates and returns new default preferences
        /// </summary>
        /// <returns>Preferences</returns>
        public static CognitiveVR_Preferences GetPreferences()
        {
            if (_prefs == null)
            {
                _prefs = Resources.Load <CognitiveVR_Preferences>("CognitiveVR_Preferences");
                if (_prefs == null)
                {
                    _prefs = ScriptableObject.CreateInstance <CognitiveVR_Preferences>();
                    string filepath = "";
                    if (!RecursiveDirectorySearch("", out filepath, "CognitiveVR" + System.IO.Path.DirectorySeparatorChar + "Resources"))
                    {
                        Debug.LogError("couldn't find CognitiveVR/Resources folder");
                    }

                    AssetDatabase.CreateAsset(_prefs, filepath + System.IO.Path.DirectorySeparatorChar + "CognitiveVR_Preferences.asset");

                    List <string> names = new List <string>();
                    List <string> paths = new List <string>();


                    GetAllScenes(names, paths);
                    for (int i = 0; i < names.Count; i++)
                    {
                        CognitiveVR_Preferences.AddSceneSettings(_prefs, names[i], paths[i]);
                    }
                    EditorUtility.SetDirty(EditorCore.GetPreferences());
                    AssetDatabase.SaveAssets();

                    AssetDatabase.Refresh();
                }
            }
            return(_prefs);
        }
コード例 #8
0
        private void SceneManager_SceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode)
        {
            var  loadingScene     = CognitiveVR_Preferences.FindScene(scene.name);
            bool replacingSceneId = false;

            if (CognitiveVR_Preferences.Instance.SendDataOnLevelLoad)
            {
                Core.SendDataEvent();
            }


            if (mode == UnityEngine.SceneManagement.LoadSceneMode.Additive)
            {
                //if scene loaded has new scene id
                if (loadingScene != null && !string.IsNullOrEmpty(loadingScene.SceneId))
                {
                    replacingSceneId = true;
                }
            }
            if (mode == UnityEngine.SceneManagement.LoadSceneMode.Single || replacingSceneId)
            {
                DynamicObject.ClearObjectIds();
                //CognitiveVR_Manager.TickEvent -= CognitiveVR_Manager_OnTick;
                Core.SetTrackingScene("");
                if (loadingScene != null)
                {
                    if (!string.IsNullOrEmpty(loadingScene.SceneId))
                    {
                        //CognitiveVR_Manager.TickEvent += CognitiveVR_Manager_OnTick;
                        Core.SetTrackingScene(scene.name);
                    }
                }
            }
            OnLevelLoaded();
        }
コード例 #9
0
        public static void ExportWholeSelectionToSingle(string fullName, bool includeTextures)
        {
            if (!CreateTargetFolder(fullName))
            {
                Debug.LogError("Scene Explorer Exporter failed to create target folder: " + fullName);
                return;
            }

            MeshFilter[] meshes = UnityEngine.Object.FindObjectsOfType <MeshFilter>();

            if (meshes.Length == 0)
            {
                EditorUtility.DisplayDialog("No meshes found!", "Please add a mesh filter to the scene", "");
                return;
            }

            int exportedObjects = 0;

            List <MeshFilter> mfList = new List <MeshFilter>();

            CognitiveVR_Preferences prefs = CognitiveVR_EditorPrefs.GetPreferences();
            bool  staticGeoOnly           = prefs.ExportStaticOnly;
            float minSize = prefs.MinExportGeoSize;

            for (int i = 0; i < meshes.Length; i++)
            {
                if (staticGeoOnly && !meshes[i].gameObject.isStatic)
                {
                    continue;
                }
                Renderer r = meshes[i].GetComponent <Renderer>();
                if (r == null || r.bounds.size.magnitude < minSize)
                {
                    continue;
                }

                exportedObjects++;
                mfList.Add(meshes[i]);
            }

            if (exportedObjects > 0)
            {
                MeshFilter[] mf = new MeshFilter[mfList.Count];

                for (int i = 0; i < mfList.Count; i++)
                {
                    mf[i] = mfList[i];
                }

                MeshesToFile(mf, "CognitiveVR_SceneExplorerExport/" + fullName, fullName, includeTextures);
            }
            else
            {
                EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
            }
        }
コード例 #10
0
        public static CognitiveVR_Preferences GetPreferences()
        {
            CognitiveVR_Preferences asset = AssetDatabase.LoadAssetAtPath <CognitiveVR_Preferences>("Assets/CognitiveVR/Resources/CognitiveVR_Preferences.asset");

            if (asset == null)
            {
                asset = ScriptableObject.CreateInstance <CognitiveVR_Preferences>();
                AssetDatabase.CreateAsset(asset, "Assets/CognitiveVR/Resources/CognitiveVR_Preferences.asset");
            }
            return(asset);
        }
コード例 #11
0
        void DrawFooter()
        {
            GUI.color = EditorCore.BlueishGrey;
            GUI.DrawTexture(new Rect(0, 500, 550, 50), EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            string tooltip = "";

            var currentScene = CognitiveVR_Preferences.FindCurrentScene();

            if (currentScene == null || string.IsNullOrEmpty(currentScene.SceneId))
            {
                tooltip = "Upload list of all Dynamic Object IDs. Scene settings not saved";
            }
            else
            {
                tooltip = "Upload list of all Dynamic Object IDs and Mesh Names to " + currentScene.SceneName + " version " + currentScene.VersionNumber;
            }

            bool enabled = !(currentScene == null || string.IsNullOrEmpty(currentScene.SceneId));

            //EditorGUI.BeginDisabledGroup(enabled);
            //EditorGUI.EndDisabledGroup();
            if (enabled)
            {
                if (GUI.Button(new Rect(80, 510, 350, 30), new GUIContent("Upload Ids to SceneExplorer for Aggregation", tooltip)))
                {
                    EditorCore.RefreshSceneVersion(delegate() { ManageDynamicObjects.UploadManifest(null); });
                }
            }
            else
            {
                var    scene        = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene();
                string errorMessage = "<color=#880000ff>This scene <color=red>" + scene.name.ToUpper() + "</color> does not have a valid SceneId.\n\nPlease upload this scene using the Scene Setup Window</color>";
                if (!EditorCore.IsDeveloperKeyValid)
                {
                    errorMessage = "Developer Key not set";
                }

                EditorGUI.BeginDisabledGroup(true);
                GUI.Button(new Rect(80, 510, 350, 30), new GUIContent("Upload Ids to SceneExplorer for Aggregation", tooltip));
                EditorGUI.EndDisabledGroup();

                GUI.color = new Color(1, 0.9f, 0.9f);
                GUI.DrawTexture(new Rect(0, 420, 550, 150), EditorGUIUtility.whiteTexture);
                GUI.color = Color.white;
                GUI.Label(new Rect(30, 430, 430, 30), errorMessage, "normallabel");

                if (GUI.Button(new Rect(380, 510, 80, 30), "Fix"))
                {
                    InitWizard.Init();
                }
            }
        }
コード例 #12
0
 public static CognitiveVR_Preferences GetPreferences()
 {
     if (instance == null)
     {
         instance = Resources.Load <CognitiveVR_Preferences>("CognitiveVR_Preferences");
         if (instance == null)
         {
             instance = new CognitiveVR_Preferences();
         }
     }
     return(instance);
 }
コード例 #13
0
ファイル: EditorCore.cs プロジェクト: Jadewyh/cvr-sdk-unity
        public static void UploadScreenshot()
        {
            //get scene id
            var currentScene = CognitiveVR_Preferences.FindCurrentScene();

            if (currentScene == null)
            {
                Debug.Log("Could not find current scene");
                return;
            }
            if (string.IsNullOrEmpty(currentScene.SceneId))
            {
                Debug.Log(currentScene.SceneName + " scene has not been uploaded!");
                return;
            }


            //file popup
            string path = EditorUtility.OpenFilePanel("Select Screenshot", "", "png");

            if (path.Length == 0)
            {
                return;
            }

            string filename = Path.GetFileName(path);

            if (EditorUtility.DisplayDialog("Upload Screenshot", "Upload " + filename + " to " + currentScene.SceneName + " version " + currentScene.VersionNumber + "?", "Upload", "Cancel"))
            {
                string url = CognitiveStatics.POSTSCREENSHOT(currentScene.SceneId, currentScene.VersionNumber);

                var bytes = File.ReadAllBytes(path);

                WWWForm form = new WWWForm();
                form.AddBinaryData("screenshot", bytes, "screenshot.png");

                var headers = new Dictionary <string, string>();

                foreach (var v in form.headers)
                {
                    headers[v.Key] = v.Value;
                }

                if (EditorCore.IsDeveloperKeyValid)
                {
                    headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
                }

                EditorNetwork.Post(url, form, UploadScreenhotResponse, headers, false);
            }
        }
コード例 #14
0
        void OnGUI()
        {
            CognitiveVR_Preferences prefs = CognitiveVR_EditorPrefs.GetPreferences();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Refresh Scenes"))
            {
                loadedScenes = false;
                //scenes = null;
            }

            if (GUILayout.Button("Save"))
            {
                EditorUtility.SetDirty(prefs);
                AssetDatabase.SaveAssets();
            }

            GUILayout.EndHorizontal();

            if (!loadedScenes)
            {
                ReadNames();
                loadedScenes = true;
            }


            GUILayout.BeginHorizontal();
            GUILayout.Label("Record", GUILayout.Width(toggleWidth));
            GUILayout.Label("Scene Name", GUILayout.Width(sceneWidth));
            GUILayout.Label("SceneID", GUILayout.Width(keyWidth));
            GUILayout.EndHorizontal();


            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            GUILayout.Space(10);

            canvasPos = GUILayout.BeginScrollView(canvasPos);

            foreach (var v in prefs.SceneKeySettings)
            {
                DisplaySceneKeySettings(v);
            }

            GUILayout.EndScrollView();
        }
コード例 #15
0
ファイル: EditorCore.cs プロジェクト: Jadewyh/cvr-sdk-unity
        /// <summary>
        /// get collection of versions of scene
        /// </summary>
        /// <param name="refreshSceneVersionComplete"></param>
        public static void RefreshSceneVersion(System.Action refreshSceneVersionComplete)
        {
            Debug.Log("refresh scene version");
            //gets the scene version from api and sets it to the current scene
            string currentSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
            var    currentSettings  = CognitiveVR_Preferences.FindScene(currentSceneName);

            if (currentSettings != null)
            {
                if (!IsDeveloperKeyValid)
                {
                    Debug.Log("Developer key invalid"); return;
                }

                if (currentSettings == null)
                {
                    Debug.Log("SendSceneVersionRequest no scene settings!");
                    return;
                }
                if (string.IsNullOrEmpty(currentSettings.SceneId))
                {
                    if (refreshSceneVersionComplete != null)
                    {
                        refreshSceneVersionComplete.Invoke();
                    }
                    return;
                }

                RefreshSceneVersionComplete = refreshSceneVersionComplete;
                string url = CognitiveStatics.GETSCENEVERSIONS(currentSettings.SceneId);

                Dictionary <string, string> headers = new Dictionary <string, string>();
                if (EditorCore.IsDeveloperKeyValid)
                {
                    headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
                }

                EditorNetwork.Get(url, GetSceneVersionResponse, headers, true, "Get Scene Version");//AUTH
            }
            else
            {
                Debug.Log("No scene versions for scene: " + currentSceneName);
            }
        }
コード例 #16
0
ファイル: InitWizard.cs プロジェクト: AndrewYY/cvr-sdk-unity
        void WelcomeUpdate()
        {
            GUI.Label(steptitlerect, "STEP 1 - WELCOME", "steptitle");

            var settings = CognitiveVR_Preferences.FindCurrentScene();

            if (settings != null && !string.IsNullOrEmpty(settings.SceneId))
            {
                //upload new version
                GUI.Label(boldlabelrect, "Welcome to the Cognitive3D SDK Scene Setup.", "boldlabel");
                GUI.Label(new Rect(30, 140, 440, 440), "This will guide you through the initial setup of your scene, and will have production ready analytics at the end of this setup.\n\n\n" +
                          "<color=#8A9EB7FF>This scene has already been uploaded to SceneExplorer!</color> Unless there are meaningful changes to the static scene geometry you probably don't need to upload this scene again.\n\n" +
                          "Use <color=#8A9EB7FF>Manage Dynamic Objects</color> if you want to upload new Dynamic Objects to your existing scene.", "normallabel");
            }
            else
            {
                GUI.Label(boldlabelrect, "Welcome to the Cognitive3D SDK Scene Setup.", "boldlabel");
                GUI.Label(new Rect(30, 200, 440, 440), "This will guide you through the initial setup of your scene, and will have production ready analytics at the end of this setup.", "normallabel");
            }
        }
コード例 #17
0
        private static void CustomPreferencesGUI()
        {
            if (!prefsLoaded)
            {
                CognitiveVR_Preferences prefs = GetPreferences();

                //teleport
                trackTeleportDistance = prefs.trackTeleportDistance;

                //gaze object
                objectSendInterval = prefs.objectSendInterval;

                prefsLoaded = true;
            }

            EditorGUILayout.LabelField("Version: " + Core.SDK_Version);

            GUI.color = Color.blue;
            if (GUILayout.Button("Documentation", EditorStyles.whiteLabel))
            {
                Application.OpenURL("https://github.com/CognitiveVR/cvr-sdk-unity/wiki");
            }
            GUI.color = Color.white;

            GUILayout.Space(20);

            trackTeleportDistance = EditorGUILayout.Toggle(new GUIContent("Track Teleport Distance", "Track the distance of a player's teleport. Requires the CognitiveVR_TeleportTracker"), trackTeleportDistance);
            objectSendInterval    = EditorGUILayout.FloatField(new GUIContent("Gaze Object Send Interval", "How many seconds of gaze data are batched together when reporting CognitiveVR_GazeObject look durations"), objectSendInterval);

            if (GUI.changed)
            {
                CognitiveVR_Preferences prefs = GetPreferences();

                //teleport
                prefs.trackTeleportDistance = trackTeleportDistance;

                //gaze object
                prefs.objectSendInterval = objectSendInterval;
                AssetDatabase.SaveAssets();
            }
        }
コード例 #18
0
ファイル: InitWizard.cs プロジェクト: AndrewYY/cvr-sdk-unity
        void DrawFooter()
        {
            GUI.color = EditorCore.BlueishGrey;
            GUI.DrawTexture(new Rect(0, 450, 500, 50), EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            DrawBackButton();

            if (pageids[currentPage] == "uploadscene")
            {
                Rect buttonrect = new Rect(350, 460, 140, 30);
                if (GUI.Button(buttonrect, "Export Scene"))
                {
                    if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name))
                    {
                        if (EditorUtility.DisplayDialog("Export Failed", "Cannot export scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel"))
                        {
                            if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes())
                            {
                            }
                            else
                            {
                                return;//cancel from save scene window
                            }
                        }
                        else
                        {
                            return;//cancel from 'do you want to save' popup
                        }
                    }
                    CognitiveVR_SceneExportWindow.ExportScene(true, selectedExportQuality.ExportStaticOnly, selectedExportQuality.MinExportGeoSize, selectedExportQuality.TextureQuality, "companyname", selectedExportQuality.DiffuseTextureName);
                    CognitiveVR_Preferences.AddSceneSettings(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
                    EditorUtility.SetDirty(EditorCore.GetPreferences());

                    UnityEditor.AssetDatabase.SaveAssets();
                    currentPage++;
                }
            }

            DrawNextButton();
        }
コード例 #19
0
ファイル: InitWizard.cs プロジェクト: AndrewYY/cvr-sdk-unity
        void UploadUpdate()
        {
            if (delayUnderstandButton)
            {
                delayUnderstandButton = false;
                understandRevealTime  = EditorApplication.timeSinceStartup + 3;
            }

            var settings = CognitiveVR_Preferences.FindCurrentScene();

            if (settings != null && !string.IsNullOrEmpty(settings.SceneId))
            {
                //upload new version
                GUI.Label(steptitlerect, "STEP 7 - UPLOAD", "steptitle");

                Color scene1color = Color.HSVToRGB(0.55f, 0.5f, 1);
                Color scene2color = Color.HSVToRGB(0.55f, 1f, 1);

                GUI.color = scene1color;
                GUI.Box(new Rect(100, 40, 125, 125), EditorCore.SceneBackground, "image_centered");
                GUI.color = Color.white;

                GUI.Box(new Rect(100, 40, 125, 125), EditorCore.ObjectsBackground, "image_centered");

                GUI.color = scene2color;
                GUI.Box(new Rect(250, 40, 125, 125), EditorCore.SceneBackground, "image_centered");
                GUI.color = Color.white;

                GUI.Label(new Rect(30, 180, 440, 440), "In the final step, we will upload version <color=#62B4F3FF>" + (settings.VersionNumber + 1) + " </color>of the scene to <color=#8A9EB7FF>SceneExplorer</color>.\n\n\n" +
                          "This will archive the previous version <color=#62B4F3FF>" + (settings.VersionNumber) + " </color> of this scene. You will be prompted to copy the Dynamic Objects to the new version.\n\n\n" +
                          "For <color=#8A9EB7FF>Dynamic Objects</color>, you will be able to continue editing those later in the <color=#8A9EB7FF>Manage Dynamic Objects</color> window.", "normallabel");
            }
            else
            {
                GUI.Label(steptitlerect, "STEP 7 - UPLOAD", "steptitle");
                GUI.Label(new Rect(30, 100, 440, 440), "In the final step, we will complete the upload process to our <color=#8A9EB7FF>SceneExplorer</color> servers.\n\n\n" +
                          "After your Scene is uploaded, if you make changes to your scene, you may want to open this window again and upload a new version of the scene.\n\n\n" +
                          "For <color=#8A9EB7FF>Dynamic Objects</color>, you will be able to continue editing those later in the <color=#8A9EB7FF>Manage Dynamic Objects</color> window.", "normallabel");
            }
        }
コード例 #20
0
        void DrawFooter()
        {
            GUI.color = EditorCore.BlueishGrey;
            GUI.DrawTexture(new Rect(0, 450, 500, 50), EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            string tooltip = "";

            var currentScene = CognitiveVR_Preferences.FindCurrentScene();

            if (currentScene == null || string.IsNullOrEmpty(currentScene.SceneId))
            {
                tooltip = "Upload list of all Dynamic Object IDs. Scene settings not saved";
            }
            else
            {
                tooltip = "Upload list of all Dynamic Object IDs and Mesh Names to " + currentScene.SceneName + " version " + currentScene.VersionNumber;
            }

            EditorGUI.BeginDisabledGroup(currentScene == null || string.IsNullOrEmpty(currentScene.SceneId));
            if (GUI.Button(new Rect(130, 450, 250, 50), new GUIContent("Save & Sync with Server", tooltip), "button_bluetext"))
            {
                EditorCore.RefreshSceneVersion(delegate() { ManageDynamicObjects.UploadManifest(null); });
            }
            EditorGUI.EndDisabledGroup();

            //if (GUI.Button(new Rect(0,450,100,50),"get"))
            //{
            //    EditorCore.RefreshSceneVersion(delegate () {
            //        Dictionary<string, string> headers = new Dictionary<string, string>();
            //        if (EditorCore.IsDeveloperKeyValid)
            //        {
            //            headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
            //        }
            //        EditorNetwork.Get(Constants.GETDYNAMICMANIFEST(currentScene.VersionId), GetManifestResponse, headers, false);
            //    });
            //}
        }
コード例 #21
0
        //only need id, mesh and name
        //static AggregationManifest Manifest;
        //static SceneVersionCollection SceneVersionCollection;

        /// <summary>
        /// generate manifest from scene objects and upload to latest version of scene. should be done only after EditorCore.RefreshSceneVersion
        /// </summary>
        public static void UploadManifest(AggregationManifest manifest, System.Action callback, System.Action nodynamicscallback = null)
        {
            //if (Manifest == null) { Manifest = new AggregationManifest(); }
            //if (SceneVersionCollection == null) { Debug.LogError("SceneVersionCollection is null! Make sure RefreshSceneVersion was called before this"); return; }

            if (manifest.objects.Count == 0)
            {
                Debug.LogWarning("Aggregation Manifest has nothing in list!");
                if (nodynamicscallback != null)
                {
                    nodynamicscallback.Invoke();
                }
                return;
            }

            string json = "";

            if (ManifestToJson(manifest, out json))
            {
                var currentSettings = CognitiveVR_Preferences.FindCurrentScene();
                if (currentSettings != null && currentSettings.VersionNumber > 0)
                {
                    SendManifest(json, currentSettings.VersionNumber, callback);
                }
                else
                {
                    Util.logError("Could not find scene version for current scene");
                }
            }
            else
            {
                Debug.LogWarning("Aggregation Manifest only contains dynamic objects with generated ids");
                if (nodynamicscallback != null)
                {
                    nodynamicscallback.Invoke();
                }
            }
        }
コード例 #22
0
        //get dynamic object aggregation manifest for the current scene
        void GetManifest()
        {
            var currentSceneSettings = CognitiveVR_Preferences.FindCurrentScene();

            if (currentSceneSettings == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(currentSceneSettings.SceneId))
            {
                Util.logWarning("Get Manifest current scene doesn't have an id!");
                return;
            }

            string url = Constants.GETDYNAMICMANIFEST(currentSceneSettings.VersionId);

            Dictionary <string, string> headers = new Dictionary <string, string>();

            if (EditorCore.IsDeveloperKeyValid)
            {
                headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
            }
            EditorNetwork.Get(url, GetManifestResponse, headers, false);//AUTH
        }
コード例 #23
0
        private void OnGUI()
        {
            GUI.skin = EditorCore.WizardGUISkin;

            GUI.DrawTexture(new Rect(0, 0, 500, 500), EditorGUIUtility.whiteTexture);

            var currentscene = CognitiveVR_Preferences.FindCurrentScene();

            if (string.IsNullOrEmpty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name))
            {
                GUI.Label(steptitlerect, "DYNAMIC OBJECTS   Scene Not Saved", "steptitle");
            }
            else if (currentscene == null || string.IsNullOrEmpty(currentscene.SceneId))
            {
                GUI.Label(steptitlerect, "DYNAMIC OBJECTS   Scene Not Uploaded", "steptitle");
            }
            else
            {
                GUI.Label(steptitlerect, "DYNAMIC OBJECTS   " + currentscene.SceneName + " Version: " + currentscene.VersionNumber, "steptitle");
            }

            GUI.Label(new Rect(30, 45, 440, 440), "These are the current <color=#8A9EB7FF>Dynamic Object</color> components in your scene:", "boldlabel");

            //headers
            Rect mesh = new Rect(30, 95, 120, 30);

            GUI.Label(mesh, "Dynamic Mesh Name", "dynamicheader");
            Rect gameobject = new Rect(190, 95, 120, 30);

            GUI.Label(gameobject, "GameObject", "dynamicheader");
            //Rect ids = new Rect(320, 95, 120, 30);
            //GUI.Label(ids, "Ids", "dynamicheader");
            Rect uploaded = new Rect(380, 95, 120, 30);

            GUI.Label(uploaded, "Uploaded", "dynamicheader");


            //content
            DynamicObject[] tempdynamics    = GetDynamicObjects;
            Rect            innerScrollSize = new Rect(30, 0, 420, tempdynamics.Length * 30);

            dynamicScrollPosition = GUI.BeginScrollView(new Rect(30, 120, 440, 270), dynamicScrollPosition, innerScrollSize, false, true);

            Rect dynamicrect;

            for (int i = 0; i < tempdynamics.Length; i++)
            {
                if (tempdynamics[i] == null)
                {
                    RefreshSceneDynamics(); GUI.EndScrollView(); return;
                }
                dynamicrect = new Rect(30, i * 30, 460, 30);
                DrawDynamicObject(tempdynamics[i], dynamicrect, i % 2 == 0);
            }
            GUI.EndScrollView();
            GUI.Box(new Rect(30, 120, 425, 270), "", "box_sharp_alpha");

            //buttons

            string scenename       = "Not Saved";
            int    versionnumber   = 0;
            string buttontextstyle = "button_bluetext";

            if (currentscene == null || string.IsNullOrEmpty(currentscene.SceneId))
            {
                buttontextstyle = "button_disabledtext";
            }
            else
            {
                scenename     = currentscene.SceneName;
                versionnumber = currentscene.VersionNumber;
            }

            //TODO display uploading label for 2 frames before actually starting to upload. see init wizard implementation

            EditorGUI.BeginDisabledGroup(currentscene == null || string.IsNullOrEmpty(currentscene.SceneId));
            if (GUI.Button(new Rect(60, 400, 150, 40), new GUIContent("Upload Selected", "Export and Upload to " + scenename + " version " + versionnumber), buttontextstyle))
            {
                //dowhattever thing get scene version
                EditorCore.RefreshSceneVersion(() =>
                {
                    if (CognitiveVR_SceneExportWindow.ExportSelectedObjectsPrefab())
                    {
                        EditorCore.RefreshSceneVersion(delegate() { ManageDynamicObjects.UploadManifest(() => CognitiveVR_SceneExportWindow.UploadSelectedDynamicObjects(true)); });
                    }
                });
            }

            if (GUI.Button(new Rect(320, 400, 100, 40), new GUIContent("Upload All", "Export and Upload to " + scenename + " version " + versionnumber), buttontextstyle))
            {
                EditorCore.RefreshSceneVersion(() =>
                {
                    if (CognitiveVR_SceneExportWindow.ExportAllDynamicsInScene())
                    {
                        EditorCore.RefreshSceneVersion(delegate() { ManageDynamicObjects.UploadManifest(() => CognitiveVR_SceneExportWindow.UploadAllDynamicObjects(true)); });
                    }
                });
            }
            EditorGUI.EndDisabledGroup();

            DrawFooter();
            Repaint(); //manually repaint gui each frame to make sure it's responsive
        }
コード例 #24
0
ファイル: Core.cs プロジェクト: alexhersh/cvr-sdk-unity
        public static void SetTrackingScene(string sceneName)
        {
            var scene = CognitiveVR_Preferences.FindScene(sceneName);

            SetTrackingScene(scene);
        }
コード例 #25
0
 public static void AddSceneSettings(CognitiveVR_Preferences newInstance, string name, string path)
 {
     //skip. this should onyl be called automatically at the construction of preferences
     newInstance.sceneSettings.Add(new SceneSettings(name, path));
 }
コード例 #26
0
        public static void CustomPreferencesGUI()
        {
            prefs = GetPreferences();
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Version: " + Core.SDK_Version);

            GUI.color = Color.blue;
            if (GUILayout.Button("Documentation", EditorStyles.whiteLabel))
            {
                Application.OpenURL("https://github.com/CognitiveVR/cvr-sdk-unity/wiki");
            }
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(new GUIContent("Customer ID", "The identifier for your company and product on the CognitiveVR Dashboard"));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            prefs.CustomerID = EditorGUILayout.TextField(prefs.CustomerID);

            GUILayout.Space(10);


            if (GUILayout.Button("Save"))
            {
                EditorUtility.SetDirty(prefs);
                AssetDatabase.SaveAssets();
            }

            if (GUILayout.Button("Open Component Setup"))
            {
                CognitiveVR_ComponentSetup.Init();
            }

            canvasPos = GUILayout.BeginScrollView(canvasPos, false, false);

            GUILayout.Space(10);

            prefs.SnapshotInterval       = EditorGUILayout.FloatField(new GUIContent("Interval for Player Snapshots", "Delay interval for:\nHMD Height\nHMD Collsion\nArm Length\nController Collision"), prefs.SnapshotInterval);
            prefs.SnapshotInterval       = Mathf.Max(prefs.SnapshotInterval, 0.1f);
            prefs.LowFramerateThreshold  = EditorGUILayout.IntField(new GUIContent("Low Framerate Threshold", "Falling below and rising above this threshold will send events"), prefs.LowFramerateThreshold);
            prefs.LowFramerateThreshold  = Mathf.Max(prefs.LowFramerateThreshold, 1);
            prefs.CollisionLayerMask     = LayerMaskField(new GUIContent("Collision Layer", "LayerMask for HMD and Controller Collision events"), prefs.CollisionLayerMask);
            prefs.GazeObjectSendInterval = EditorGUILayout.FloatField(new GUIContent("Gaze Object Send Interval", "How many seconds of gaze data are batched together when reporting CognitiveVR_GazeObject look durations"), prefs.GazeObjectSendInterval);
            prefs.GazeObjectSendInterval = Mathf.Max(prefs.GazeObjectSendInterval, 1);

            prefs.TrackArmLengthSamples = EditorGUILayout.IntField(new GUIContent("Arm Length Samples", "Number of samples taken. The max is assumed to be maximum arm length"), prefs.TrackArmLengthSamples);
            prefs.TrackHMDHeightSamples = EditorGUILayout.IntField(new GUIContent("HMD Height Samples", "Number of samples taken. The average is assumed to be the player's eye height"), prefs.TrackHMDHeightSamples);
            prefs.TrackArmLengthSamples = Mathf.Clamp(prefs.TrackArmLengthSamples, 1, 100);
            prefs.TrackHMDHeightSamples = Mathf.Clamp(prefs.TrackHMDHeightSamples, 1, 100);



            GUILayout.Space(10);
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(new GUIContent("Player Recorder Options", "Settings for how the Player Recorder collects and sends data to SceneExplorer.com"));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            //radio buttons

            GUIStyle selectedRadio = new GUIStyle(GUI.skin.label);

            selectedRadio.normal.textColor = new Color(0, 0.0f, 0, 1.0f);
            selectedRadio.fontStyle        = FontStyle.Bold;

            //3D content
            GUILayout.BeginHorizontal();
            if (prefs.PlayerDataType == 0)
            {
                GUILayout.Label("3D Content (default)", selectedRadio, GUILayout.Width(195));
            }
            else
            {
                GUILayout.Label("3D Content (default)", GUILayout.Width(195));
            }
            bool o = prefs.PlayerDataType == 0;
            bool b = GUILayout.Toggle(prefs.PlayerDataType == 0, "", EditorStyles.radioButton);

            if (b != o)
            {
                prefs.PlayerDataType = 0;
            }
            GUILayout.EndHorizontal();

            //360 video content
            GUILayout.BeginHorizontal();
            if (prefs.PlayerDataType == 1)
            {
                GUILayout.Label(new GUIContent("360 Video Content", "Video content displayed in a sphere"), selectedRadio, GUILayout.Width(195));
            }
            else
            {
                GUILayout.Label(new GUIContent("360 Video Content", "Video content displayed in a sphere"), GUILayout.Width(195));
            }

            bool o2 = prefs.PlayerDataType == 1;
            bool b2 = GUILayout.Toggle(prefs.PlayerDataType == 1, "", EditorStyles.radioButton);

            if (b2 != o2)
            {
                prefs.PlayerDataType = 1;
            }
            GUILayout.EndHorizontal();

            if (GUI.changed)
            {
                if (prefs.PlayerDataType == 0) //3d content
                {
                    prefs.TrackPosition          = true;
                    prefs.TrackGazePoint         = true;
                    prefs.TrackGazeDirection     = false;
                    prefs.GazePointFromDirection = false;
                }
                else //video content
                {
                    prefs.TrackPosition          = true;
                    prefs.TrackGazePoint         = false;
                    prefs.TrackGazeDirection     = false;
                    prefs.GazePointFromDirection = true;
                }
            }

            EditorGUI.BeginDisabledGroup(prefs.PlayerDataType != 1);
            prefs.GazeDirectionMultiplier = EditorGUILayout.FloatField(new GUIContent("Video Sphere Radius", "Multiplies the normalized GazeDirection"), prefs.GazeDirectionMultiplier);
            prefs.GazeDirectionMultiplier = Mathf.Max(0.1f, prefs.GazeDirectionMultiplier);
            EditorGUI.EndDisabledGroup();

            GUILayout.Space(10);

            prefs.SendDataOnLevelLoad = EditorGUILayout.Toggle(new GUIContent("Send Data on Level Load", "Send all snapshots on Level Loaded"), prefs.SendDataOnLevelLoad);
            prefs.SendDataOnQuit      = EditorGUILayout.Toggle(new GUIContent("Send Data on Quit", "Sends all snapshots on Application OnQuit\nNot reliable on Mobile"), prefs.SendDataOnQuit);
            prefs.DebugWriteToFile    = EditorGUILayout.Toggle(new GUIContent("DEBUG - Write snapshots to file", "Write snapshots to file instead of uploading to SceneExplorer"), prefs.DebugWriteToFile);
            prefs.SendDataOnHotkey    = EditorGUILayout.Toggle(new GUIContent("DEBUG - Send Data on Hotkey", "Press a hotkey to send data"), prefs.SendDataOnHotkey);
            //prefs.SendDataOnHMDRemove = EditorGUILayout.Toggle(new GUIContent("Send data on HMD remove", "Send all snapshots on HMD remove event"), prefs.SendDataOnHMDRemove);

            EditorGUI.BeginDisabledGroup(!prefs.SendDataOnHotkey);

            if (remapHotkey)
            {
                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.wordWrap         = true;
                style.normal.textColor = new Color(0.5f, 1.0f, 0.5f, 1.0f);

                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("Hotkey", "Shift, Ctrl and Alt modifier keys are not allowed"), GUILayout.Width(125));
                GUI.color = Color.green;
                GUILayout.Button("Any Key", GUILayout.Width(70));
                GUI.color = Color.white;

                string displayKey = (prefs.HotkeyCtrl ? "Ctrl + " : "") + (prefs.HotkeyShift ? "Shift + " : "") + (prefs.HotkeyAlt ? "Alt + " : "") + prefs.SendDataHotkey.ToString();
                GUILayout.Label(displayKey);
                GUILayout.EndHorizontal();
                Event e = Event.current;

                //shift, ctrl, alt
                if (e.type == EventType.keyDown && e.keyCode != KeyCode.None && e.keyCode != KeyCode.LeftShift && e.keyCode != KeyCode.RightShift && e.keyCode != KeyCode.LeftControl && e.keyCode != KeyCode.RightControl && e.keyCode != KeyCode.LeftAlt && e.keyCode != KeyCode.RightAlt)
                {
                    prefs.HotkeyAlt      = e.alt;
                    prefs.HotkeyShift    = e.shift;
                    prefs.HotkeyCtrl     = e.control;
                    prefs.SendDataHotkey = e.keyCode;
                    remapHotkey          = false;
                    //this is kind of a hack, but it works
                    GetWindow <CognitiveVR_EditorPrefs>().Repaint();
                    GetWindow <CognitiveVR_EditorPrefs>().Close();
                }
            }
            else
            {
                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.wordWrap         = true;
                style.normal.textColor = new Color(0.5f, 0.5f, 0.5f, 0.75f);
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("Hotkey", "Shift, Ctrl and Alt modifier keys are not allowed"), GUILayout.Width(125));
                if (GUILayout.Button("Remap", GUILayout.Width(70)))
                {
                    remapHotkey = true;
                }
                string displayKey = (prefs.HotkeyCtrl ? "Ctrl + " : "") + (prefs.HotkeyShift ? "Shift + " : "") + (prefs.HotkeyAlt ? "Alt + " : "") + prefs.SendDataHotkey.ToString();
                GUILayout.Label(displayKey);
                GUILayout.EndHorizontal();
            }

            EditorGUI.EndDisabledGroup();

            GUILayout.Space(10);
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Scene Explorer Export Options");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();


#if UNITY_EDITOR_OSX
            EditorGUILayout.HelpBox("Exporting scenes is not available on Mac at this time", MessageType.Warning);
            EditorGUI.BeginDisabledGroup(true);
#endif

            prefs.ExportStaticOnly         = EditorGUILayout.Toggle(new GUIContent("Export Static Geo Only", "Only export meshes marked as static. Dynamic objects (such as vehicles, doors, etc) will not be exported"), prefs.ExportStaticOnly);
            prefs.MinExportGeoSize         = EditorGUILayout.FloatField(new GUIContent("Minimum export size", "Ignore exporting meshes that are below this size(pebbles, grass,etc)"), prefs.MinExportGeoSize);
            appendName                     = EditorGUILayout.TextField(new GUIContent("Append to File Name", "This could be a level's number and version"), appendName);
            prefs.ExplorerMinimumFaceCount = EditorGUILayout.IntField(new GUIContent("Minimum Face Count", "Ignore decimating objects with fewer faces than this value"), prefs.ExplorerMinimumFaceCount);
            prefs.ExplorerMaximumFaceCount = EditorGUILayout.IntField(new GUIContent("Maximum Face Count", "Objects with this many faces will be decimated to 10% of their original face count"), prefs.ExplorerMaximumFaceCount);

            if (prefs.ExplorerMinimumFaceCount < 0)
            {
                prefs.ExplorerMinimumFaceCount = 0;
            }
            if (prefs.ExplorerMaximumFaceCount < 1)
            {
                prefs.ExplorerMaximumFaceCount = 1;
            }
            if (prefs.ExplorerMinimumFaceCount > prefs.ExplorerMaximumFaceCount)
            {
                prefs.ExplorerMinimumFaceCount = prefs.ExplorerMaximumFaceCount;
            }

            if (string.IsNullOrEmpty(prefs.SavedBlenderPath))
            {
                FindBlender();
            }

            EditorGUILayout.LabelField("Path To Blender", prefs.SavedBlenderPath);
            if (GUILayout.Button("Select Blender.exe"))
            {
                prefs.SavedBlenderPath = EditorUtility.OpenFilePanel("Select Blender.exe", string.IsNullOrEmpty(prefs.SavedBlenderPath) ? "c:\\" : prefs.SavedBlenderPath, "");

                if (!string.IsNullOrEmpty(prefs.SavedBlenderPath))
                {
                    //prefs.SavedBlenderPath = prefs.SavedBlenderPath.Substring(0, prefs.SavedBlenderPath.Length - "blender.exe".Length) + "";
                }
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Export Scene", "Exports the scene to Blender and reduces polygons. This also exports required textures at a low resolution")))
            {
                ExportScene(true);
            }

            if (GUILayout.Button(new GUIContent("Export Scene SKIP TEXTURES", "Exports only the scene geometry to Blender and reduces polygons")))
            {
                ExportScene(false);
            }
            GUILayout.EndHorizontal();

#if UNITY_EDITOR_OSX
            EditorGUI.EndDisabledGroup();
#endif

            if (GUILayout.Button(new GUIContent("Manage Scene IDs", "Open window to set which tracked player data is uploaded to your scenes")))
            {
                CognitiveVR_SceneKeyConfigurationWindow.Init();
            }

            GUILayout.EndScrollView();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(prefs);
            }
        }
コード例 #27
0
        static void Refresh()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
            CognitiveVR_Preferences   p  = CognitiveVR_Preferences.Instance;

            sb.AppendLine("*****************************");
            sb.AppendLine("***********SYSTEM************");
            sb.AppendLine("*****************************");
            sb.AppendLine("Unity Version:" + Application.unityVersion);
            sb.AppendLine("OS:" + SystemInfo.operatingSystem);
            sb.AppendLine("System Time: " + System.DateTime.Now.ToString());

            #region Project Settings
            sb.AppendLine();
            sb.AppendLine("*****************************");
            sb.AppendLine("***********PROJECT***********");
            sb.AppendLine("*****************************");
            string s = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
            sb.AppendLine("SDK Type: " + s);
            sb.AppendLine("SDK Version: " + Core.SDK_VERSION);
            try
            {
                sb.AppendLine("Api Key: ****" + p.ApplicationKey.Substring(p.ApplicationKey.Length - 4));
            }
            catch
            {
                sb.AppendLine("Api Key: INVALID");
            }
            try
            {
                sb.AppendLine("Developer Key: ****" + EditorCore.DeveloperKey.Substring(EditorCore.DeveloperKey.Length - 4));
            }
            catch
            {
                sb.AppendLine("Developer Key: INVALID");
            }
            sb.AppendLine("Enable Logging: " + p.EnableLogging);
            sb.AppendLine("Enable Development Logging: " + p.EnableDevLogging);
            sb.AppendLine("Gaze Type: " + p.GazeType.ToString());
            sb.AppendLine("Snapshot Interval: " + p.SnapshotInterval);
            sb.AppendLine("Dynamic Object Search in Parent: " + p.DynamicObjectSearchInParent);
            sb.AppendLine("Dynamic Object Layer Mask: " + p.DynamicLayerMask);
            sb.AppendLine("Track GPS Location: " + p.TrackGPSLocation);
            sb.AppendLine("GPS Sync with Player Update: " + p.SyncGPSWithGaze);
            sb.AppendLine("GPS Update Interval: " + p.GPSInterval);
            sb.AppendLine("GPS Accuracy: " + p.GPSAccuracy);
            sb.AppendLine("Record Floor Position: " + p.RecordFloorPosition);
            sb.AppendLine("Gaze Snapshot Batch Size: " + p.GazeSnapshotCount);
            sb.AppendLine("Event Snapshot Batch Size: " + p.TransactionSnapshotCount);
            sb.AppendLine("Event Extreme Batch Size: " + p.TransactionExtremeSnapshotCount);
            sb.AppendLine("Event Minimum Timer: " + p.TransactionSnapshotMinTimer);
            sb.AppendLine("Event Automatic Send Timer: " + p.TransactionSnapshotMaxTimer);

            sb.AppendLine("Dynamic Snapshot Batch Size: " + p.DynamicSnapshotCount);
            sb.AppendLine("Dynamic Extreme Batch Size: " + p.DynamicExtremeSnapshotCount);
            sb.AppendLine("Dynamic Minimum Timer: " + p.DynamicSnapshotMinTimer);
            sb.AppendLine("Dynamic Automatic Send Timer: " + p.DynamicSnapshotMaxTimer);

            sb.AppendLine("Sensor Snapshot Batch Size: " + p.SensorSnapshotCount);
            sb.AppendLine("Sensor Extreme Batch Size: " + p.SensorExtremeSnapshotCount);
            sb.AppendLine("Sensor Minimum Timer: " + p.SensorSnapshotMinTimer);
            sb.AppendLine("Sensor Automatic Send Timer: " + p.SensorSnapshotMaxTimer);

            sb.AppendLine("Fixation Snapshot Batch Size: " + p.FixationSnapshotCount);
            sb.AppendLine("Fixation Extreme Batch Size: " + p.FixationExtremeSnapshotCount);
            sb.AppendLine("Fixation Minimum Timer: " + p.FixationSnapshotMinTimer);
            sb.AppendLine("Fixation Automatic Send Timer: " + p.FixationSnapshotMaxTimer);

            sb.AppendLine("Save Data to Local Cache if no internet connection: " + p.LocalStorage);
            sb.AppendLine("Cache Size (bytes): " + p.LocalDataCacheSize);
            sb.AppendLine("Cache Size (mb): " + EditorUtility.FormatBytes(p.LocalDataCacheSize));
            sb.AppendLine("Custom Protocol: " + p.Protocol);
            sb.AppendLine("Custom Gateway: " + p.Gateway);
            sb.AppendLine("Custom Viewer: " + p.Viewer);
            sb.AppendLine("Custom Dashboard: " + p.Dashboard);

            sb.AppendLine("Send Data on HMD Remove: " + p.SendDataOnHMDRemove);
            sb.AppendLine("Send Data on Level Load: " + p.SendDataOnLevelLoad);
            sb.AppendLine("Send Data on Quit: " + p.SendDataOnQuit);
            sb.AppendLine("Send Data on Hotkey: " + p.SendDataOnHotkey);
            sb.AppendLine("Send Data Primary Hotkey: " + p.SendDataHotkey);
            sb.AppendLine("Send Data Hotkey Modifiers: " + p.HotkeyShift + " " + p.HotkeyCtrl + " " + p.HotkeyAlt);

            sb.AppendLine("Texture Export Quality: " + p.TextureResize);
            sb.AppendLine("Export Lowest LOD from LODGroup Components: " + p.ExportSceneLODLowest);
            sb.AppendLine("Export AO Maps: " + p.ExportAOMaps);

            sb.AppendLine("Scene Settings:");

            for (int i = 0; i < p.sceneSettings.Count; i++)
            {
                var scene = p.sceneSettings[i];
                if (i != p.sceneSettings.Count - 1)
                {
                    sb.AppendLine("  ├─" + scene.SceneName);
                    sb.AppendLine("  │  ├─Scene Id: " + scene.SceneId);
                    sb.AppendLine("  │  ├─Scene Path: " + scene.ScenePath);
                    sb.AppendLine("  │  ├─Last Revision: " + scene.LastRevision);
                    sb.AppendLine("  │  ├─Version Number: " + scene.VersionNumber);
                    sb.AppendLine("  │  └─Version Id: " + scene.VersionId);
                }
                else
                {
                    sb.AppendLine("  └─" + scene.SceneName);
                    sb.AppendLine("     ├─Scene Id: " + scene.SceneId);
                    sb.AppendLine("     ├─Scene Path: " + scene.ScenePath);
                    sb.AppendLine("     ├─Last Revision: " + scene.LastRevision);
                    sb.AppendLine("     ├─Version Number: " + scene.VersionNumber);
                    sb.AppendLine("     └─Version Id: " + scene.VersionId);
                }
            }
            #endregion

            #region Current Scene
            sb.AppendLine();
            sb.AppendLine("*****************************");
            sb.AppendLine("********CURRENT SCENE********");
            sb.AppendLine("*****************************");

            var currentScene = CognitiveVR_Preferences.FindSceneByPath(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().path);
            if (currentScene != null)
            {
                sb.AppendLine("Scene Name: " + currentScene.SceneName);
                sb.AppendLine("Scene Id: " + currentScene.SceneId);
                sb.AppendLine("Scene Path: " + currentScene.ScenePath);
                sb.AppendLine("Last Revision: " + currentScene.LastRevision);
                sb.AppendLine("Version Number: " + currentScene.VersionNumber);
                sb.AppendLine("Version Id: " + currentScene.VersionId);

                string fullName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
                string objPath  = EditorCore.GetSubDirectoryPath(fullName);

                if (System.IO.Directory.Exists(objPath))
                {
                    var size = GetDirectorySize(objPath);
                    sb.AppendLine("Scene Size (mb): " + string.Format("{0:0.00}", (size / 1048576f)));
                }
                else
                {
                    sb.AppendLine("Scene Not Exported " + objPath);
                }
            }
            else
            {
                var currentEditorScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene();
                sb.AppendLine("Scene Name: " + currentEditorScene.name);
                sb.AppendLine("Scene Settings not included in Preferences");
            }

            var mainCamera = Camera.main;
            if (mainCamera != null)
            {
                sb.AppendLine("Main Camera GameObject: " + mainCamera.gameObject.name);
            }
            else
            {
                sb.AppendLine("No Main Camera in scene");
            }

            var manager = FindObjectOfType <CognitiveVR_Manager>();
            if (manager != null)
            {
                sb.AppendLine("Manager Initialize On Start: " + manager.InitializeOnStart);
                sb.AppendLine("Manager Startup Delay Time (s): " + manager.StartupDelayTime);
            }
            else
            {
                sb.AppendLine("No Manager in scene");
            }
            #endregion

            #region Scene Dynamics
            sb.AppendLine();
            sb.AppendLine("*****************************");
            sb.AppendLine("****CURRENT SCENE OBJECTS****");
            sb.AppendLine("*****************************");

            var sceneDynamics = FindObjectsOfType <DynamicObject>();
            sb.AppendLine("Dynamic Object Count: " + sceneDynamics.Length);

            for (int i = 0; i < sceneDynamics.Length; i++)
            {
                var dynamic = sceneDynamics[i];

                bool   last        = i == sceneDynamics.Length - 1;
                string headerLine  = "  ├─";
                string preLineMid  = "  │  ├─";
                string preLineLast = "  │  └─";
                if (last)
                {
                    headerLine  = "  └─";
                    preLineMid  = "     ├─";
                    preLineLast = "     └─";
                }

                sb.AppendLine(headerLine + dynamic.gameObject.name);
                sb.AppendLine(preLineMid + "Mesh Name: " + dynamic.MeshName);
                var mainCollider = dynamic.GetComponent <Collider>();
                if (mainCollider != null)
                {
                    sb.AppendLine(preLineMid + "Has Collider: true");
                    sb.AppendLine(preLineMid + "Collider Type: " + mainCollider.GetType().ToString());
                }
                else
                {
                    sb.AppendLine(preLineMid + "Has Collider: false");
                }

                if (dynamic.transform.childCount > 0)
                {
                    sb.AppendLine(preLineMid + "Has Children: true");
                    int expectedColliderCount = mainCollider != null ? 1 : 0;
                    if (dynamic.GetComponentsInChildren <Collider>().Length > expectedColliderCount)
                    {
                        sb.AppendLine(preLineLast + "Has Child Colliders: true");
                    }
                    else
                    {
                        sb.AppendLine(preLineLast + "Has Child Colliders: false");
                    }
                }
                else
                {
                    sb.AppendLine(preLineLast + "Has Children: false");
                }
            }
            #endregion
            sb.AppendLine();
            sb.AppendLine("*****************************");
            sb.AppendLine("********EXPORT FOLDER********");
            sb.AppendLine("*****************************");

            string baseDirectory = EditorCore.GetBaseDirectoryPath();
            if (System.IO.Directory.Exists(baseDirectory))
            {
                System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(baseDirectory);
                sb.AppendLine("/" + d.Name + " (" + string.Format("{0:0}", (GetDirectorySize(baseDirectory) / 1048576f)) + "mb)");
                AppendDirectory(sb, baseDirectory, 1);
            }

            DebugText = sb.ToString();
        }
コード例 #28
0
 public static void SetLobbyId(string lobbyId)
 {
     CognitiveVR_Preferences.SetLobbyId(lobbyId);
 }
コード例 #29
0
        public override void OnInspectorGUI()
        {
            if (!hasCheckedRenderType)
            {
                CheckGazeRenderType();
                hasCheckedRenderType = true;
            }

            var p = (CognitiveVR_Preferences)target;

            p.ApplicationKey   = EditorGUILayout.TextField("Application Key", p.ApplicationKey);
            p.EnableLogging    = EditorGUILayout.Toggle("Enable Logging", p.EnableLogging);
            p.EnableDevLogging = EditorGUILayout.Toggle("Enable Development Logging", p.EnableDevLogging);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("3D Player Tracking", EditorStyles.boldLabel);
            //TODO change tooltip based on selected gaze type
            p.GazeType = (GazeType)EditorGUILayout.EnumPopup("Gaze Type", p.GazeType);
            if (GUI.changed)
            {
                CheckGazeRenderType();
            }
            p.SnapshotInterval            = EditorGUILayout.FloatField("Snapshot Interval", p.SnapshotInterval);
            p.DynamicObjectSearchInParent = EditorGUILayout.Toggle(new GUIContent("Dynamic Object Search in Parent", "When capturing gaze on a Dynamic Object, also search in the collider's parent for the dynamic object component"), p.DynamicObjectSearchInParent);

            bool eyetracking = false;

#if CVR_TOBIIVR || CVR_FOVE || CVR_NEURABLE || CVR_PUPIL || CVR_AH || CVR_SNAPDRAGON || CVR_VIVEPROEYE || CVR_VARJO
            eyetracking = true;
#endif

            if (p.GazeType == GazeType.Physics || eyetracking)
            {
                LayerMask gazeMask = new LayerMask();
                gazeMask.value  = p.GazeLayerMask;
                gazeMask        = EditorGUILayout.MaskField("Gaze Layer Mask", gazeMask, (UnityEditorInternal.InternalEditorUtility.layers));
                p.GazeLayerMask = gazeMask.value;
            }

            LayerMask dynamicMask = new LayerMask();
            dynamicMask.value  = p.DynamicLayerMask;
            dynamicMask        = EditorGUILayout.MaskField("Dynamic Object Layer Mask", dynamicMask, (UnityEditorInternal.InternalEditorUtility.layers));
            p.DynamicLayerMask = dynamicMask.value;

            p.TrackGPSLocation = EditorGUILayout.Toggle(new GUIContent("Track GPS Location", "Record GPS location and compass direction at the interval below"), p.TrackGPSLocation);

            EditorGUI.BeginDisabledGroup(!p.TrackGPSLocation);
            EditorGUI.indentLevel++;
            gpsFoldout = EditorGUILayout.Foldout(gpsFoldout, "GPS Options");
            if (gpsFoldout)
            {
                p.SyncGPSWithGaze = EditorGUILayout.Toggle(new GUIContent("Sync with Player Update", "Request new GPS location every time the player position and gaze is recorded"), p.SyncGPSWithGaze);
                EditorGUI.BeginDisabledGroup(p.SyncGPSWithGaze);
                p.GPSInterval = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("GPS Update Interval", "Interval in seconds to record new GPS location data"), p.GPSInterval), 0.1f, 60f);
                EditorGUI.EndDisabledGroup();
                p.GPSAccuracy = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("GPS Accuracy", "Desired accuracy in meters. Using higher values like 500 may not require GPS and may save battery power"), p.GPSAccuracy), 1f, 500f);
            }
            EditorGUI.indentLevel--;
            EditorGUI.EndDisabledGroup();

            p.RecordFloorPosition = EditorGUILayout.Toggle(new GUIContent("Record Floor Position", "Includes the floor position below the HMD in a VR experience"), p.RecordFloorPosition);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("360 Player Tracking", EditorStyles.boldLabel);
            p.SnapshotInterval = EditorGUILayout.FloatField("Snapshot Interval", p.SnapshotInterval);
            p.SnapshotInterval = Mathf.Clamp(p.SnapshotInterval, 0.1f, 10);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Sending Data Batches", EditorStyles.boldLabel);

            //gaze
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField("Gaze", EditorStyles.boldLabel);
            EditorGUI.indentLevel--;
            p.GazeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Gaze Snapshot Batch Size", "The number of Gaze datapoints to record before automatically sending a web request to the dashboard"), p.GazeSnapshotCount), 64, 1500);

            //transactions
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField("Events", EditorStyles.boldLabel);
            EditorGUI.indentLevel--;
            p.TransactionSnapshotCount        = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Event Snapshot Batch Size", "The number of Events to record before automatically sending a web request to the dashboard"), p.TransactionSnapshotCount), 1, 1000);
            p.TransactionExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Event Extreme Batch Size", "Threshold for ignoring the Event Minimum Timer. If this many Events have been recorded, immediately send"), p.TransactionExtremeSnapshotCount), p.TransactionSnapshotCount, 1000);
            p.TransactionSnapshotMinTimer     = EditorGUILayout.IntField(new GUIContent("Event Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Event data. Ignored if the batch size reaches Event Extreme Limit"), Mathf.Clamp(p.TransactionSnapshotMinTimer, 1, 10));
            p.TransactionSnapshotMaxTimer     = EditorGUILayout.IntField(new GUIContent("Event Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Event data"), Mathf.Clamp(p.TransactionSnapshotMaxTimer, p.TransactionSnapshotMinTimer, 60));

            //dynamics
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField("Dynamics", EditorStyles.boldLabel);
            EditorGUI.indentLevel--;
            p.DynamicSnapshotCount        = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Dynamic Snapshot Batch Size", "The number of Dynamic snapshots and manifest entries to record before automatically sending a web request to the dashboard"), p.DynamicSnapshotCount), 16, 1500);
            p.DynamicExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Dynamic Extreme Batch Size", "Threshold for ignoring the Dynamic Minimum Timer. If this many Dynamic snapshots have been recorded, immediately send"), p.DynamicExtremeSnapshotCount), p.DynamicSnapshotCount, 1500);
            //p.DynamicSnapshotMinTimer = EditorGUILayout.IntField(new GUIContent("Dynamic Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Dynamic data. Ignored if the batch size reaches Dynamic Extreme Limit"), Mathf.Clamp(p.DynamicSnapshotMinTimer, 1, 60));
            p.DynamicSnapshotMaxTimer = EditorGUILayout.IntField(new GUIContent("Dynamic Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Dynamic snapshots or Manifest entries"), Mathf.Clamp(p.DynamicSnapshotMaxTimer, 1, 600));

            //sensors
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField("Sensors", EditorStyles.boldLabel);
            EditorGUI.indentLevel--;
            p.SensorSnapshotCount        = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Sensor Snapshot Batch Size", "The number of Sensor datapoints to record before automatically sending a web request to the dashboard"), p.SensorSnapshotCount), 64, 1500);
            p.SensorExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Sensor Extreme Batch Size", "Threshold for ignoring the Sensor Minimum Timer. If this many Sensor datapoints have been recorded, immediately send"), p.SensorExtremeSnapshotCount), p.SensorSnapshotCount, 1500);
            p.SensorSnapshotMinTimer     = EditorGUILayout.IntField(new GUIContent("Sensor Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Sensor data. Ignored if the batch size reaches Sensor Extreme Limit"), Mathf.Clamp(p.SensorSnapshotMinTimer, 1, 60));
            p.SensorSnapshotMaxTimer     = EditorGUILayout.IntField(new GUIContent("Sensor Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Sensor data"), Mathf.Clamp(p.SensorSnapshotMaxTimer, p.SensorSnapshotMinTimer, 600));

            //fixations
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField("Fixations", EditorStyles.boldLabel);
            EditorGUI.indentLevel--;
            p.FixationSnapshotCount        = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Fixation Snapshot Batch Size", "The number of Fixations to record before automatically sending a web request to the dashboard"), p.FixationSnapshotCount), 1, 1000);
            p.FixationExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Fixation Extreme Batch Size", "Threshold for ignoring the Fixation Minimum Timer. If this many Fixations have been recorded, immediately send"), p.FixationExtremeSnapshotCount), p.FixationSnapshotCount, 1000);
            p.FixationSnapshotMinTimer     = EditorGUILayout.IntField(new GUIContent("Fixation Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Fixation data. Ignored if the batch size reaches Fixation Extreme Limit"), Mathf.Clamp(p.FixationSnapshotMinTimer, 1, 10));
            p.FixationSnapshotMaxTimer     = EditorGUILayout.IntField(new GUIContent("Fixation Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Fixation data"), Mathf.Clamp(p.FixationSnapshotMaxTimer, p.FixationSnapshotMinTimer, 60));

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Local Data Cache", EditorStyles.boldLabel);
            //local storage
            p.LocalStorage = EditorGUILayout.Toggle("Save data to Local Cache if no internet connection", p.LocalStorage);
            EditorGUI.BeginDisabledGroup(!p.LocalStorage);
            GUILayout.BeginHorizontal();
            p.LocalDataCacheSize = EditorGUILayout.LongField("Cache Size", p.LocalDataCacheSize);
            if (p.LocalDataCacheSize < 1048576)
            {
                p.LocalDataCacheSize = 1048576;
            }                                                                       //at least 1mb of storage (1048576 bytes)
            EditorGUILayout.LabelField(EditorUtility.FormatBytes(p.LocalDataCacheSize), GUILayout.Width(100));
            GUILayout.EndHorizontal();
            p.ReadLocalCacheCount = EditorGUILayout.IntField(new GUIContent("Upload Local Cache Rate", "For each successful network response, read this number of cached requests from the local data cache"), p.ReadLocalCacheCount);
            p.ReadLocalCacheCount = Mathf.Max(p.ReadLocalCacheCount, 0);
            if (p.ReadLocalCacheCount == 0 && p.LocalStorage)
            {
                EditorGUILayout.HelpBox("Saved data will only be uploaded if manually called! See Docs", MessageType.Warning);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Sending Data", EditorStyles.boldLabel);
            CognitiveVR_Preferences.Instance.Protocol  = EditorGUILayout.TextField(new GUIContent("Custom Protocol", "https"), CognitiveVR_Preferences.Instance.Protocol);
            CognitiveVR_Preferences.Instance.Gateway   = EditorGUILayout.TextField(new GUIContent("Custom Gateway", "data.cognitive3d.com"), CognitiveVR_Preferences.Instance.Gateway);
            CognitiveVR_Preferences.Instance.Viewer    = EditorGUILayout.TextField(new GUIContent("Custom Viewer", "sceneexplorer.com/scene/"), CognitiveVR_Preferences.Instance.Viewer);
            CognitiveVR_Preferences.Instance.Dashboard = EditorGUILayout.TextField(new GUIContent("Custom Dashboard", "app.cognitive3d.com"), CognitiveVR_Preferences.Instance.Dashboard);
            p.SendDataOnHMDRemove = EditorGUILayout.Toggle("Send Data on HMD Remove", p.SendDataOnHMDRemove);
            p.SendDataOnLevelLoad = EditorGUILayout.Toggle("Send Data on Level Load", p.SendDataOnLevelLoad);
            p.SendDataOnQuit      = EditorGUILayout.Toggle("Send Data on Quit", p.SendDataOnQuit);
            p.SendDataOnHotkey    = EditorGUILayout.Toggle("Send Data on Hotkey", p.SendDataOnHotkey);
            EditorGUI.indentLevel++;
            EditorGUI.BeginDisabledGroup(!p.SendDataOnHotkey);
            GUILayout.BeginHorizontal();

            p.SendDataHotkey = (KeyCode)EditorGUILayout.EnumPopup("Hotkey", p.SendDataHotkey);

            if (p.HotkeyShift)
            {
                GUI.color = Color.green;
            }
            if (GUILayout.Button("Shift", EditorStyles.miniButtonLeft))
            {
                p.HotkeyShift = !p.HotkeyShift;
            }
            GUI.color = Color.white;

            if (p.HotkeyCtrl)
            {
                GUI.color = Color.green;
            }
            if (GUILayout.Button("Ctrl", EditorStyles.miniButtonMid))
            {
                p.HotkeyCtrl = !p.HotkeyCtrl;
            }
            GUI.color = Color.white;

            if (p.HotkeyAlt)
            {
                GUI.color = Color.green;
            }
            if (GUILayout.Button("Alt", EditorStyles.miniButtonRight))
            {
                p.HotkeyAlt = !p.HotkeyAlt;
            }
            GUI.color = Color.white;

            /*if (remapHotkey)
             * {
             *  GUILayout.Button("Any Key", EditorStyles.miniButton, GUILayout.Width(100));
             *  Event e = Event.current;
             *
             *  if (e.type == EventType.keyDown && e.keyCode != KeyCode.None && e.keyCode != KeyCode.LeftShift && e.keyCode != KeyCode.RightShift && e.keyCode != KeyCode.LeftControl && e.keyCode != KeyCode.RightControl && e.keyCode != KeyCode.LeftAlt && e.keyCode != KeyCode.RightAlt)
             *  {
             *      p.HotkeyAlt = e.alt;
             *      p.HotkeyShift = e.shift;
             *      p.HotkeyCtrl = e.control;
             *      p.SendDataHotkey = e.keyCode;
             *      remapHotkey = false;
             *      Repaint();
             *  }
             * }
             * else
             * {
             *  if (GUILayout.Button("Remap", EditorStyles.miniButton,GUILayout.Width(100)))
             *  {
             *      remapHotkey = true;
             *  }
             * }*/

            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Scene Export", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;

            var v = CognitiveVR_Preferences.FindCurrentScene();
            if (v == null || string.IsNullOrEmpty(v.SceneId))
            {
                EditorGUILayout.LabelField("Current Scene: " + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + "     Version: not uploaded");
            }
            else
            {
                EditorGUILayout.LabelField("Current Scene: " + v.SceneName + "     Version: " + v.VersionNumber);
            }
            EditorGUILayout.Space();

            GUIContent[] textureQualityNames = new GUIContent[] { new GUIContent("Full"), new GUIContent("Half"), new GUIContent("Quarter"), new GUIContent("Eighth"), new GUIContent("Sixteenth"), new GUIContent("Thirty Second"), new GUIContent("Sixty Fourth") };
            int[]        textureQualities    = new int[] { 1, 2, 4, 8, 16, 32, 64 };
            p.TextureResize = EditorGUILayout.IntPopup(new GUIContent("Texture Export Quality", "Reduce textures when uploading to scene explorer"), p.TextureResize, textureQualityNames, textureQualities);
            //EditorCore.ExportSettings.TextureQuality = EditorGUILayout.IntPopup(new GUIContent("Texture Export Quality", "Reduce textures when uploading to scene explorer"), EditorCore.ExportSettings.TextureQuality, textureQualityNames, textureQualities);
            p.ExportSceneLODLowest = EditorGUILayout.Toggle("Export Lowest LOD from LODGroup components", p.ExportSceneLODLowest);
            p.ExportAOMaps         = EditorGUILayout.Toggle("Export AO Maps", p.ExportAOMaps);
            GUILayout.BeginHorizontal();
            //GUILayout.Space(15);

            //TODO texture export settings

            //the full process
            //refresh scene versions
            //save screenshot
            //export scene
            //decimate scene
            //confirm upload of scene. new scene? new version?
            //export dynamics
            //confirm uploading dynamics
            //confirm upload manifest

            if (GUILayout.Button("Export", "ButtonLeft"))
            {
                if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name))
                {
                    if (EditorUtility.DisplayDialog("Export Failed", "Cannot export scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel"))
                    {
                        if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes())
                        {
                        }
                        else
                        {
                            return;//cancel from save scene window
                        }
                    }
                    else
                    {
                        return;//cancel from 'do you want to save' popup
                    }
                }
                CognitiveVR_SceneExportWindow.ExportGLTFScene();

                string fullName             = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
                string objPath              = CognitiveVR_SceneExportWindow.GetDirectory(fullName);
                string jsonSettingsContents = "{ \"scale\":1,\"sceneName\":\"" + fullName + "\",\"sdkVersion\":\"" + Core.SDK_VERSION + "\"}";
                System.IO.File.WriteAllText(objPath + "settings.json", jsonSettingsContents);

                //CognitiveVR.CognitiveVR_SceneExportWindow.ExportScene(true, EditorCore.ExportSettings.ExportStaticOnly, EditorCore.ExportSettings.MinExportGeoSize, EditorCore.ExportSettings.TextureQuality, EditorCore.DeveloperKey, EditorCore.ExportSettings.DiffuseTextureName);
                CognitiveVR_Preferences.AddSceneSettings(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
                UnityEditor.AssetDatabase.SaveAssets();
            }

            bool hasUploadFiles = EditorCore.HasSceneExportFolder(CognitiveVR_Preferences.FindCurrentScene());

            EditorGUI.BeginDisabledGroup(!hasUploadFiles);
            if (GUILayout.Button("Upload", "ButtonRight"))
            {
                System.Action completedmanifestupload = delegate()
                {
                    CognitiveVR_SceneExportWindow.UploadAllDynamicObjects(true);
                };

                System.Action completedRefreshSceneVersion2 = delegate()
                {
                    ManageDynamicObjects.UploadManifest(completedmanifestupload);
                };

                //upload dynamics
                System.Action completeSceneUpload = delegate() {
                    EditorCore.RefreshSceneVersion(completedRefreshSceneVersion2); //likely completed in previous step, but just in case
                };

                //upload scene
                System.Action completedRefreshSceneVersion1 = delegate() {
                    CognitiveVR_Preferences.SceneSettings current = CognitiveVR_Preferences.FindCurrentScene();

                    if (current == null || string.IsNullOrEmpty(current.SceneId))
                    {
                        //new scene
                        if (EditorUtility.DisplayDialog("Upload New Scene", "Upload " + current.SceneName + " to SceneExplorer?", "Ok", "Cancel"))
                        {
                            CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload);
                        }
                    }
                    else
                    {
                        //new version
                        if (EditorUtility.DisplayDialog("Upload New Version", "Upload a new version of this existing scene? Will archive previous version", "Ok", "Cancel"))
                        {
                            CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload);
                        }
                    }
                };

                //get the latest verion of the scene
                if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name))
                {
                    if (EditorUtility.DisplayDialog("Upload Failed", "Cannot upload scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel"))
                    {
                        if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes())
                        {
                            EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1);
                        }
                        else
                        {
                            return;//cancel from save scene window
                        }
                    }
                    else
                    {
                        return;//cancel from 'do you want to save' popup
                    }
                }
                else
                {
                    EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1);
                }
            }

            GUIContent ButtonContent = new GUIContent("Upload Screenshot");
            if (v == null)
            {
                GUILayout.Button(ButtonContent);
            }
            else
            {
                if (GUILayout.Button(ButtonContent))
                {
                    EditorCore.UploadScreenshot();
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.EndDisabledGroup();
            EditorGUI.indentLevel--;
            GUILayout.EndHorizontal();

            if (GUILayout.Button(new GUIContent("Refresh Latest Scene Versions", "Get the latest versionnumber and versionid for this scene"))) //ask scene explorer for all the versions of this active scene. happens automatically post scene upload
            {
                EditorCore.RefreshSceneVersion(null);
            }

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("sceneSettings"), true);
            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(p);
            }
        }
コード例 #30
0
        private void OnGUI()
        {
            GUI.skin = EditorCore.WizardGUISkin;

            GUI.DrawTexture(new Rect(0, 0, 500, 550), EditorGUIUtility.whiteTexture);

            var currentscene = CognitiveVR_Preferences.FindCurrentScene();

            if (string.IsNullOrEmpty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name))
            {
                GUI.Label(steptitlerect, "DYNAMIC OBJECTS   Scene Not Saved", "steptitle");
            }
            else if (currentscene == null || string.IsNullOrEmpty(currentscene.SceneId))
            {
                GUI.Label(steptitlerect, "DYNAMIC OBJECTS   Scene Not Uploaded", "steptitle");
            }
            else
            {
                GUI.Label(steptitlerect, "DYNAMIC OBJECTS   " + currentscene.SceneName + " Version: " + currentscene.VersionNumber, "steptitle");
            }

            GUI.Label(new Rect(30, 45, 440, 440), "These are the active <color=#8A9EB7FF>Dynamic Object components</color> currently found in your scene.", "boldlabel");

            //headers
            Rect mesh = new Rect(30, 95, 120, 30);

            GUI.Label(mesh, "Dynamic Mesh Name", "dynamicheader");
            Rect gameobject = new Rect(190, 95, 120, 30);

            GUI.Label(gameobject, "GameObject", "dynamicheader");
            //Rect ids = new Rect(320, 95, 120, 30);
            //GUI.Label(ids, "Ids", "dynamicheader");
            Rect uploaded = new Rect(380, 95, 120, 30);

            GUI.Label(uploaded, "Uploaded", "dynamicheader");


            //content
            DynamicObject[] tempdynamics = GetDynamicObjects;

            if (tempdynamics.Length == 0)
            {
                GUI.Label(new Rect(30, 120, 420, 270), "No objects found.\n\nHave you attached any Dynamic Object components to objects?\n\nAre they active in your hierarchy?", "button_disabledtext");
            }

            Rect innerScrollSize = new Rect(30, 0, 420, tempdynamics.Length * 30);

            dynamicScrollPosition = GUI.BeginScrollView(new Rect(30, 120, 440, 285), dynamicScrollPosition, innerScrollSize, false, true);

            Rect dynamicrect;

            for (int i = 0; i < tempdynamics.Length; i++)
            {
                if (tempdynamics[i] == null)
                {
                    RefreshSceneDynamics(); GUI.EndScrollView(); return;
                }
                dynamicrect = new Rect(30, i * 30, 460, 30);
                DrawDynamicObject(tempdynamics[i], dynamicrect, i % 2 == 0);
            }
            GUI.EndScrollView();
            GUI.Box(new Rect(30, 120, 425, 285), "", "box_sharp_alpha");

            //buttons

            string scenename     = "Not Saved";
            int    versionnumber = 0;

            //string buttontextstyle = "button_bluetext";
            if (currentscene == null || string.IsNullOrEmpty(currentscene.SceneId))
            {
                //buttontextstyle = "button_disabledtext";
            }
            else
            {
                scenename     = currentscene.SceneName;
                versionnumber = currentscene.VersionNumber;
            }

            int selectionCount = 0;

            foreach (var v in Selection.gameObjects)
            {
                if (v.GetComponentInChildren <DynamicObject>())
                {
                    selectionCount++;
                }
            }



            //texture resolution

            if (CognitiveVR_Preferences.Instance.TextureResize > 4)
            {
                CognitiveVR_Preferences.Instance.TextureResize = 4;
            }

            //resolution settings here
            EditorGUI.BeginDisabledGroup(DisableButtons);
            if (GUI.Button(new Rect(30, 415, 140, 35), new GUIContent("1/4 Resolution", DisableButtons?"":"Quarter resolution of dynamic object textures"), CognitiveVR_Preferences.Instance.TextureResize == 4 ? "button_blueoutline" : "button_disabledtext"))
            {
                CognitiveVR_Preferences.Instance.TextureResize = 4;
            }
            if (CognitiveVR_Preferences.Instance.TextureResize != 4)
            {
                GUI.Box(new Rect(30, 415, 140, 35), "", "box_sharp_alpha");
            }

            if (GUI.Button(new Rect(180, 415, 140, 35), new GUIContent("1/2 Resolution", DisableButtons ? "" : "Half resolution of dynamic object textures"), CognitiveVR_Preferences.Instance.TextureResize == 2 ? "button_blueoutline" : "button_disabledtext"))
            {
                CognitiveVR_Preferences.Instance.TextureResize = 2;
                //selectedExportQuality = ExportSettings.DefaultSettings;
            }
            if (CognitiveVR_Preferences.Instance.TextureResize != 2)
            {
                GUI.Box(new Rect(180, 415, 140, 35), "", "box_sharp_alpha");
            }

            if (GUI.Button(new Rect(330, 415, 140, 35), new GUIContent("1/1 Resolution", DisableButtons ? "" : "Full resolution of dynamic object textures"), CognitiveVR_Preferences.Instance.TextureResize == 1 ? "button_blueoutline" : "button_disabledtext"))
            {
                CognitiveVR_Preferences.Instance.TextureResize = 1;
                //selectedExportQuality = ExportSettings.HighSettings;
            }
            if (CognitiveVR_Preferences.Instance.TextureResize != 1)
            {
                GUI.Box(new Rect(330, 415, 140, 35), "", "box_sharp_alpha");
            }
            EditorGUI.EndDisabledGroup();


            EditorGUI.BeginDisabledGroup(currentscene == null || string.IsNullOrEmpty(currentscene.SceneId));
            if (GUI.Button(new Rect(30, 460, 200, 30), new GUIContent("Upload " + selectionCount + " Selected Meshes", DisableButtons ? "" : "Export and Upload to " + scenename + " version " + versionnumber)))
            {
                //dowhattever thing get scene version
                EditorCore.RefreshSceneVersion(() =>
                {
                    if (CognitiveVR_SceneExportWindow.ExportSelectedObjectsPrefab())
                    //GLTFExportMenu.ExportSelected();
                    {
                        EditorCore.RefreshSceneVersion(delegate() { ManageDynamicObjects.UploadManifest(() => CognitiveVR_SceneExportWindow.UploadSelectedDynamicObjects(true)); });
                    }
                    //if (CognitiveVR_SceneExportWindow.ExportSelectedObjectsPrefab())
                    //{
                    //    EditorCore.RefreshSceneVersion(delegate () { ManageDynamicObjects.UploadManifest(() => CognitiveVR_SceneExportWindow.UploadSelectedDynamicObjects(true)); });
                    //}
                });
            }

            if (GUI.Button(new Rect(270, 460, 200, 30), new GUIContent("Upload All Meshes", DisableButtons ? "" : "Export and Upload to " + scenename + " version " + versionnumber)))
            {
                EditorCore.RefreshSceneVersion(() =>
                {
                    var dynamics          = GameObject.FindObjectsOfType <DynamicObject>();
                    List <GameObject> gos = new List <GameObject>();
                    foreach (var v in dynamics)
                    {
                        gos.Add(v.gameObject);
                    }

                    Selection.objects = gos.ToArray();

                    //GLTFExportMenu.ExportSelected();
                    if (CognitiveVR_SceneExportWindow.ExportSelectedObjectsPrefab())
                    {
                        EditorCore.RefreshSceneVersion(delegate() { ManageDynamicObjects.UploadManifest(() => CognitiveVR_SceneExportWindow.UploadSelectedDynamicObjects(true)); });
                    }

                    //if (CognitiveVR_SceneExportWindow.ExportAllDynamicsInScene())
                    //{
                    //    EditorCore.RefreshSceneVersion(delegate () { ManageDynamicObjects.UploadManifest(() => CognitiveVR_SceneExportWindow.UploadAllDynamicObjects(true)); });
                    //}
                });
            }
            EditorGUI.EndDisabledGroup();

            DrawFooter();
            Repaint(); //manually repaint gui each frame to make sure it's responsive
        }