Example #1
0
        void AuthenticateUpdate()
        {
            GUI.Label(steptitlerect, "STEP 2 - AUTHENTICATION", "steptitle");
            GUI.Label(boldlabelrect, "Please add your Cognitive3D authorization keys below to continue.", "boldlabel");

            //dev key
            GUI.Label(new Rect(30, 200, 100, 30), "Developer Key", "miniheader");
            developerkey = EditorCore.TextField(new Rect(30, 230, 400, 40), developerkey, 32);
            if (string.IsNullOrEmpty(developerkey))
            {
                GUI.Label(new Rect(30, 230, 400, 40), "asdf-hjkl-1234-5678", "ghostlabel");
            }
            else
            {
                GUI.Label(new Rect(440, 230, 24, 40), EditorCore.Checkmark, "image_centered");
            }

            //api key
            GUI.Label(new Rect(30, 300, 100, 30), "API Key", "miniheader");
            apikey = EditorCore.TextField(new Rect(30, 330, 400, 40), apikey, 32);
            if (string.IsNullOrEmpty(apikey))
            {
                GUI.Label(new Rect(30, 330, 400, 40), "asdf-hjkl-1234-5678", "ghostlabel");
            }
            else
            {
                GUI.Label(new Rect(440, 330, 24, 40), EditorCore.Checkmark, "image_centered");
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
        void SaveKeys()
        {
            EditorPrefs.SetString("developerkey", developerkey);
            EditorCore.GetPreferences().APIKey = apikey;

            EditorUtility.SetDirty(EditorCore.GetPreferences());
            AssetDatabase.SaveAssets();
        }
Example #4
0
 void LoadKeys()
 {
     developerkey = EditorPrefs.GetString("developerkey");
     apikey       = EditorCore.GetPreferences().APIKey;
     if (apikey == null)
     {
         apikey = "";
     }
 }
Example #5
0
        public static void Init()
        {
            ManageDynamicObjects window = (ManageDynamicObjects)EditorWindow.GetWindow(typeof(ManageDynamicObjects), true, "");

            window.minSize = new Vector2(500, 550);
            window.maxSize = new Vector2(500, 550);
            window.Show();
            EditorCore.CheckForExpiredDeveloperKey(GetDevKeyResponse);
            needsRefreshDevKey = false;
        }
Example #6
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();
                }
            }
        }
 void DisplayGazeTrackHelpbox(bool trackgaze)
 {
     if (trackgaze && ((DynamicObject)serializedObject.targetObjects[0]).GetComponent <Canvas>() == null)
     {
         DynamicObject dyn             = null;
         int           missingCollider = 0;
         bool          lots            = false;
         for (int i = 0; i < serializedObject.targetObjects.Length; i++)
         {
             dyn = serializedObject.targetObjects[i] as DynamicObject;
             if (dyn)
             {
                 if (EditorCore.GetPreferences().DynamicObjectSearchInParent)
                 {
                     if (!dyn.GetComponentInChildren <Collider>())
                     {
                         missingCollider++;
                         if (missingCollider > 25)
                         {
                             lots = true;
                             break;
                         }
                     }
                 }
                 else
                 {
                     if (!dyn.GetComponent <Collider>())
                     {
                         missingCollider++;
                         if (missingCollider > 25)
                         {
                             lots = true;
                             break;
                         }
                     }
                 }
             }
         }
         if (lots)
         {
             EditorGUILayout.HelpBox("Lots of objects requires a collider to Track Gaze!", MessageType.Warning);
         }
         else if (missingCollider == 1)
         {
             EditorGUILayout.HelpBox("This object requires a collider to Track Gaze!", MessageType.Warning);
         }
         else if (missingCollider > 1)
         {
             EditorGUILayout.HelpBox(missingCollider + " objects requires a collider to Track Gaze!", MessageType.Warning);
         }
     }
 }
Example #8
0
        static void Cognitive3DManager()
        {
            var found = Object.FindObjectOfType <CognitiveVR_Manager>();

            if (found != null)
            {
#if CVR_NEURABLE
                Neurable.Analytics.Portal.NeurableCognitiveMenu.InstantiateAnalyticsManager();
#endif
                Selection.activeGameObject = found.gameObject;
                return;
            }
            else
            {
                EditorCore.SpawnManager(EditorCore.DisplayValue(DisplayKey.ManagerName));
            }
        }
Example #9
0
        //currently UNUSED. useful with the scene export window that shows all scenes regardless of if they were exported
        private static void UpdateSceneNames()
        {
            var prefs = EditorCore.GetPreferences();

            //save these to a temp list
            List <CognitiveVR_Preferences.SceneSettings> oldSettings = new List <CognitiveVR_Preferences.SceneSettings>();

            foreach (var v in prefs.sceneSettings)
            {
                oldSettings.Add(v);
            }


            //clear then rebuild the list in preferences
            prefs.sceneSettings.Clear();

            //add all scenes
            string[] guidList = AssetDatabase.FindAssets("t:scene");

            foreach (var v in guidList)
            {
                string path = AssetDatabase.GUIDToAssetPath(v);
                string name = path.Substring(path.LastIndexOf('/') + 1);
                name = name.Substring(0, name.Length - 6);

                prefs.sceneSettings.Add(new CognitiveVR_Preferences.SceneSettings(name, path));
            }

            //match up dictionary keys from temp list
            foreach (var oldSetting in oldSettings)
            {
                foreach (var newSetting in prefs.sceneSettings)
                {
                    if (newSetting.SceneName == oldSetting.SceneName)
                    {
                        newSetting.SceneId       = oldSetting.SceneId;
                        newSetting.LastRevision  = oldSetting.LastRevision;
                        newSetting.SceneName     = oldSetting.SceneName;
                        newSetting.ScenePath     = oldSetting.ScenePath;
                        newSetting.VersionId     = oldSetting.VersionId;
                        newSetting.VersionNumber = oldSetting.VersionNumber;
                    }
                }
            }
        }
