//return component is changes have been made public Component RestoreSettings() { Component resultChangedComponent = null; if (!_isComponentObjectNull) { ComponentObject = EditorUtility.InstanceIDToObject(ComponentObject.GetInstanceID()) as Component; } else { ComponentObject = null; } if (ComponentObject != null && _values != null) { foreach (var name in _values.Keys) { var newValue = _values[name]; var property = ComponentObject.GetType().GetProperty(name); if (null != property) { var currentValue = property.GetValue(ComponentObject, null); if (!HasValueChanged(newValue, currentValue)) { continue; } property.SetValue(ComponentObject, newValue, null); resultChangedComponent = ComponentObject; } else { var field = ComponentObject.GetType().GetField(name); var currentValue = field.GetValue(ComponentObject); if (!HasValueChanged(newValue, currentValue)) { continue; } field.SetValue(ComponentObject, newValue); resultChangedComponent = ComponentObject; } } } _values = null; return(resultChangedComponent); }
private List <FieldInfo> GetFields(List <string> propertiesToIgnore) { List <FieldInfo> fields = new List <FieldInfo>(); foreach (FieldInfo fieldInfo in ComponentObject.GetType().GetFields()) { if (fieldInfo.IsPublic && !propertiesToIgnore.Contains(fieldInfo.Name)) { if (!Attribute.IsDefined(fieldInfo, typeof(HideInInspector))) { fields.Add(fieldInfo); } } } return(fields); }
private IEnumerable <FieldInfo> GetFields() { var fields = new List <FieldInfo>(); foreach (var fieldInfo in ComponentObject.GetType().GetFields()) { if (!fieldInfo.IsPublic) { continue; } if (!Attribute.IsDefined(fieldInfo, typeof(HideInInspector))) { fields.Add(fieldInfo); } } return(fields); }
private IEnumerable <PropertyInfo> GetProperties() { var properties = new List <PropertyInfo>(); foreach (var propertyInfo in ComponentObject.GetType().GetProperties()) { if (Attribute.IsDefined(propertyInfo, typeof(HideInInspector))) { continue; } var setMethod = propertyInfo.GetSetMethod(); if (null != setMethod && setMethod.IsPublic) { properties.Add(propertyInfo); } } return(properties); }
private List <PropertyInfo> GetProperties(List <string> propertiesToIgnore) { List <PropertyInfo> properties = new List <PropertyInfo>(); foreach (PropertyInfo propertyInfo in ComponentObject.GetType().GetProperties()) { if (!propertiesToIgnore.Contains(propertyInfo.Name)) { if (!Attribute.IsDefined(propertyInfo, typeof(HideInInspector))) { MethodInfo setMethod = propertyInfo.GetSetMethod(); if (null != setMethod && setMethod.IsPublic) { properties.Add(propertyInfo); } } } } return(properties); }
private void ButtonCreate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { object newObject = null; var editValue = EditValue; switch (EditMode) { case ObjectEditMode.Property: var propertyName = (string)Key; var property = ComponentObject.GetType().GetProperty(propertyName); if (ConfigPublic.CreateNewAddonValue(property.PropertyType , false , out newObject)) { EditValue = newObject; SetComponentPropertyValue(); ModifyData(); } break; case ObjectEditMode.Object: var objectType = ObjectType; if (objectType == null) { objectType = typeof(PaoObject); } if (ConfigPublic.CreateNewAddonValue(objectType , false , out newObject)) { EditValue = newObject; SetComponentPropertyValue(); ModifyData(); } break; default: break; } }
public void RestoreSettings() { if (ComponentObject != null) { ComponentObject = EditorUtility.InstanceIDToObject(ComponentObject.GetInstanceID()) as Component; } if (IsSavingSettings && null != ComponentObject && null != values) { foreach (string name in values.Keys) { object newValue = values[name]; PropertyInfo property = ComponentObject.GetType().GetProperty(name); if (null != property) { object currentValue = property.GetValue(ComponentObject, null); if (HasValueChanged(newValue, currentValue)) { property.SetValue(ComponentObject, newValue, null); } } else { FieldInfo field = ComponentObject.GetType().GetField(name); object currentValue = field.GetValue(ComponentObject); if (HasValueChanged(newValue, currentValue)) { field.SetValue(ComponentObject, newValue); } } } } values = null; }
//return component is changes have been made public Component RestoreSettings() { Component resultChangedComponent = null; if (!_isComponentObjectNull) { ComponentObject = EditorUtility.InstanceIDToObject(ComponentObject.GetInstanceID()) as Component; } else { ComponentObject = null; } if (ComponentObject != null && _values != null) { foreach (var name in _values.Keys) { var newValue = _values[name]; var property = ComponentObject.GetType().GetProperty(name); if (null != property) { var currentValue = property.GetValue(ComponentObject, null); if (!HasValueChanged(newValue, currentValue)) { continue; } property.SetValue(ComponentObject, newValue, null); resultChangedComponent = ComponentObject; } else { var field = ComponentObject.GetType().GetField(name); var currentValue = field.GetValue(ComponentObject); if (!HasValueChanged(newValue, currentValue)) { continue; } if (ComponentObject.ToString().Contains("DarkTonic.MasterAudio.MasterAudio")) { switch (field.Name) { case "customEvents": FilterOutDGSCCustomEvents(ref newValue); break; case "customEventCategories": FilterOutDGSCCustomEventCategories(ref newValue); break; case "musicPlaylists": FilterOutDGSCPlaylists(ref newValue); break; case "groupBuses": FilterOutDGSCBuses(ref newValue); break; case "musicDuckingSounds": FilterOutDGSCDuckGroups(ref newValue); break; } } field.SetValue(ComponentObject, newValue); resultChangedComponent = ComponentObject; } } } _values = null; return(resultChangedComponent); }