This attribute may be applied to FIELDS and PROPERTIES only (Called "variables", for brevity, below.)
At it's core, it does little more than store a copy of the attributed variable's value, for later comparison.
It provides the programmer with the ability to check that comparison via hasChanged() The values is re-copied and stored by calling resetChangeValue Thats the important stuff, though there are a few more detailed options, like how to store classes that the programmer cannot simply make a copy of (StoreAsType), and a name for use in inspector GUIs. Details within. WARNING: the use of this attribute has the potential to significantly impact performance; use with caution.
Public Member Functions | |
DeltaAttribute (string _conditonalOptionName) | |
default constructor, mandatory parameter takes a string that can be used to display an option to enable/disable this attribute. This value is also used by DeltaMonitor to find an attribute by name. | |
bool | hasChanged () |
This is one of the two primary functions for this class. It determines if the variable this attribute is assigned to, has changed since the last time reset was called. | |
void | resetChangeValue () |
This is one of the two primary functions for this class. Stores the current value of the variable this attribute is assigned to. Subsequent checks using hasChanged will compare against the value stored in this function. If the range option is used, it will only be overwritten if a "change" is detected, when this function is called. | |
Public Attributes | |
bool | checkEnabled |
If this is false, the comparison of values wont even be performed. | |
string | conditionalOptionName |
Attribute's option name, used to create a user interface allowing a human to uniquely identify this attribute this name must be unique for each attribute used in a class | |
MemberInfo | fieldRef |
Contains a PropertyInfo or FieldInfo reference to the field, so we don't need to lookup the field, by name more than the once, during initialization. | |
MemberInfo | innerFieldRef |
This field is only used in conjunction with checkMember, when using the CheckMember named Parameter (checkMember!=""). Contains a PropertyInfo or FieldInfo reference to the field, so we don't need to lookup the field by name more than the once, during initialization. | |
object | monitoredInstance |
Reference to the object that contains the variables we want to detect changes of. | |
Properties | |
bool | CheckArrayElementsFlag [get, set] |
this accessor is be a NAMED PARAMETER for this attribute. It is used to specify that the field checked is an array, and we should compare the contents of the array, rather than the array reference, to check for changes. | |
string | CheckMember [get, set] |
CheckMember is a NAMED PARAMETER for this attribute. It is used when the user wants to access a single member of the attributed variable, rather than the variable reference itself. Only one level of indirection is possible with this. | |
int | ComparePriority [get, set] |
this accessor is be a NAMED PARAMETER for this attribute. It is used for optimization, to specify the order in which comparison should be performed. This can be useful when some checks are slower than others, because checking is stopped once ANY change is detected. Not used internally, but by external classes like DeltaMontor. | |
bool | DontResetIfDisabled [get, set] |
DontResetIfDisabled is a NAMED PARAMETER for this attribute. Used for optimization, if this named parameter is true, disabled attributes, will NOT have the _lastCycleValue updated when resetChangeValue() is called. The side-effect of using this attribute is that; it will lead to a change detection when attribute is re-enabled, if the value has changed since last enabled. | |
object | LastCycleValue [get, set] |
stored value that will compared against the "live" value. | |
float | Range [get, set] |
Range is only applicable if the StoreAsType can add and subtract floating point numbers. When used, will NOT generate a change detection until the change is larger than this value. | |
int | SetID [get, set] |
SetID is a NAMED PARAMETER for this attribute. It is used when the user wants to group together various Delta attributes. the user will be responsible for any such grouping, but may use this value to do it. Attributes that are not specifically assigned to a Set, will have default a SetID of 0; | |
Type | StoreAsType [get, set] |
StoreAsType is a NAMED PARAMETER for this attribute. This parameter should be used when you want to compare object values, rather than object references.(Except when applying the attribute to members that are Value Types, like structs and atomic types. In these cases values will always be compared.) The user may need to define a new class or struct to use here, when the field references a type that cannot be instantiated by itself, like components, assets or Transforms. The user may choose to optimize processing by defining a new class or struct to use here, with only a small subset of members, of a large class, needing change detection. It is the users obligation to specify the copy and compare behavior in the definition of the StoreAsType's class The StoreAsType class MUST be defined with a Constructor, that takes an instance of the attributed-variable's Type as the sole parameter. The StoreAsType class MUST be defined with an Equals function, taking a single object (System.Object) parameter; it must properly equate objects of the attributed-variable's Type. warning: copying and comparing large and detailed data structures can impact performance when performed often | |
Inherits Attribute.