Example #10
0
        static void Cognitive3DManager()
        {
            var found = Object.FindObjectOfType <CognitiveVR_Manager>();

            if (found != null)
            {
                Selection.activeGameObject = found.gameObject;
                return;
            }
            else
            {
                string gameobjectName = "CognitiveVR_Manager";
#if CVR_NEURABLE
                gameobjectName = "Neurable Cognitive Engine";
#endif

                EditorCore.SpawnManager(gameobjectName);
            }
        }
Example #11
0
        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();
        }
Example #12
0
        void GetManifestResponse(int responsecode, string error, string text)
        {
            if (responsecode == 200)
            {
                //BuildManifest(getRequest.text);
                var allEntries = JsonUtil.GetJsonArray <AggregationManifest.AggregationManifestEntry>(text);

                Debug.Log("Number of Dynamic Objects in current Manifest: " + allEntries.Length);

                Manifest = new AggregationManifest();

                Manifest.objects = new List <AggregationManifest.AggregationManifestEntry>(allEntries);
                Repaint();

                //also hit settings to get the current version of the scene
                EditorCore.RefreshSceneVersion(null);
            }
            else
            {
                Util.logWarning("GetManifestResponse " + responsecode + " " + error);
            }
        }
Example #13
0
        public static void CheckGazeRenderType()
        {
            var p = EditorCore.GetPreferences();

            if (PlayerSettings.stereoRenderingPath == StereoRenderingPath.MultiPass && p.RenderPassType != 0)
            {
                p.RenderPassType = 0;
                EditorUtility.SetDirty(p);
            }
            else if (PlayerSettings.stereoRenderingPath == StereoRenderingPath.SinglePass && p.RenderPassType != 1)
            {
                p.RenderPassType = 1;
                EditorUtility.SetDirty(p);
            }
            else if (PlayerSettings.stereoRenderingPath == StereoRenderingPath.Instancing)
            {
                if (p.GazeType == GazeType.Command)
                {
                    Debug.LogError("Cognitive3D Analytics does not support Command Buffer Gaze with SinglePass (Instanced) stereo rendering. Please change the gaze type in Cognitive3D->Advanced Options menu");
                }
            }
        }
Example #14
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);
            //    });
            //}
        }
Example #15
0
        void UploadSummaryUpdate()
        {
            GUI.Label(steptitlerect, "STEP 8 - UPLOAD", "steptitle");
            GUI.Label(new Rect(30, 45, 440, 440), "Here is a final summary of what will be uploaded to <color=#8A9EB7FF>SceneExplorer</color>:", "boldlabel");

            int dynamicObjectCount = GetDynamicObjects.Length;

            GUI.Label(new Rect(30, 120, 440, 440), "You will be uploading <color=#62B4F3FF>" + dynamicObjectCount + "</color> Dynamic Objects", "label_disabledtext_large");

            string scenename = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;

            if (string.IsNullOrEmpty(scenename))
            {
                scenename = "SCENE NOT SAVED";
            }
            string settingsname = "Maximum Quality";

            if (qualityindex == 0)
            {
                settingsname = "Low Quality";
            }
            if (qualityindex == 1)
            {
                settingsname = "Medium Quality";
            }
            GUI.Label(new Rect(30, 150, 440, 440), "You will be uploading <color=#62B4F3FF>" + scenename + "</color> with <color=#62B4F3FF>" + settingsname + "</color>", "label_disabledtext_large");

            GUI.Label(new Rect(30, 200, 440, 440), "Your scene display image will be this:", "label_disabledtext_large");

            var sceneRT = EditorCore.GetSceneRenderTexture();

            if (sceneRT != null)
            {
                GUI.Box(new Rect(175, 230, 150, 150), sceneRT, "image_centeredboxed");
            }

            GUI.Label(new Rect(30, 390, 440, 440), "You can add <color=#8A9EB7FF>ExitPoll</color> surveys, update <color=#8A9EB7FF>Dynamic Objects</color>, and add user engagement scripts after this process is complete.", "normallabel");
        }
Example #16
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
        }
Example #17
0
        //each row is 30 pixels
        void DrawDynamicObject(DynamicObject dynamic, Rect rect, bool darkbackground)
        {
            Event e = Event.current;

            if (e.isMouse && e.type == EventType.mouseDown)
            {
                if (e.mousePosition.x < rect.x || e.mousePosition.x > rect.x + rect.width || e.mousePosition.y < rect.y || e.mousePosition.y > rect.y + rect.height)
                {
                }
                else
                {
                    if (e.shift) //add to selection
                    {
                        GameObject[] gos = new GameObject[Selection.transforms.Length + 1];
                        Selection.gameObjects.CopyTo(gos, 0);
                        gos[gos.Length - 1] = dynamic.gameObject;
                        Selection.objects   = gos;
                    }
                    else
                    {
                        Selection.activeTransform = dynamic.transform;
                    }
                }
            }

            if (darkbackground)
            {
                GUI.Box(rect, "", "dynamicentry_even");
            }
            else
            {
                GUI.Box(rect, "", "dynamicentry_odd");
            }

            //GUI.color = Color.white;

            Rect mesh       = new Rect(rect.x + 10, rect.y, 120, rect.height);
            Rect gameobject = new Rect(rect.x + 160, rect.y, 120, rect.height);
            //Rect id = new Rect(rect.x + 290, rect.y, 120, rect.height);

            Rect collider = new Rect(rect.x + 320, rect.y, 24, rect.height);
            Rect uploaded = new Rect(rect.x + 380, rect.y, 24, rect.height);

            if (dynamic.UseCustomMesh)
            {
                GUI.Label(mesh, dynamic.MeshName, "dynamiclabel");
            }
            else
            {
                GUI.Label(mesh, dynamic.CommonMesh.ToString(), "dynamiclabel");
            }
            GUI.Label(gameobject, dynamic.gameObject.name, "dynamiclabel");

            if (!dynamic.HasCollider())
            {
                GUI.Label(collider, new GUIContent(EditorCore.Alert, "Tracking Gaze requires a collider"), "image_centered");
            }
            if (EditorCore.GetExportedDynamicObjectNames().Contains(dynamic.MeshName) || !dynamic.UseCustomMesh)
            {
                GUI.Label(uploaded, EditorCore.Checkmark, "image_centered");
            }
            else
            {
                GUI.Label(uploaded, EditorCore.EmptyCheckmark, "image_centered");
            }
        }
