Beispiel #1
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);
        }
Beispiel #2
0
        void SaveKeys()
        {
            EditorPrefs.SetString("developerkey", developerkey);
            EditorCore.GetPreferences().APIKey = apikey;

            EditorUtility.SetDirty(EditorCore.GetPreferences());
            AssetDatabase.SaveAssets();
        }
Beispiel #3
0
 void LoadKeys()
 {
     developerkey = EditorPrefs.GetString("developerkey");
     apikey       = EditorCore.GetPreferences().APIKey;
     if (apikey == null)
     {
         apikey = "";
     }
 }
 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);
         }
     }
 }
Beispiel #5
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;
                    }
                }
            }
        }
Beispiel #6
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();
        }
Beispiel #7
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");
                }
            }
        }
Beispiel #8
0
 static void Cognitive3DOptions()
 {
     //select asset
     Selection.activeObject = EditorCore.GetPreferences();
 }
        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();
        }
Beispiel #10
0
        void UploadSceneUpdate()
        {
            GUI.Label(steptitlerect, "STEP 6 - SCENE UPLOAD", "steptitle");


            GUI.Label(new Rect(30, 45, 440, 440), "All geometry without a <color=#8A9EB7FF>Dynamic Object</color> component will be exported and uploaded to <color=#8A9EB7FF>SceneExplorer</color>.", "boldlabel");

            string selectBlender = "Select Blender.exe";

#if UNITY_EDITOR_OSX
            selectBlender = "Select Blender.app";
#endif
            GUI.Label(new Rect(30, 120, 100, 30), selectBlender, "miniheader");

            GUI.Label(new Rect(130, 120, 30, 30), new GUIContent(EditorGUIUtility.FindTexture("d_console.infoicon.sml"), "Blender is used to reduce complex scene geometry. It is free and open source.\nDownload from Blender.org"), "image_centered");

            if (GUI.Button(new Rect(30, 160, 100, 30), "Browse...", "button_disabled"))
            {
                EditorCore.BlenderPath = EditorUtility.OpenFilePanel("Select Blender", string.IsNullOrEmpty(EditorCore.BlenderPath) ? "c:\\" : EditorCore.BlenderPath, "");
            }

            GUI.Label(new Rect(140, 165, 300, 60), EditorCore.BlenderPath, "label_disabledtext");



            GUI.Label(new Rect(30, 220, 200, 30), "Scene Export Quality", "miniheader");

            if (GUI.Button(new Rect(30, 250, 140, 100), "Low\n\n", qualityindex == 0 ? "button_blueoutline" : "button_disabledtext"))
            {
                qualityindex          = 0;
                selectedExportQuality = ExportSettings.LowSettings;
            }
            if (qualityindex == 0)
            {
                GUI.Label(new Rect(88, 265, 24, 100), EditorCore.Checkmark, "image_centered");
            }
            else
            {
                GUI.Label(new Rect(88, 265, 24, 100), EditorCore.EmptyCheckmark, "image_centered");
            }

            if (GUI.Button(new Rect(180, 250, 140, 100), "Medium\n\n", qualityindex == 1 ? "button_blueoutline" : "button_disabledtext"))
            {
                qualityindex          = 1;
                selectedExportQuality = ExportSettings.DefaultSettings;
            }
            if (qualityindex == 1)
            {
                GUI.Label(new Rect(238, 265, 24, 100), EditorCore.Checkmark, "image_centered");
            }
            else
            {
                GUI.Label(new Rect(238, 265, 24, 100), EditorCore.EmptyCheckmark, "image_centered");
            }

            if (GUI.Button(new Rect(330, 250, 140, 100), "Maximum\n\n", qualityindex == 2 ? "button_blueoutline" : "button_disabledtext"))
            {
                qualityindex          = 2;
                selectedExportQuality = ExportSettings.HighSettings;
            }
            if (qualityindex == 2)
            {
                GUI.Label(new Rect(388, 265, 24, 100), EditorCore.Checkmark, "image_centered");
            }
            else
            {
                GUI.Label(new Rect(388, 265, 24, 100), EditorCore.EmptyCheckmark, "image_centered");
            }


            if (GUI.Button(new Rect(270, 410, 220, 40), "Augmented Reality? Skip Scene Export", "miniheader"))
            {
                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.ExportSceneAR();
                CognitiveVR_Preferences.AddSceneSettings(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
                EditorUtility.SetDirty(EditorCore.GetPreferences());

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

            /*if (EditorCore.HasSceneExportFiles(CognitiveVR_Preferences.FindCurrentScene()))
             * {
             *  GUI.Label(new Rect(300, 400, 24, 40), EditorCore.Checkmark, "image_centered");
             * }
             * else
             * {
             *  GUI.Label(new Rect(300, 400, 24, 40), EditorCore.EmptyCheckmark, "image_centered");
             * }*/
        }