protected override void Update() { using (Property()) { Label(); Default(field => field.Component); var behaviour = GetBehaviour(); var typeName = GetValue(field => field.Component.TypeName); var index = GetValue(field => field.Component.Index); var component = SerializableComponent.Get(behaviour, typeName, index); var fields = component.GetType() .GetProperties() .Where(each => each.GetGetMethod() != null) .OrderBy(each => each.Name) .ToDictionary(each => each.Name, each => each.Name); Next(); UI.Dropdown(fields, property => property.PropertyName); } }
protected override void Update() { var source = GetValue(field => field.Source); if (source != null) { using (Property()) { Label(); var components = GetComponentDictionary(source); var result = UI.Dropdown(components, field => field.ComponentName); if (result.Index >= 0) { var value = GetValue(field => field.ComponentName); if (value.Contains("|")) { var index = value.Split('|').Last(); SetProperty(field => field.Index, index); } } // New scope { var typeName = GetValue(field => field.ComponentName); var index = GetValue(field => field.Index); var component = SerializableComponent.Get(source, typeName, index); var componentType = component.GetType(); var dictionary = componentType.GetEvents().ToDictionary(each => each.Name, each => each.Name); LeftGap(); UI.Dropdown(dictionary, property => property.EventName); } } } }
public PropertyInfo GetProperty(MonoBehaviour behaviour) { var component = Component.Get(behaviour); return(component.GetType().GetProperty(PropertyName)); }
protected override void Update() { using (Property()) { Label(); Default(field => field.Source); Newline(); var source = GetValue(field => field.Source); if (source == null) { return; } var componentType = source.GetType(); var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly; if (componentType.Is <MonoScript>()) { componentType = source.As <MonoScript>().GetClass(); } if (componentType.Is <MonoBehaviour>() || componentType.Is <ScriptableObject>()) { var properties = componentType.GetProperties(bindingFlags) .Where(each => each.GetGetMethod() != null) .OrderBy(each => each.Name) .Cast <MemberInfo>(); var fields = componentType.GetFields(bindingFlags) .OrderBy(each => each.Name) .Cast <MemberInfo>(); var dictionary = fields.Concat(properties).Concat(componentType.GetEvents(bindingFlags)).ToDictionary(each => each.Name, each => each.Name); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); UI.Dropdown(dictionary, property => property.MemberName); } else { var gameObject = source as GameObject; if (gameObject.IsPrefab()) { return; } var components = GetComponentDictionary(gameObject); var result = UI.Dropdown(components, field => field.ComponentName); if (result.Index >= 0) { var value = GetValue(field => field.ComponentName); if (value.Contains("|")) { SetProperty(field => field.Index, value.Split('|').Last()); } } var typeName = GetValue(field => field.ComponentName); var index = GetValue(field => field.Index); var component = SerializableComponent.Get(gameObject, typeName, index); var chosenComponentType = component.GetType(); var properties = chosenComponentType.GetProperties(bindingFlags) .Where(each => each.GetGetMethod() != null) .OrderBy(each => each.Name) .Cast <MemberInfo>(); var fields = chosenComponentType.GetFields(bindingFlags) .OrderBy(each => each.Name) .Cast <MemberInfo>(); var componentDictionary = fields.Concat(properties) .Concat(chosenComponentType.GetEvents(bindingFlags)) .ToDictionary(each => each.Name, each => each.Name); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); LeftGap(); UI.Dropdown(componentDictionary, property => property.MemberName); } } }