Example #18
0
        void OnGUI()
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (selectedClip != null)
            {
                GUILayout.Label(AssetPreview.GetMiniThumbnail(selectedClip), GUILayout.Height(128), GUILayout.Width(128));
            }
            else
            {
                GUILayout.Box("", GUILayout.Height(128), GUILayout.Width(128));
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            selectedClip = (VideoClip)EditorGUILayout.ObjectField(selectedClip, typeof(UnityEngine.Video.VideoClip), true);

            if (EditorCore.MediaSources.Length == 0)
            {
                if (GUILayout.Button("Refresh Media Sources"))
                {
                    EditorCore.RefreshMediaSources();
                }
                return;
            }

            //media source
            string[] displayOptions = new string[EditorCore.MediaSources.Length];
            for (int i = 0; i < EditorCore.MediaSources.Length; i++)
            {
                displayOptions[i] = EditorCore.MediaSources[i].name;
            }
            _choiceIndex = EditorGUILayout.Popup("Select Media Source", _choiceIndex, displayOptions);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Description:", GUILayout.Width(100));
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextArea(EditorCore.MediaSources[_choiceIndex].description);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            GUILayout.Space(20);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Projection Type");
            if (latlong)
            {
                GUI.color = Color.green;
            }
            if (GUILayout.Button("Latitude Longitude", EditorStyles.miniButtonLeft))
            {
                latlong = true;
            }
            GUI.color = Color.white;
            if (!latlong)
            {
                GUI.color = Color.green;
            }
            if (GUILayout.Button("Cubemap", EditorStyles.miniButtonRight))
            {
                latlong = false;
            }
            GUI.color = Color.white;
            GUILayout.EndHorizontal();


            EditorGUI.BeginDisabledGroup(selectedClip == null || string.IsNullOrEmpty(EditorCore.MediaSources[_choiceIndex].name));
            if (GUILayout.Button("Create"))
            {
                CreateAssets();
            }
            EditorGUI.EndDisabledGroup();
        }
Example #19
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();
        }
        public override void OnInspectorGUI()
        {
            MediaComponent m = (MediaComponent)target;

            var meshrenderer = m.GetComponent <MeshRenderer>();

            if (m.VideoPlayer == null && meshrenderer != null)
            {
                //image
            }
            else if (m.VideoPlayer != null)
            {
                //video
            }
            else
            {
                EditorGUILayout.HelpBox("If media is a video, Video Player must be set\nIf media is an image, must have mesh render on this gameobject", MessageType.Error);
                //not set up
            }

            //display script field
            var script = serializedObject.FindProperty("m_Script");

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();

            //video player component
            m.VideoPlayer = (UnityEngine.Video.VideoPlayer)EditorGUILayout.ObjectField("Video Player", m.VideoPlayer, typeof(UnityEngine.Video.VideoPlayer), true);

            //media source
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextField("Media Source", m.MediaSource);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();
            string[] displayOptions = new string[EditorCore.MediaSources.Length];
            if (displayOptions.Length == 0)
            {
                if (GUILayout.Button("Refresh Media"))
                {
                    EditorCore.RefreshMediaSources();
                }
                EditorGUILayout.EndHorizontal();
                return;
            }

            if (!string.IsNullOrEmpty(m.MediaSource) && _choiceIndex == 0 && displayOptions.Length > 0)
            {
                //try once to select the correct media
                for (int i = 0; i < EditorCore.MediaSources.Length; i++)
                {
                    if (EditorCore.MediaSources[i].uploadId == m.MediaSource)
                    {
                        _choiceIndex = i;
                    }
                }
            }

            for (int i = 0; i < EditorCore.MediaSources.Length; i++)
            {
                displayOptions[i] = EditorCore.MediaSources[i].name;
            }
            _choiceIndex = EditorGUILayout.Popup("Select Media Source", _choiceIndex, displayOptions);


            if (m.MediaSource != EditorCore.MediaSources[_choiceIndex].uploadId)
            {
                GUI.color = Color.green;
            }

            if (GUILayout.Button("Save", GUILayout.Width(40)))
            {
                m.MediaSource = EditorCore.MediaSources[_choiceIndex].uploadId;
            }

            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(true);

            //EditorGUILayout.LabelField("Id", EditorCore.MediaSources[_choiceIndex].uploadId);
            //GUILayout.Label("Description");
            EditorGUILayout.TextArea(EditorCore.MediaSources[_choiceIndex].description);

            EditorGUI.EndDisabledGroup();

            if (GUI.changed)
            {
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
            }
        }
Example #21
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);
            }
        }
