/// <summary> /// Shows the file saving window then saves the frustum quality settings as an asset /// </summary> public void SaveBaseSettings() { string fullPathName = EditorUtility.SaveFilePanelInProject("Save Base Settings", BaseSettings.name, "asset", "Please select a location and a filename."); if (fullPathName.Length > 0) { AuraBaseSettings baseSettingsInstance = AuraBaseSettings.Instantiate <AuraBaseSettings>(BaseSettings); AssetDatabase.CreateAsset(baseSettingsInstance, fullPathName); BaseSettings = baseSettingsInstance; } }
/// <summary> /// Shows the file selection window then replaces the current frustum base settings with the selected one /// </summary> public void LoadBaseSettings() { string dataFolderPath = Application.dataPath + "/"; string path = EditorUtility.OpenFilePanelWithFilters("Load Base Settings", Application.dataPath, new string[] { "Aura Base Settings", "asset" }); if (path.StartsWith(dataFolderPath, StringComparison.CurrentCultureIgnoreCase)) { path = "Assets/" + path.Substring(dataFolderPath.Length); AuraBaseSettings loadedSettings = AssetDatabase.LoadAssetAtPath <AuraBaseSettings>(path); LoadBaseSettings(loadedSettings); } }
/// <summary> /// Retrievse all the base settings /// </summary> private void PopulateExistingBaseSettingsPresetsList() { _foundBaseSettingsPresets = AssetDatabase.FindAssets("t:AuraBaseSettings"); _selectedBaseSettingsPresetId = -1; if (_foundBaseSettingsPresets.Length > 0) { _foundBaseSettingsPresetsName = new string[_foundBaseSettingsPresets.Length]; for (int i = 0; i < _foundBaseSettingsPresets.Length; ++i) { _foundBaseSettingsPresets[i] = AssetDatabase.GUIDToAssetPath(_foundBaseSettingsPresets[i]); AuraBaseSettings preset = AssetDatabase.LoadAssetAtPath <AuraBaseSettings>(_foundBaseSettingsPresets[i]); if (_currentAuraComponent.frustumSettings.baseSettings == preset) { _foundBaseSettingsPresetsName[i] = "Current"; _selectedBaseSettingsPresetId = i; continue; } _foundBaseSettingsPresetsName[i] = preset.name; string presetPath = Directory.GetParent(AssetDatabase.GetAssetPath(preset)).FullName; presetPath = ("Assets" + presetPath.Substring(Application.dataPath.Length) + "\\").Replace('/', '\\'); _foundBaseSettingsPresetsName[i] += " (in " + presetPath + ")"; } } }
/// <summary> /// Replaces the current frustum base settings /// </summary> /// <param name="baseSettings">the replacing frustum base settings</param> public void LoadBaseSettings(AuraBaseSettings baseSettings) { this.BaseSettings = baseSettings; }
/// <summary> /// Draws the base settings area /// </summary> private void DisplayBaseSettingsArea() { AuraBaseSettings currentBaseSettings = (AuraBaseSettings)_baseSettingsProperty.objectReferenceValue; if (!ReferenceEquals(_previousBaseSettings, currentBaseSettings)) { PopulateExistingBaseSettingsPresetsList(); } _previousBaseSettings = currentBaseSettings; EditorGUILayout.BeginVertical(GuiStyles.ButtonNoHover); EditorGUILayout.BeginVertical(GuiStyles.Background); EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("Aura <b>Base Settings</b>", Aura.ResourcesCollection.baseSettingsPresetIconTexture), new GUIStyle(GuiStyles.LabelCenteredBig) { fontSize = 15 }); EditorGUILayout.Separator(); GuiHelpers.DrawContextualHelpBox("The \"Base Settings Preset\" is the asset that holds the base settings for the data computation."); //if(_foundBaseSettingsPresets.Length != AssetDatabase.FindAssets("t:AuraBaseSettings").Length) //{ // PopulateExistingBaseSettingsPresetsList(); //} if (_foundBaseSettingsPresets.Length > 0) { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Select Existing", GuiStyles.Label, GUILayout.MaxWidth(96)); _selectedBaseSettingsPresetId = EditorGUILayout.Popup(_selectedBaseSettingsPresetId, _foundBaseSettingsPresetsName); EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { _currentAuraComponent.frustumSettings.LoadBaseSettings(AssetDatabase.LoadAssetAtPath <AuraBaseSettings>(_foundBaseSettingsPresets[_selectedBaseSettingsPresetId])); PopulateExistingBaseSettingsPresetsList(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Preset File", GuiStyles.Label, GUILayout.MaxWidth(80)); EditorGUILayout.PropertyField(_baseSettingsProperty, new GUIContent("")); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); //if (GUILayout.Button(new GUIContent("Load Existing", Aura.AuraResourcesCollection.loadIconTexture, "Loads an existing preset file"), GuiStyles.ButtonBigNoBorder)) //{ // _currentAuraComponent.frustumSettings.LoadBaseSettings(); //} //GUILayout.Space(8); if (GUILayout.Button(new GUIContent("Save As New Preset", Aura.ResourcesCollection.saveIconTexture, "Saves the current settings in a new file"), GuiStyles.ButtonBigNoBorder)) { _currentAuraComponent.frustumSettings.SaveBaseSettings(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); SerializedObject baseSettingsObject = new SerializedObject(_currentAuraComponent.frustumSettings.BaseSettings); AuraBaseSettingsEditor.DrawCustomEditor(baseSettingsObject, _currentAuraComponent); EditorGUILayout.EndVertical(); }