private static void Find() { sceneReference.Clear(); var path = "build/ReferenceViewer/data.dat"; var selectedObjects = Selection.objects; Action find = () => { var data = UnityEditorInternal.InternalEditorUtility.LoadSerializedFileAndForget(path)[0] as Data; Find(data, selectedObjects); }; if (File.Exists(path)) { find(); } else { if (EditorUtility.DisplayDialog("必要なデータがありません", "データを作成します。\nデータ作成に時間がかかりますがよろしいですか?", "はい", "いいえ")) { Creator.Build(find); } } }
private static void Find() { sceneReference.Clear(); var path = "build/ReferenceViewer/data.dat"; var guids = Selection.objects.Select(obj => AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj))).ToArray(); Action find = () => { var text = File.ReadAllBytes(path); var data = ByteArrayToObject <Data>(text); Find(data, guids); }; if (File.Exists(path)) { find(); } else { if (EditorUtility.DisplayDialog("必要なデータがありません", "データを作成します。\nデータ作成に時間がかかりますがよろしいですか?", "はい", "いいえ")) { Creator.Build(find); } } }
private static void Find() { sceneReference.Clear(); var path = "build/ReferenceViewer/data.dat"; var guids = Selection.objects.Select(obj => AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj))).ToArray(); Action find = () => { var text = File.ReadAllBytes(path); var data = ByteArrayToObject <Data>(text); Find(data, guids); }; if (File.Exists(path)) { find(); } else { Creator.Build(find); } }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Update", EditorStyles.toolbarButton)) { Creator.Build(); EditorGUIUtility.ExitGUI(); } EditorGUI.BeginChangeCheck(); var types = items.Select(item => item.type).ToArray(); var display = types.Select(t => t.Name).ToArray(); for (var i = 0; i < display.Length; i++) { switch (display[i]) { case "Object": display[i] = "Scene"; break; case "GameObject": display[i] = "Prefab"; break; } } ArrayUtility.Insert(ref display, 0, "All"); var selected = EditorGUILayout.Popup(selectedFilter, display, EditorStyles.toolbarPopup); if (EditorGUI.EndChangeCheck()) { selectedFilter = selected; } EditorGUILayout.EndHorizontal(); if (items.Count == 0) { return; } pos = EditorGUILayout.BeginScrollView(pos); var groupBy = items.GroupBy(item => item.searchedGUIContent.tooltip); foreach (var group in groupBy) { var enumerator = @group.GetEnumerator(); var item = new Item(); while (enumerator.MoveNext()) { item.type = enumerator.Current.type; item.searchedGUIContent = enumerator.Current.searchedGUIContent; item.referenceGUIContents.AddRange(enumerator.Current.referenceGUIContents); item.referencedGUIContents.AddRange(enumerator.Current.referencedGUIContents); } if (selectedFilter != 0 && item.type != types[selectedFilter - 1]) { continue; } EditorGUILayout.BeginHorizontal("box", GUILayout.Width(Screen.width * 0.96f)); DrawGUIContents(item.searchedGUIContent, item.referenceGUIContents); var iconSize = EditorGUIUtility.GetIconSize(); EditorGUIUtility.SetIconSize(Vector2.one * 32); GUILayout.Label(item.searchedGUIContent, GUILayout.Width(Screen.width * 0.3f), GUILayout.ExpandWidth(false)); EditorGUIUtility.SetIconSize(iconSize); PingObjectIfOnMouseDown(item.searchedGUIContent.tooltip); DrawGUIContents(item.searchedGUIContent, item.referencedGUIContents); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUILayout.EndScrollView(); }