private void PerformParenting(AudioManagerCategory parent, List <AudioManagerCategory> categories, DragAndDropArgs args) { bool isChangingParent = categories.Any(c => c.Parent != parent); bool showWarning = isChangingParent && !Event.current.control; if (!showWarning || EditorUtility.DisplayDialog("Reparent categories?", "Are you sure you want to move " + categories.Count + " items to parent " + parent.ID + "?", "Reparent", "Cancel")) { foreach (var cat in categories) { SetParent(parent, cat); } if (args.dragAndDropPosition == DragAndDropPosition.BetweenItems) { int insertIndex = args.insertAtIndex; for (int i = categories.Count - 1; i >= 0; i--) { var cat = categories[i]; insertIndex = GetAdjustedInsertIndex(parent, cat, insertIndex); SetSiblingIndex(cat, insertIndex); } } m_Data.SaveTree(); m_Data.ReconstructTreeChildren(); m_Root = m_Data.TreeData; } }
public static AudioManagerData LoadInstanceData() { AudioPreferences p = AudioPreferences.Instance; #if UNITY_2018_3_OR_NEWER var go = PrefabUtility.LoadPrefabContents(p.AudioManagerDataPrefabPath); AudioManagerData data = go.GetComponent <AudioManagerData>(); #else AudioManagerData data = AssetDatabase.LoadAssetAtPath <AudioManagerData>(p.AudioManagerDataPath); #endif if (data == null) { return(null); } data.ReconstructTreeChildren(); return(data); }