/// <summary>
        /// Gets or creates the package settings, stored as an asset in the project folder.
        /// </summary>
        /// <returns></returns> The package settings.
        private static COLIBRIVRSettings GetOrCreateSettings()
        {
            if (!Directory.Exists(settingsFolderAbsolutePath))
            {
                GeneralToolkit.CreateOrClear(PathType.Directory, settingsFolderAbsolutePath);
            }
            if (!Directory.Exists(settingsResourcesAbsolutePath))
            {
                GeneralToolkit.CreateOrClear(PathType.Directory, settingsResourcesAbsolutePath);
            }
            string            settingsAssetPath = Path.Combine(GeneralToolkit.ToRelativePath(COLIBRIVRSettings.settingsFolderAbsolutePath), "COLIBRIVRSettings.asset");
            COLIBRIVRSettings settings          = AssetDatabase.LoadAssetAtPath <COLIBRIVRSettings>(settingsAssetPath);

            if (settings == null)
            {
                settings = ScriptableObject.CreateInstance <COLIBRIVRSettings>();
                settings.COLMAPSettings        = (COLMAPSettings)ScriptableObject.CreateInstance <COLMAPSettings>().Initialize();
                settings.BlenderSettings       = (BlenderSettings)ScriptableObject.CreateInstance <BlenderSettings>().Initialize();
                settings.InstantMeshesSettings = (InstantMeshesSettings)ScriptableObject.CreateInstance <InstantMeshesSettings>().Initialize();
                settings.previewMaxResolution  = 256;
                AssetDatabase.CreateAsset(settings, settingsAssetPath);
                AssetDatabase.AddObjectToAsset(settings.COLMAPSettings, settingsAssetPath);
                AssetDatabase.AddObjectToAsset(settings.BlenderSettings, settingsAssetPath);
                AssetDatabase.AddObjectToAsset(settings.InstantMeshesSettings, settingsAssetPath);
                AssetDatabase.SaveAssets();
            }
            return(settings);
        }
        /// <summary>
        /// Enables the user to specify settings for the COLIBRI VR package.
        /// </summary>
        /// <param name="packageSettings"></param> The package settings object.
        public static void SectionPackageSettings(COLIBRIVRSettings packageSettings)
        {
            SerializedObject serializedSettings = new SerializedObject(packageSettings);

            serializedSettings.Update();

            GeneralToolkit.EditorNewSection("Package settings");
            string             label   = "Max. resolution for preview";
            string             tooltip = "Maximum resolution for the preview images.";
            SerializedProperty propertyPreviewMaxResolution = serializedSettings.FindProperty(_propertyNamePreviewMaxResolution);

            propertyPreviewMaxResolution.intValue = EditorGUILayout.IntSlider(new GUIContent(label, tooltip), propertyPreviewMaxResolution.intValue, 1, 8192);

            GeneralToolkit.EditorNewSection("External helper tools");
            packageSettings.COLMAPSettings.EditorSettingsFoldout();
            packageSettings.BlenderSettings.EditorSettingsFoldout();
            packageSettings.InstantMeshesSettings.EditorSettingsFoldout();

            serializedSettings.ApplyModifiedProperties();
        }
Example #3
0
        /// <summary>
        /// Displays a GUI enabling the user to see the current package settings.
        /// Intentionally, this interface cannot be used to modify these settings.
        /// </summary>
        public override void OnInspectorGUI()
        {
            // Start the GUI.
            GeneralToolkit.EditorStart(serializedObject, _targetObject);

            // Indicate how to modify these settings.
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("The settings below can be modified from the Project Settings window.", GeneralToolkit.wordWrapStyle);
            EditorGUILayout.Space();

            // Disable the GUI.
            bool isGUIEnabled = GUI.enabled;

            GUI.enabled = false;

            // Enable the user to see the package's settings.
            COLIBRIVRSettings.SectionPackageSettings(_targetObject);

            // End the GUI.
            GUI.enabled = isGUIEnabled;
            GeneralToolkit.EditorEnd(serializedObject);
        }
Example #4
0
        public static SettingsProvider CreateSettingsProvider()
        {
            // First parameter is the path in the Settings window.
            // Second parameter is the scope of this setting: it only appears in the Project Settings window.
            SettingsProvider provider = new SettingsProvider("Project/COLIBRIVRSettings", SettingsScope.Project)
            {
                // By default the last token of the path is used as display name if no label is provided.
                label = "COLIBRI VR",

                // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
                guiHandler = (searchContext) =>
                {
                    COLIBRIVRSettings packageSettings = COLIBRIVRSettings.packageSettings;
                    COLIBRIVRSettings.SectionPackageSettings(packageSettings);
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                keywords = new HashSet <string>(new[] { "COLIBRI VR", "COLMAP", "Blender", "Instant Meshes" })
            };

            return(provider);
        }
Example #5
0
 /// <summary>
 /// On selection, sets up the target properties.
 /// </summary>
 void OnEnable()
 {
     // Get the target object.
     _targetObject = (COLIBRIVRSettings)serializedObject.targetObject;
 }