Closed TheBricktop closed 5 years ago
The documentation will be in the near future.
OSCReflection is a common wrapper around Reflection to simplify development and to simply obtain values from object properties.
Used in OSCSerializer, OSCTransmitterInformer components, OSCReceiverReflection components and in internal editor classes.
In a few hours I'll write an example of using OSCReflection.
OSC Reflection is simple System.Reflection wrapper.
// Get all fields in object.
var fieldMembers = OSCReflection.GetMembers(@object, OSCReflectionType.Field);
// Get all properties in object.
var propertyMembers = OSCReflection.GetMembers(@object, OSCReflectionType.Property);
// Get all methods in object.
var methodMembers = OSCReflection.GetMembers(@object, OSCReflectionType.Method);
// Get all members in object.
var allMembers = OSCReflection.GetMembers(@object, OSCReflectionType.All);
// Get all readable methods in object.
var readableMembers = OSCReflection.GetMembersByAccess(@object, OSCReflectionAccess.Read, OSCReflectionType.All);
// Get all writable methods in object.
var writableMembers = OSCReflection.GetMembersByAccess(@object, OSCReflectionAccess.Write, OSCReflectionType.All);
// Get all readable and writable members with Vector3 return type.
var vectorMembers = OSCReflection.GetMembersByType(@object, typeof(Vector3), OSCReflectionAccess.ReadWrite, OSCReflectionType.All);
OSCReflectionProperty is a wrapper what allow to read and write valuer in any member type (Field, Property, Methods).
var reflectionProperty = OSCReflectionProperty.Create(@object, vectorMembers[0]);
// Values
reflectionProperty.SetValue(new Vector3(1, 2, 3)); // Set vector value.
var vector = reflectionProperty.GetValue(); // Get vector value.
reflectionProperty.Value = new Vector3(1, 2, 3); // Or you can use value property.
var value = reflectionProperty.Value;
// Other
var propertyType = reflectionProperty.PropertyType; // Get property type.
var propertyName = reflectionProperty.PropertyName; // Get property name.
OSCReflectionMember created to store reflection member data in editor. Or you can use it for simple finding reflection members in target.
var reflectionMember = new OSCReflectionMember();
reflectionMember.Target = @object; // Target object.
reflectionMember.MemberName = "get_position"; // Object member name.
// Get OSCReflectionProperty from OSCReflectionMemger.
var reflectionProperty = reflectionMember.GetProperty();
seriously is there any documentation on that?