Example #22
0
 static void CognitiveCheckUpdates()
 {
     EditorCore.ForceCheckUpdates();
 }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            var script            = serializedObject.FindProperty("m_Script");
            var updateRate        = serializedObject.FindProperty("UpdateRate");
            var positionThreshold = serializedObject.FindProperty("PositionThreshold");
            var rotationThreshold = serializedObject.FindProperty("RotationThreshold");
            var scaleThreshold    = serializedObject.FindProperty("ScaleThreshold");
            var useCustomId       = serializedObject.FindProperty("UseCustomId");
            var customId          = serializedObject.FindProperty("CustomId");
            var commonMeshName    = serializedObject.FindProperty("CommonMesh");
            var meshname          = serializedObject.FindProperty("MeshName");
            var useCustomMesh     = serializedObject.FindProperty("UseCustomMesh");
            var isController      = serializedObject.FindProperty("IsController");
            var syncWithGaze      = serializedObject.FindProperty("SyncWithPlayerGazeTick");
            var idPool            = serializedObject.FindProperty("IdPool");

            foreach (var t in serializedObject.targetObjects) //makes sure a custom id is valid
            {
                var dynamic = t as DynamicObject;
                if (dynamic.editorInstanceId != dynamic.GetInstanceID() || string.IsNullOrEmpty(dynamic.CustomId)) //only check if something has changed on a dynamic, or if the id is empty
                {
                    if (dynamic.UseCustomId && idType == 0)
                    {
                        if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(dynamic.gameObject)))//scene asset
                        {
                            dynamic.editorInstanceId = dynamic.GetInstanceID();
                            CheckCustomId();
                        }
                        else //project asset
                        {
                            dynamic.editorInstanceId = dynamic.GetInstanceID();
                            if (string.IsNullOrEmpty(dynamic.CustomId))
                            {
                                string s = System.Guid.NewGuid().ToString();
                                dynamic.CustomId = "editor_" + s;
                            }
                        }
                    }
                }
            }

            //display script on component
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();

            //use custom mesh and mesh text field
            GUILayout.BeginHorizontal();
            UnityEditor.EditorGUILayout.PropertyField(useCustomMesh);
            bool anycustomnames = false;

            foreach (var t in targets)
            {
                var dyn = t as DynamicObject;
                if (dyn.UseCustomMesh)
                {
                    anycustomnames = true;
                    if (string.IsNullOrEmpty(dyn.MeshName))
                    {
                        dyn.MeshName = dyn.gameObject.name.ToLower().Replace(" ", "_").Replace("<", "_").Replace(">", "_").Replace("|", "_").Replace("?", "_").Replace("*", "_").Replace("\"", "_").Replace("/", "_").Replace("\\", "_").Replace(":", "_");
                        if (!Application.isPlaying)
                        {
                            UnityEditor.EditorUtility.SetDirty(dyn);
                            UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                        }
                    }
                    if (targets.Length == 1)
                    {
                        dyn.MeshName = UnityEditor.EditorGUILayout.TextField("", dyn.MeshName);
                    }
                }
            }
            if (!anycustomnames)
            {
                UnityEditor.EditorGUILayout.PropertyField(commonMeshName, new GUIContent(""));
            }
            GUILayout.EndHorizontal();

            if (idType == -1)
            {
                var dyn = target as DynamicObject;
                if (dyn.UseCustomId)
                {
                    idType = 0;
                }
                else if (dyn.IdPool != null)
                {
                    idType = 2;
                }
                else
                {
                    idType = 1;
                }
            }
            GUILayout.BeginHorizontal();
            idType = EditorGUILayout.Popup(new GUIContent("Id Source"), idType, idTypeNames);

            if (idType == 0) //custom id
            {
                EditorGUILayout.PropertyField(customId, new GUIContent(""));
                useCustomId.boolValue       = true;
                idPool.objectReferenceValue = null;
            }
            else if (idType == 1) //generate id
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.LabelField(new GUIContent("Id will be generated at runtime", "This object will not be included in aggregation metrics on the dashboard"));
                EditorGUI.EndDisabledGroup();
                customId.stringValue        = string.Empty;
                useCustomId.boolValue       = false;
                idPool.objectReferenceValue = null;
            }
            else if (idType == 2) //id pool
            {
                EditorGUILayout.ObjectField(idPool, new GUIContent("", "Provides a consistent list of Ids to be used at runtime. Allows aggregated data from objects spawned at runtime"));
                customId.stringValue  = string.Empty;
                useCustomId.boolValue = false;
            }
            GUILayout.EndHorizontal();

            if (idType == 2) //id pool
            {
                var dyn = target as DynamicObject;
                if (dyn.IdPool == null)
                {
                    if (GUILayout.Button("New Dynamic Object Id Pool"))
                    {
                        var pool = ScriptableObject.CreateInstance <DynamicObjectIdPool>();
                        //write some values
                        pool.Ids = new string[1] {
                            System.Guid.NewGuid().ToString()
                        };
                        pool.MeshName   = dyn.MeshName;
                        pool.PrefabName = dyn.gameObject.name;
                        //save to root assets folder
                        AssetDatabase.CreateAsset(pool, "Assets/" + pool.MeshName + " Id Pool.asset");
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                        //get reference to file
                        idPool.objectReferenceValue = pool;
                    }
                }
            }

            foldout = EditorGUILayout.Foldout(foldout, "Advanced");
            if (foldout)
            {
                if (useCustomMesh.boolValue)
                {
                    //Mesh
                    GUILayout.Label("Export and Upload", EditorStyles.boldLabel);
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Export Mesh", "ButtonLeft", GUILayout.Height(30)))
                    {
                        ExportUtility.ExportAllSelectedDynamicObjects();
                    }

                    EditorGUI.BeginDisabledGroup(!EditorCore.HasDynamicExportFiles(meshname.stringValue));
                    if (GUILayout.Button("Thumbnail from\nSceneView", "ButtonMid", GUILayout.Height(30)))
                    {
                        foreach (var v in serializedObject.targetObjects)
                        {
                            EditorCore.SaveDynamicThumbnailSceneView((v as DynamicObject).gameObject);
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    EditorGUI.BeginDisabledGroup(!EditorCore.HasDynamicExportFiles(meshname.stringValue));
                    if (GUILayout.Button("Upload Mesh", "ButtonRight", GUILayout.Height(30)))
                    {
                        ExportUtility.UploadSelectedDynamicObjectMeshes(true);
                    }
                    EditorGUI.EndDisabledGroup();

                    //texture export settings
                    GUILayout.EndHorizontal();
                    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*/ };
                    CognitiveVR_Preferences.Instance.TextureResize = EditorGUILayout.IntPopup(new GUIContent("Texture Export Quality", "Reduce textures when uploading to scene explorer"), CognitiveVR_Preferences.Instance.TextureResize, textureQualityNames, textureQualities);
                    GUILayout.Space(5);

                    //ID upload
                    var dyn = target as DynamicObject;
                    if (dyn.UseCustomId)
                    {
                        EditorGUI.BeginDisabledGroup(!EditorCore.HasDynamicExportFiles(meshname.stringValue));
                        if (GUILayout.Button("Upload Custom ID for aggregation"))
                        {
                            Debug.Log("upload custom id to scene");
                            //ExportUtility.UploadSelectedDynamicObjectMeshes(true);
                            EditorCore.RefreshSceneVersion(delegate()
                            {
                                ManageDynamicObjects.AggregationManifest manifest = new ManageDynamicObjects.AggregationManifest();
                                manifest.objects.Add(new ManageDynamicObjects.AggregationManifest.AggregationManifestEntry(dyn.gameObject.name, dyn.MeshName, dyn.CustomId));
                                ManageDynamicObjects.UploadManifest(manifest, null);
                            });
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                    else if (dyn.IdPool != null)
                    {
                        EditorGUI.BeginDisabledGroup(!EditorCore.HasDynamicExportFiles(meshname.stringValue));
                        if (GUILayout.Button("Upload ID Pool for aggregation"))
                        {
                            Debug.Log("upload id pool to scene");
                            //ExportUtility.UploadSelectedDynamicObjectMeshes(true);
                            EditorCore.RefreshSceneVersion(delegate()
                            {
                                ManageDynamicObjects.AggregationManifest manifest = new ManageDynamicObjects.AggregationManifest();
                                for (int i = 0; i < dyn.IdPool.Ids.Length; i++)
                                {
                                    manifest.objects.Add(new ManageDynamicObjects.AggregationManifest.AggregationManifestEntry(dyn.gameObject.name, dyn.MeshName, dyn.IdPool.Ids[i]));
                                }
                                ManageDynamicObjects.UploadManifest(manifest, null);
                            });
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                }

                //Snapshot Threshold

                GUILayout.Label("Data Snapshot", EditorStyles.boldLabel);

                //controller stuff
                GUILayout.BeginHorizontal();

                UnityEditor.EditorGUILayout.PropertyField(isController, new GUIContent("Is Controller", "If true, this will record user's inputs and display the inputs in a popup on SceneExplorer"));

                if (targets.Length == 1)
                {
                    var dyn = targets[0] as DynamicObject;

                    if (dyn.IsController)
                    {
                        dyn.ControllerType = (DynamicObject.ControllerDisplayType)EditorGUILayout.EnumPopup(dyn.ControllerType);
                    }

                    if (dyn.IsController)
                    {
                        EditorGUILayout.LabelField("Is Right", GUILayout.Width(60));
                        dyn.IsRight = EditorGUILayout.Toggle(dyn.IsRight, GUILayout.Width(20));
                    }
                }

                GUILayout.EndHorizontal();

                EditorGUILayout.PropertyField(syncWithGaze, new GUIContent("Sync with Gaze", "Records the transform of the dynamic object on the same frame as gaze. This may smooth movement of this object in SceneExplorer relative to the player's position"));
                EditorGUI.BeginDisabledGroup(syncWithGaze.boolValue);
                EditorGUILayout.PropertyField(updateRate, new GUIContent("Update Rate", "This is the Snapshot interval in the Tracker Options Window"), GUILayout.MinWidth(50));
                updateRate.floatValue = Mathf.Max(0.1f, updateRate.floatValue);
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.PropertyField(positionThreshold, new GUIContent("Position Threshold", "Meters the object must move to write a new snapshot. Checked each 'Tick'"));
                positionThreshold.floatValue = Mathf.Max(0, positionThreshold.floatValue);

                EditorGUILayout.PropertyField(rotationThreshold, new GUIContent("Rotation Threshold", "Degrees the object must rotate to write a new snapshot. Checked each 'Tick'"));
                rotationThreshold.floatValue = Mathf.Max(0, rotationThreshold.floatValue);

                EditorGUILayout.PropertyField(scaleThreshold, new GUIContent("Scale Threshold", "Scale multiplier that must be exceeded to write a new snapshot. Checked each 'Tick'"));
                scaleThreshold.floatValue = Mathf.Max(0, scaleThreshold.floatValue);

                EditorGUI.EndDisabledGroup();
            } //advanced foldout


            if (GUI.changed)
            {
                foreach (var t in targets)
                {
                    var dyn = t as DynamicObject;
                    if (dyn.UseCustomMesh)
                    {
                        //replace all invalid characters <>|?*"/\: with _
                        dyn.MeshName = dyn.MeshName.Replace(" ", "_").Replace("<", "_").Replace(">", "_").Replace("|", "_").Replace("?", "_").Replace("*", "_").Replace("\"", "_").Replace("/", "_").Replace("\\", "_").Replace(":", "_");
                    }
                }

                //IMPROVEMENT should check that some meaningful property changed, not just foldout
                if (!Application.isPlaying)
                {
                    foreach (var t in targets)
                    {
                        EditorUtility.SetDirty(t);
                    }
                    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                }
            }

            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();
        }
Example #24
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
        }
Example #25
0
        private void OnGUI()
        {
            if (needsRefreshDevKey == true)
            {
                EditorCore.CheckForExpiredDeveloperKey(GetDevKeyResponse);
                needsRefreshDevKey = false;
            }
            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, "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, "Exported Mesh", "dynamicheader");
            //IMPROVEMENT get list of uploaded mesh names from dashboard


            //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");
            }

            DynamicObjectIdPool[] poolAssets = EditorCore.GetDynamicObjectPoolAssets;


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

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

            Rect dynamicrect;
            int  GuiOffset = 0;

            for (; GuiOffset < tempdynamics.Length; GuiOffset++)
            {
                if (tempdynamics[GuiOffset] == null)
                {
                    RefreshSceneDynamics(); GUI.EndScrollView(); return;
                }
                dynamicrect = new Rect(30, GuiOffset * 30, 460, 30);
                DrawDynamicObject(tempdynamics[GuiOffset], dynamicrect, GuiOffset % 2 == 0);
            }
            for (int i = 0; i < poolAssets.Length; i++)
            {
                //if (poolAssets[i] == null) { RefreshSceneDynamics(); GUI.EndScrollView(); return; }
                dynamicrect = new Rect(30, (i + GuiOffset) * 30, 460, 30);
                DrawDynamicObjectPool(poolAssets[i], dynamicrect, (i + GuiOffset) % 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++;
                }
            }

            //IMPROVEMENT enable mesh upload from selected dynamic object id pool that has exported mesh files
            //if (Selection.activeObject.GetType() == typeof(DynamicObjectIdPool))
            //{
            //    var pool = Selection.activeObject as DynamicObjectIdPool;
            //    if (EditorCore.HasDynamicExportFiles(pool.MeshName))
            //    {
            //        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;
            }
            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;
            }
            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) || selectionCount == 0);
            if (GUI.Button(new Rect(30, 460, 200, 30), new GUIContent("Upload " + selectionCount + " Selected Meshes", DisableButtons ? "" : "Export and Upload to " + scenename + " version " + versionnumber)))
            {
                EditorCore.RefreshSceneVersion(() =>
                {
                    foreach (var go in Selection.gameObjects)
                    {
                        var dyn = go.GetComponent <DynamicObject>();
                        if (dyn == null)
                        {
                            continue;
                        }
                        //check if export files exist
                        if (!EditorCore.HasDynamicExportFiles(dyn.MeshName))
                        {
                            ExportUtility.ExportDynamicObject(dyn);
                        }
                        //check if thumbnail exists
                        if (!EditorCore.HasDynamicObjectThumbnail(dyn.MeshName))
                        {
                            EditorCore.SaveDynamicThumbnailAutomatic(dyn.gameObject);
                        }
                    }

                    EditorCore.RefreshSceneVersion(delegate()
                    {
                        var manifest = new AggregationManifest();
                        AddOrReplaceDynamic(manifest, GetDynamicObjectsInScene());
                        ManageDynamicObjects.UploadManifest(manifest, () => ExportUtility.UploadSelectedDynamicObjectMeshes(true));
                    });
                });
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(currentscene == null || string.IsNullOrEmpty(currentscene.SceneId));
            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();

                    foreach (var go in Selection.gameObjects)
                    {
                        var dyn = go.GetComponent <DynamicObject>();
                        if (dyn == null)
                        {
                            continue;
                        }
                        //check if export files exist
                        if (!EditorCore.HasDynamicExportFiles(dyn.MeshName))
                        {
                            ExportUtility.ExportDynamicObject(dyn);
                        }
                        //check if thumbnail exists
                        if (!EditorCore.HasDynamicObjectThumbnail(dyn.MeshName))
                        {
                            EditorCore.SaveDynamicThumbnailAutomatic(dyn.gameObject);
                        }
                    }

                    EditorCore.RefreshSceneVersion(delegate()
                    {
                        var manifest = new AggregationManifest();
                        AddOrReplaceDynamic(manifest, GetDynamicObjectsInScene());
                        ManageDynamicObjects.UploadManifest(manifest, () => ExportUtility.UploadSelectedDynamicObjectMeshes(true));
                    });
                });
            }
            EditorGUI.EndDisabledGroup();

            DrawFooter();
            Repaint(); //manually repaint gui each frame to make sure it's responsive
        }
