public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { AssetSelectionAttribute att = attribute as AssetSelectionAttribute; Type type = att.type; if (att.useName) { if (property.propertyType != SerializedPropertyType.String) { Debug.LogWarning("Field :: " + property.displayName + " is not an string type, cannot draw names with asset selector"); EditorGUI.PropertyField(position, property, label); return; } AssetSelector.DrawName(type, position, property, label, att.OnAssetsLoaded, att.OnAssetsFound); } else { if (property.propertyType != SerializedPropertyType.ObjectReference) { Debug.LogWarning("Field :: " + property.displayName + " is not an object reference type, cannot draw with asset selector"); EditorGUI.PropertyField(position, property, label); return; } AssetSelector.Draw(type, position, property, label, att.OnAssetsLoaded, att.OnAssetsFound); } }
static AssetSelector GetAssetSelector(Type type, Func <List <AssetSelectorElement>, List <AssetSelectorElement> > onAssetsLoaded) { AssetSelector selector; if (allAssetSelectors.TryGetValue(type, out selector)) { if (selector != null) { return(selector); } } allAssetSelectors[type] = new AssetSelector(type, onAssetsLoaded); return(allAssetSelectors[type]); }
static AssetSelector GetSelector(Type type) { AssetSelector selector; if (allAssetSelectors.TryGetValue(type, out selector)) { if (selector != null) { return(selector); } } allAssetSelectors[type] = new AssetSelector(type); return(allAssetSelectors[type]); }