private string FileField(SerializedProperty property, Rect position, string label, string guid, Type type) { string path = AssetDatabase.GUIDToAssetPath(guid); UnityEngine.Object file = AssetDatabase.LoadAssetAtPath(path, type); EditorGUI.BeginChangeCheck(); { file = EditorGUI.ObjectField(new Rect(position.x, position.y, position.width - 80, position.height), label, file, type, false); if (EditorGUI.DropdownButton(new Rect(position.xMax - 80, position.y, 60, position.height), new GUIContent("Select"), FocusType.Passive)) { SelectAssetReferenceWindow.Show(new AssetReferenceDropdownState(type, property), position); } if (GUI.Button(new Rect(position.xMax - 20, position.y, 20, position.height), new GUIContent("X"))) { file = null; path = string.Empty; guid = string.Empty; } } if (EditorGUI.EndChangeCheck()) { path = AssetDatabase.GetAssetPath(file); guid = AssetDatabase.AssetPathToGUID(path); } return(guid); }
public static SelectAssetReferenceWindow Show(AssetReferenceDropdownState state, Rect rect) { _assetReferenceDropdownState = state; SelectAssetReferenceWindow window = new SelectAssetReferenceWindow(state); window.minimumSize = new Vector2(rect.width, 200); window.Show(rect); return(window); }