├── .DS_Store ├── .gitignore ├── Editor.meta ├── Editor ├── Dropdown.meta ├── Dropdown │ ├── DropdownCopyPasteContextMenu.cs │ ├── DropdownCopyPasteContextMenu.cs.meta │ ├── GenericTypeCreateWindow.cs │ ├── GenericTypeCreateWindow.cs.meta │ ├── SerializeReferenceAdvancedDropdown.cs │ ├── SerializeReferenceAdvancedDropdown.cs.meta │ ├── SerializeReferencePropertyDrawer.cs │ ├── SerializeReferencePropertyDrawer.cs.meta │ ├── SerializeReferencePropertyDrawer_IMGUI.cs │ ├── SerializeReferencePropertyDrawer_IMGUI.cs.meta │ ├── SerializeReferencePropertyDrawer_UIToolkit.cs │ └── SerializeReferencePropertyDrawer_UIToolkit.cs.meta ├── EditReferenceType.meta ├── EditReferenceType │ ├── EditReferenceTypeUtils.cs │ ├── EditReferenceTypeUtils.cs.meta │ ├── EditReferenceTypeWindow.cs │ └── EditReferenceTypeWindow.cs.meta ├── Layouts.meta ├── Layouts │ ├── EditReferenceType.uxml │ ├── EditReferenceType.uxml.meta │ ├── RefTo.uxml │ ├── RefTo.uxml.meta │ ├── SearchTool.uxml │ ├── SearchTool.uxml.meta │ ├── SearchToolStyle.uss │ ├── SearchToolStyle.uss.meta │ ├── SerializeReferenceDropdown.uxml │ ├── SerializeReferenceDropdown.uxml.meta │ ├── SerializeReferenceToolStyle.uss │ └── SerializeReferenceToolStyle.uss.meta ├── Preferences.meta ├── Preferences │ ├── SerializeReferenceToolsSettingsProvider.cs │ ├── SerializeReferenceToolsSettingsProvider.cs.meta │ ├── SerializeReferenceToolsUserPreferences.cs │ └── SerializeReferenceToolsUserPreferences.cs.meta ├── RefTo.meta ├── RefTo │ ├── RefToContextMenu.cs │ ├── RefToContextMenu.cs.meta │ ├── RefToExtensions.cs │ ├── RefToExtensions.cs.meta │ ├── RefToPropertyDrawer.cs │ └── RefToPropertyDrawer.cs.meta ├── SearchTool.meta ├── SearchTool │ ├── SearchToolData.cs │ ├── SearchToolData.cs.meta │ ├── SearchToolWindow.cs │ ├── SearchToolWindow.cs.meta │ ├── SearchToolWindowIntegration.cs │ ├── SearchToolWindowIntegration.cs.meta │ ├── SearchToolWindowSearchProvider.cs │ ├── SearchToolWindowSearchProvider.cs.meta │ ├── SearchToolWindowTempSO.cs │ └── SearchToolWindowTempSO.cs.meta ├── SerializeReferenceDropdownEditor.asmdef ├── SerializeReferenceDropdownEditor.asmdef.meta ├── Utils.meta └── Utils │ ├── CodeAnalysis.cs │ ├── CodeAnalysis.cs.meta │ ├── FileIterator.cs │ ├── FileIterator.cs.meta │ ├── LinqExtensions.cs │ ├── LinqExtensions.cs.meta │ ├── Log.cs │ ├── Log.cs.meta │ ├── MissingTypeUtils.cs │ ├── MissingTypeUtils.cs.meta │ ├── Paths.cs │ ├── Paths.cs.meta │ ├── ReflectionUtils.cs │ ├── ReflectionUtils.cs.meta │ ├── SOUtils.cs │ ├── SOUtils.cs.meta │ ├── TypeUtils.cs │ ├── TypeUtils.cs.meta │ ├── UIToolkitExtensions.cs │ └── UIToolkitExtensions.cs.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── RefTo.cs ├── RefTo.cs.meta ├── SerializeReferenceDropdownAttribute.cs ├── SerializeReferenceDropdownAttribute.cs.meta ├── SerializeReferenceDropdownNameAttribute.cs ├── SerializeReferenceDropdownNameAttribute.cs.meta ├── SerializeReferenceDropdownRuntime.asmdef ├── SerializeReferenceDropdownRuntime.asmdef.meta ├── TypeTooltipAttribute.cs └── TypeTooltipAttribute.cs.meta ├── Samples~ ├── Circle.cs ├── Circle.cs.meta ├── ColliderShape.cs ├── ColliderShape.cs.meta ├── Generics.meta ├── Generics │ ├── GenericData.cs │ └── GenericData.cs.meta ├── IShape.cs ├── IShape.cs.meta ├── MonoColliderShape.cs ├── MonoColliderShape.cs.meta ├── Rectangle.cs ├── Rectangle.cs.meta ├── SerializeReferenceDropdownSample.asmdef ├── SerializeReferenceDropdownSample.asmdef.meta ├── SerializeReferenceDropdownTest.unity ├── SerializeReferenceDropdownTest.unity.meta ├── TestShapesForSRD.cs └── TestShapesForSRD.cs.meta ├── package.json └── package.json.meta /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexeyTaranov/SerializeReferenceDropdown/8ea41ddb6a33913226c88e930d229b47896faa90/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48980d0c2e097dd478664647dc85c897 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Dropdown.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33364137ef904612821f70de49361b76 3 | timeCreated: 1743183487 -------------------------------------------------------------------------------- /Editor/Dropdown/DropdownCopyPasteContextMenu.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SerializeReferenceDropdown.Editor.Utils; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace SerializeReferenceDropdown.Editor.Dropdown 7 | { 8 | [InitializeOnLoad] 9 | public class DropdownCopyPasteContextMenu 10 | { 11 | private static (string json, Type type) lastObject; 12 | 13 | static DropdownCopyPasteContextMenu() 14 | { 15 | EditorApplication.contextualPropertyMenu += ShowSerializeReferenceCopyPasteContextMenu; 16 | } 17 | 18 | private static void ShowSerializeReferenceCopyPasteContextMenu(GenericMenu menu, SerializedProperty property) 19 | { 20 | if (property.propertyType == SerializedPropertyType.ManagedReference) 21 | { 22 | var copyProperty = property.Copy(); 23 | menu.AddItem(new GUIContent("Copy Serialize Reference"), false, 24 | (_) => { CopyReferenceValue(copyProperty); }, null); 25 | var pasteAsValueContent = new GUIContent("Paste Serialize Reference as Value"); 26 | menu.AddItem(pasteAsValueContent, false, (_) => PasteAsValue(copyProperty), 27 | null); 28 | } 29 | } 30 | 31 | private static void CopyReferenceValue(SerializedProperty property) 32 | { 33 | var refValue = GetReferenceToValueFromSerializerPropertyReference(property); 34 | lastObject.json = JsonUtility.ToJson(refValue); 35 | lastObject.type = refValue?.GetType(); 36 | } 37 | 38 | private static void PasteAsValue(SerializedProperty property) 39 | { 40 | try 41 | { 42 | SOUtils.RegisterUndo(property, "Paste reference value"); 43 | if (lastObject.type != null) 44 | { 45 | var pasteObj = JsonUtility.FromJson(lastObject.json, lastObject.type); 46 | property.managedReferenceValue = pasteObj; 47 | } 48 | else 49 | { 50 | property.managedReferenceValue = null; 51 | } 52 | 53 | property.serializedObject.ApplyModifiedProperties(); 54 | property.serializedObject.Update(); 55 | } 56 | catch (Exception e) 57 | { 58 | Log.DevError($"Failed paste value: {e}"); 59 | } 60 | } 61 | 62 | private static object GetReferenceToValueFromSerializerPropertyReference(SerializedProperty property) 63 | { 64 | #if UNITY_2021_2_OR_NEWER 65 | return property.managedReferenceValue; 66 | #else 67 | return property.GetTarget(); 68 | #endif 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /Editor/Dropdown/DropdownCopyPasteContextMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08e2b2b0b3ee4a2c9c6a0e85a13618ef 3 | timeCreated: 1657954546 -------------------------------------------------------------------------------- /Editor/Dropdown/GenericTypeCreateWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using SerializeReferenceDropdown.Editor.Utils; 6 | using UnityEditor; 7 | using UnityEditor.IMGUI.Controls; 8 | using UnityEngine; 9 | using UnityEngine.UIElements; 10 | 11 | namespace SerializeReferenceDropdown.Editor.Dropdown 12 | { 13 | public class GenericTypeCreateWindow : EditorWindow 14 | { 15 | private const int InvalidIndex = -1; 16 | 17 | private SerializedProperty serializedProperty; 18 | private Type inputGenericType; 19 | private Action onSelectNewGenericType; 20 | 21 | private IReadOnlyList specifiedTypesFromProperty; 22 | 23 | private List> typesForParameters; 24 | private List> typeNamesForParameters; 25 | private int[] selectedIndexes; 26 | 27 | private IReadOnlyList