Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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]);
        }
Exemplo n.º 3
0
        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]);
        }