private void DrawHeader() { _tabIndex = GUILayout.Toolbar(_tabIndex, _headerContents.ToArray()); if (_tabIndex == 0 && _changesMade) { bool save = EditorUtility.DisplayDialog("Bookmark Everything", "You have unsaved changes. Would you like to save them?", "Yes", "No"); if (save) { SaveChanges(); } else { _lastlyAddedCount = -1; _tempLocations.Clear(); _tempLocations.AddRange(EntryData.Clone(_currentSettings.EntryData.ToArray())); _changesMade = false; } } switch (_tabIndex) { case 0: DrawProjectFinder(); break; case 1: DrawSettings(); break; default: break; } }
private void SaveChanges() { _currentSettings.EntryData.Clear(); _currentSettings.EntryData.AddRange(EntryData.Clone(_tempLocations.ToArray())); _lastlyAddedCount = -1; _currentSettings.Save(); _changesMade = false; }
private void LoadSettings() { //attempt to load the entries _currentSettings = IOHelper.ReadFromDisk <SaveData>(SETTINGS_FILENAME); //if nothing is saved, retrieve the default values if (_currentSettings == null) { _currentSettings = new SaveData(); _currentSettings.PingType = PingTypes.Both; _currentSettings.Save(); } _tempLocations.AddRange(EntryData.Clone(_currentSettings.EntryData.ToArray())); _pingType = _currentSettings.PingType; _visualMode = _currentSettings.VisualMode; VisualMode(_visualMode); _autoClose = _currentSettings.AutoClose; _showFullPath = _currentSettings.ShowFullPath; _showFullPathForFolder = _currentSettings.ShowFullPathForFolders; }
private void DrawSettings() { DrawInnerSettings(); int toBeRemoved = -1; UnityEngine.Object pingedObject = null; _settingScrollPos = EditorGUILayout.BeginScrollView(_settingScrollPos, _scrollViewStyle, GUILayout.MaxHeight(position.height)); //Iterate all found entries - key is path value is type EditorGUILayout.BeginVertical(_boxStyle); EditorGUILayout.LabelField("Manage Registered Assets", _boldLabelStyle); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); for (int i = 0; i < _tempLocations.Count; i++) { bool exists = IOHelper.Exists(_tempLocations[i].GUID, ExistentialCheckStrategy.GUID); if (_lastlyAddedCount != -1 && i >= _tempLocations.Count - _lastlyAddedCount - 1) { GUI.color = Color.green; } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { string fullPath = exists ? AssetDatabase.GUIDToAssetPath(_tempLocations[i].GUID) : "(Removed)" + AssetDatabase.GUIDToAssetPath(_tempLocations[i].GUID); GUILayout.Space(4); EditorGUILayout.SelectableLabel(fullPath, _textFieldStyle, GUILayout.Height(EditorGUIUtility.singleLineHeight)); } EditorGUILayout.EndVertical(); if (!exists) { GUI.enabled = false; } if (DrawButton("", "ViewToolOrbit", ButtonTypes.SmallNormalHeight)) { pingedObject = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(_tempLocations[i].GUID)); if (Selection.activeObject) { Selection.activeObject = null; } if (_pingType == PingTypes.Ping) { EditorGUIUtility.PingObject(pingedObject); } else if (_pingType == PingTypes.Selection) { Selection.activeObject = pingedObject; } else if (_pingType == PingTypes.Both) { EditorGUIUtility.PingObject(pingedObject); Selection.activeObject = pingedObject; } } // if (DrawButton("Assign Selected Object", "TimeLinePingPong", ButtonTypes.Standard)) // { // string s = AssetDatabase.GetAssetPath(Selection.activeObject); // if (s == "" || s == null || Selection.activeObject == null) // { // EditorUtility.DisplayDialog("Empty Selection", "Please select an item from Project Hierarchy.", "Okay"); // } // else // { // _tempLocations[i] = Selection.activeObject; // _changesMade = true; // } // GUI.FocusControl(null); // } //çatecori ///*int categoryIndex*/ = GetIndexOfCategory(_tempPlayerPrefLocations[i].Category); _tempLocations[i].Index = EditorGUILayout.Popup(_tempLocations[i].Index, RetrieveGUIContent(_projectFinderHeaders), _popupStyle, GUILayout.MinHeight(EditorGUIUtility.singleLineHeight), GUILayout.MaxWidth(150)); _tempLocations[i].Category = _projectFinderHeaders[_tempLocations[i].Index]; if (!exists) { GUI.enabled = true; } //Remove Button if (DrawButton("", "ol minus", ButtonTypes.SmallNormalHeight)) { if (_lastlyAddedCount != -1 && i >= _tempLocations.Count - _lastlyAddedCount - 1) { _lastlyAddedCount--; } toBeRemoved = i; } } EditorGUILayout.EndHorizontal(); if (_lastlyAddedCount != -1 && i >= _tempLocations.Count - _lastlyAddedCount - 1) { GUI.color = _defaultGUIColor; } }//endfor if (_tempLocations.Count == 0 && _currentSettings.EntryData.Count == 0) { EditorGUILayout.LabelField("Start dragging some assets from Project Folder!", _boldLabelStyle); } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); //Focus to Project window if a ping object is selected. Causes an error if it is directly made within the for loop if (pingedObject != null) { EditorUtility.FocusProjectWindow(); } //Remove item if (toBeRemoved != -1) { _tempLocations.RemoveAt(toBeRemoved); } //-- //Add // if (DrawButton("Add", "ol plus", ButtonTypes.Big)) // { // if (Selection.activeObject != null) // { // _tempLocations.Add(Selection.activeObject); // } // else // { // EditorUtility.DisplayDialog("Empty Selection", "Please select an item from Project Hierarchy.", "Okay"); // } // GUI.FocusControl(null); // } //Save //detect if any change occured, if not reverse the HelpBox if (_currentSettings.EntryData.Count != _tempLocations.Count) { _changesMade = true; } else { for (int i = 0; i < _currentSettings.EntryData.Count; i++) { if (_currentSettings.EntryData[i].GUID != _tempLocations[i].GUID || _currentSettings.EntryData[i].Category != _tempLocations[i].Category) { _changesMade = true; break; } if (i == _currentSettings.EntryData.Count - 1) { _changesMade = false; } } } //Show info about saving if (_changesMade) { if (DrawButton("Save", "redLight", ButtonTypes.Big)) { SaveChanges(); } EditorGUILayout.HelpBox("Changes are made, you should save changes if you want to keep them.", MessageType.Info); if (DrawButton("Discard Changes", "", ButtonTypes.Standard)) { _lastlyAddedCount = -1; _tempLocations.Clear(); _tempLocations.AddRange(EntryData.Clone(_currentSettings.EntryData.ToArray())); _changesMade = false; } } }