Skip to main content

CustomMethodApplyAttribute

A class in Alta.Attributes, the global namespace.

Prefab apply attribute that calls a named method on the component when the prefab is applied. The method should return bool (true means it applied); methods are looked up by reflection and cached.

Constructors​

MemberWhat it is
CustomMethodApplyAttribute(string method)Creates a CustomMethodApplyAttribute from method.

Fields​

4 private and internal fields
MemberWhat it is
private static object[] emptyEmpty argument array for the reflection call.
private const BindingFlags flagsBinding flags used to find the method.
private static Dictionary<int, MethodInfo> methodsCache of found methods that return bool.
private static Dictionary<int, MethodInfo> nonReturnMethodsCache of found methods that don't return bool.

Properties​

MemberWhat it is
string Method { get; }Name of the method to call, public or private, instance or static.

Methods​

MemberWhat it is
override bool HandleApply(Component component, FieldInfo field, GameObject prefab)Finds and calls Method on the component and returns its bool; a non-bool method is called, logs an error and counts as true.
1 private and internal method
MemberWhat it is
private static int GetHashCode(Type type, string method)Builds the cache key from the component type and method name.