AutoPopulated AssetList with CustomFilterMethod - Force refresh?

Issue #559 new
Kristijan Trajkovski created an issue

We’re trying to make a small tool that would allow us to pick an asset kit and easily swap out the mesh of an object. Our artist should pick the location where the kit he wants to use is located, and the AssetList should only show objects located there. My initial thought was - We’re going to use an attribute expression to read from the KitLocation, but that doesn’t seem to work on AssetLists. My next solution was to do a CustomFilterMethod to filter based on the location of the assets. However, we’re having the following issue.
If the KitLocation is changed, the KitAsset doesn’t change. How can we force a new AutoPopulation?

using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEditor;

public class KitList : MonoBehaviour
  public string KitLocation;
  [AssetList(CustomFilterMethod = "ObjectInKitLocation", Path = "/Prefabs/Kits/", AutoPopulate = true)]
  public GameObject KitAsset;

  // Check if given GameObject is in KitLocation
  bool ObjectInKitLocation(GameObject go)
    return AssetDatabase.GetAssetPath(go).StartsWith(KitLocation, System.StringComparison.Ordinal);


Comments (1)

  1. Log in to comment