Accessor Providers
public class MyProvider : IAccessorProvider
{
public string Id => "Texture Data Provider";
public IAccessor GetAccessor(Type sourceType, string pathId)
{
return pathId switch
{
"Width" => new ObjectAccessor<Texture2D, int>(t => ((Texture2D)t).width, null),
"Height" => new ObjectAccessor<Texture2D, int>(t => ((Texture2D)t).height, null),
_ => throw new ArgumentException(nameof(pathId)),
};
}
public IEnumerable<AccessorPath> GetAvailablePaths(object source)
{
if(source is not Texture2D)
{
return Enumerable.Empty<AccessorPath>();
}
return new AccessorPath[]
{
new AccessorPath(this, "Width", BindMode.Read, typeof(int)),
new AccessorPath(this, "Height", BindMode.Read, typeof(int)),
};
}
public bool TryConvertIdToPath(string id, string separator, out string path)
{
path = id;
return true;
}
}


Last updated