ArticyCustomFilterAttribute Class

This attribute can be used to limit the available options on ArticyRefs object picker.

Definition

Namespace: Articy.Unity
Assembly: ArticyRuntime (in ArticyRuntime.dll) Version: 1.3.0
C#
public sealed class ArticyCustomFilterAttribute : Attribute
Inheritance
Object    Attribute    ArticyCustomFilterAttribute

Remarks

Use this to restrict what objects can be picked in the unity editor for a specific ArticyRef.

  Note

This does not restrict assignments in code and only restricts the choices inside the unity editor.

Example

C#
// 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;
}
C#
// 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;
}
C#
// 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];
    }
}

Constructors

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.

See Also