Example #26
0
 public override void OnClose()
 {
     EditorCore.SetPlayerDefine(option);
 }
Example #27
0
 static void Cognitive3DOptions()
 {
     //select asset
     Selection.activeObject = EditorCore.GetPreferences();
 }
Example #28
0
 static void RefreshMediaSources()
 {
     EditorCore.RefreshMediaSources();
 }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var idpools = targets;
            var idpool  = (DynamicObjectIdPool)target;

            if (!EditorCore.HasDynamicExportFiles(idpool.MeshName))
            {
                EditorGUILayout.HelpBox("Mesh: " + idpool.MeshName + " not found!\nAdd your prefab to the scene and press 'Export Mesh' in the 'advanced' inspector foldout", MessageType.Warning);
            }

            bool   holdingShift = Event.current.shift;
            string AddIdString  = holdingShift ? "Add Id (x5)" : "Add Id";

            GUILayout.BeginHorizontal();

            if (GUILayout.Button(AddIdString, GUILayout.Width(100)))
            {
                foreach (Object opool in idpools)
                {
                    var pool = (DynamicObjectIdPool)opool;

                    if (pool.Ids == null)
                    {
                        pool.Ids = new string[0];
                    }

                    if (holdingShift)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            ArrayUtility.Add(ref pool.Ids, System.Guid.NewGuid().ToString());
                        }
                    }
                    else
                    {
                        ArrayUtility.Add(ref pool.Ids, System.Guid.NewGuid().ToString());
                    }
                }
            }

            EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(idpool.PrefabName) || string.IsNullOrEmpty(idpool.MeshName) || idpool.Ids == null || idpool.Ids.Length == 0);
            if (GUILayout.Button("Upload Ids"))
            {
                EditorCore.RefreshSceneVersion(delegate()
                {
                    ManageDynamicObjects.AggregationManifest manifest = new CognitiveVR.ManageDynamicObjects.AggregationManifest();
                    foreach (Object opool in idpools)
                    {
                        var pool = (DynamicObjectIdPool)opool;
                        foreach (var id in pool.Ids)
                        {
                            manifest.objects.Add(new ManageDynamicObjects.AggregationManifest.AggregationManifestEntry(pool.PrefabName, pool.MeshName, id));
                        }
                    }

                    ManageDynamicObjects.UploadManifest(manifest, null);
                });
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            Repaint();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            var script               = serializedObject.FindProperty("m_Script");
            var groupName            = serializedObject.FindProperty("GroupName");
            var syncWithPlayerUpdate = serializedObject.FindProperty("SyncWithPlayerUpdate");
            var updateRate           = serializedObject.FindProperty("UpdateRate");
            var positionThreshold    = serializedObject.FindProperty("PositionThreshold");
            var rotationThreshold    = serializedObject.FindProperty("RotationThreshold");
            var snapshotOnEnable     = serializedObject.FindProperty("SnapshotOnEnable");
            var updateTicksOnEnable  = serializedObject.FindProperty("UpdateTicksOnEnable");
            var releaseOnDisable     = serializedObject.FindProperty("ReleaseIdOnDisable");
            var releaseOnDestroy     = serializedObject.FindProperty("ReleaseIdOnDestroy");
            var useCustomID          = serializedObject.FindProperty("UseCustomId");
            var customId             = serializedObject.FindProperty("CustomId");
            var commonMeshName       = serializedObject.FindProperty("CommonMesh");
            var meshname             = serializedObject.FindProperty("MeshName");
            var useCustomMesh        = serializedObject.FindProperty("UseCustomMesh");
            var trackGaze            = serializedObject.FindProperty("TrackGaze");
            var requiresManualEnable = serializedObject.FindProperty("RequiresManualEnable");

            foreach (var t in serializedObject.targetObjects)
            {
                var dynamic = t as DynamicObject;
                if (dynamic.iId != dynamic.GetInstanceID() || string.IsNullOrEmpty(dynamic.CustomId)) //only check if something has changed on a dynamic
                {
                    if (dynamic.UseCustomId)
                    {
                        dynamic.iId = dynamic.GetInstanceID(); //this will often mark the scene dirty without any apparent or meaningful changes
                        CheckCustomId(ref dynamic.CustomId);
                        //TODO cache while scene active, but don't bother marking scene dirty if only iId is dirty
                    }
                }
            }


#if UNITY_5_6_OR_NEWER
            //video
            //var flipVideo = serializedObject.FindProperty("FlipVideo");
            //var externalVideoSource = serializedObject.FindProperty("ExternalVideoSource");
            var videoPlayer = serializedObject.FindProperty("VideoPlayer");
#endif

            //display script on component
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();

            GUILayout.BeginHorizontal();

            UnityEditor.EditorGUILayout.PropertyField(useCustomMesh);

            bool anycustomnames = false;
            foreach (var t in targets)
            {
                var dyn = t as DynamicObject;
                if (dyn.UseCustomMesh)
                {
                    anycustomnames = true;
                    if (string.IsNullOrEmpty(dyn.MeshName))
                    {
                        dyn.MeshName = dyn.gameObject.name.ToLower().Replace(" ", "_");
                        UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                    }
                    if (targets.Length == 1)
                    {
                        dyn.MeshName = UnityEditor.EditorGUILayout.TextField("", dyn.MeshName);
                    }
                }
            }
            if (!anycustomnames)
            {
                UnityEditor.EditorGUILayout.PropertyField(commonMeshName, new GUIContent(""));
            }

            GUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(trackGaze, new GUIContent("Track Gaze on Dynamic Object"));
            DisplayGazeTrackHelpbox(trackGaze.boolValue);

            GUILayout.Space(10);

            foldout = EditorGUILayout.Foldout(foldout, "Advanced");
            if (foldout)
            {
                if (useCustomMesh.boolValue)
                {
                    //Mesh
                    GUILayout.Label("Mesh", EditorStyles.boldLabel);


                    //EditorGUI.BeginDisabledGroup(useCustomMesh.boolValue);
                    //UnityEditor.EditorGUILayout.PropertyField(commonMeshName);
                    //EditorGUI.EndDisabledGroup();

                    if (string.IsNullOrEmpty(meshname.stringValue))
                    {
                        //meshname.stringValue = serializedObject.targetObject.name.ToLower().Replace(" ", "_");
                        UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                    }

                    GUILayout.BeginHorizontal();
                    //UnityEditor.EditorGUILayout.PropertyField(useCustomMesh);

                    //EditorGUI.BeginDisabledGroup(!useCustomMesh.boolValue);
                    UnityEditor.EditorGUILayout.PropertyField(meshname, new GUIContent(""));
                    if (GUILayout.Button("Export", "ButtonLeft", GUILayout.MaxWidth(100)))
                    {
                        CognitiveVR_SceneExportWindow.ExportSelectedObjectsPrefab();
                        foreach (var t in serializedObject.targetObjects)
                        {
                            var dyn = t as DynamicObject;
                            if (!dyn.UseCustomId)
                            {
                                EditorCore.SaveDynamicThumbnailAutomatic(dyn.gameObject);
                            }
                        }
                    }

                    EditorGUI.BeginDisabledGroup(!EditorCore.HasDynamicExportFiles(meshname.stringValue));
                    if (GUILayout.Button("Upload", "ButtonRight", GUILayout.MaxWidth(100)))
                    {
                        CognitiveVR_SceneExportWindow.UploadSelectedDynamicObjects(true);
                    }
                    EditorGUI.EndDisabledGroup();

                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    EditorGUI.BeginDisabledGroup(!EditorCore.HasDynamicExportFiles(meshname.stringValue));
                    if (GUILayout.Button("Thumbnail from SceneView", GUILayout.MaxWidth(180)))
                    {
                        foreach (var v in serializedObject.targetObjects)
                        {
                            EditorCore.SaveDynamicThumbnailSceneView((v as DynamicObject).gameObject);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                    GUILayout.EndHorizontal();
                }

                //Setup
                GUILayout.Label("Setup", EditorStyles.boldLabel);

                UnityEditor.EditorGUILayout.PropertyField(snapshotOnEnable, new GUIContent("Snapshot On Enable", "Save the transform when this object is first enabled"));

                //EditorGUI.BeginDisabledGroup(!snapshotOnEnable.boolValue);
                UnityEditor.EditorGUILayout.PropertyField(updateTicksOnEnable, new GUIContent("Update Ticks on Enable", "Begin coroutine that saves the transform of this object when it moves"));
                //EditorGUI.EndDisabledGroup();

                EditorGUILayout.PropertyField(trackGaze, new GUIContent("Track Gaze on Dynamic Object"));

                DisplayGazeTrackHelpbox(trackGaze.boolValue);

                EditorGUILayout.PropertyField(requiresManualEnable, new GUIContent("Requires Manual Enable", "If true, ManualEnable must be called before OnEnable will function. Used to set initial variables on an object"));


                //Object ID
                GUILayout.Label("Ids", EditorStyles.boldLabel);

                GUILayout.BeginHorizontal();

                EditorGUILayout.PropertyField(useCustomID, new GUIContent("Use Custom Id", "This is used to identify specific objects to aggregate the position across multiple play sessions"));

                EditorGUI.BeginDisabledGroup(!useCustomID.boolValue);
                EditorGUILayout.PropertyField(customId, new GUIContent(""));
                EditorGUI.EndDisabledGroup();

                GUILayout.EndHorizontal();

                EditorGUILayout.PropertyField(groupName, new GUIContent("Group Name", "This is used to identify types of objects and combine aggregated data"));

                EditorGUILayout.PropertyField(releaseOnDisable, new GUIContent("Release Id OnDisable", "Allow other objects to use this Id when this object is no longer active"));
                EditorGUILayout.PropertyField(releaseOnDestroy, new GUIContent("Release Id OnDestroy", "Allow other objects to use this Id when this object is no longer active"));

                //Snapshot Threshold
                GUILayout.Label("Snapshot Threshold", EditorStyles.boldLabel);


                EditorGUILayout.PropertyField(syncWithPlayerUpdate, new GUIContent("Sync with Player Update", "This is the Snapshot interval in the Tracker Options Window"));

                EditorGUI.BeginDisabledGroup(syncWithPlayerUpdate.boolValue);
                if (syncWithPlayerUpdate.boolValue)
                {
                    EditorGUILayout.FloatField(new GUIContent("Update Rate", "Synced with Player Update.\nThe interval between checking for modified position and rotation"), EditorCore.GetPreferences().SnapshotInterval);
                }
                else
                {
                    EditorGUILayout.PropertyField(updateRate, new GUIContent("Update Rate", "The interval between checking for modified position and rotation"));
                }
                updateRate.floatValue = Mathf.Max(0.1f, updateRate.floatValue);
                EditorGUI.EndDisabledGroup();


                EditorGUILayout.PropertyField(positionThreshold, new GUIContent("Position Threshold", "Meters the object must move to write a new snapshot. Checked each 'Tick'"));
                positionThreshold.floatValue = Mathf.Max(0, positionThreshold.floatValue);

                EditorGUILayout.PropertyField(rotationThreshold, new GUIContent("Rotation Threshold", "Degrees the object must rotate to write a new snapshot. Checked each 'Tick'"));
                rotationThreshold.floatValue = Mathf.Max(0, rotationThreshold.floatValue);

#if !UNITY_5_6_OR_NEWER
                GUILayout.Label("Video Settings", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox("Video Player requires Unity 5.6 or newer!", MessageType.Warning);
#else
                GUILayout.Label("Video Settings", EditorStyles.boldLabel);

                EditorGUILayout.PropertyField(videoPlayer, new GUIContent("Video Player"));

                //EditorGUILayout.PropertyField(externalVideoSource, new GUIContent("External Video Source", "The URL source of the video"));
                //EditorGUILayout.PropertyField(flipVideo, new GUIContent("Flip Video Horizontally"));
#endif
            } //advanced foldout


            if (GUI.changed)
            {
                foreach (var t in targets)
                {
                    var dyn = t as DynamicObject;
                    if (dyn.UseCustomMesh)
                    {
                        dyn.MeshName = dyn.MeshName.Replace(" ", "_");
                    }
                }

                //remove spaces from meshname
                //meshname.stringValue = meshname.stringValue.Replace(" ", "_");

                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
            }

            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();
        }