Note
This does not restrict assignments in code and only restricts the choices inside the unity editor.
public sealed class ArticyCustomFilterAttribute : AttributeUse this to restrict what objects can be picked in the unity editor for a specific ArticyRef.
// simple filter
[ArticyCustomFilter(nameof(IsCharacterOfFamilySmith))]
public ArticyRef characterRef;
bool IsCharacterOfFamilySmith(ArticyObject articyObject, object[] args)
{
if (articyObject is Entity entity)
return entity.DisplayName.Value.EndsWith("Smith"); // show only entities which last name is "Smith"
return false;
}// filter using parameters
[ArticyCustomFilter(nameof(IsLastName), "Smith")]
public ArticyRef characterRef;
bool IsLastName(ArticyObject articyObject, object[] args)
{
if (articyObject is Entity entity)
return entity.DisplayName.Value.EndsWith((string)args[0]); // use the argument to test the last name
return false;
}// use filter from static utility class
public class Player : MonoBehaviour
{
// show only weapons that are in the user folder "Swords"
[ArticyCustomFilter(typeof(MyArticyRefFilter), nameof(MyArticyRefFilter.EntityUserFolder), "Swords")]
public ArticyRef weapon;
}
public static class MyArticyRefFilter
{
public static bool EntityUserFolder(ArticyObject articyObject, object[] args)
{
if (articyObject is not Entity)
return false;
UserFolder folder = articyObject.Parent as UserFolder;
return folder != null && folder.DisplayName == (string)args[0];
}
}| ArticyCustomFilterAttribute(String, Object) | This attribute can be used to limit the available options on ArticyRefs object picker. The target method must match ArticyCustomFilterCallback. |
| ArticyCustomFilterAttribute(Type, String, Object) | This attribute can be used to limit the available options on ArticyRefs object picker. The target method must match ArticyCustomFilterCallback. |