private void Refresh() { DataBinding.LoadBindableTypeAndProperties(); dic_type_propertyTrees.Clear(); SelectedType = null; TreeItem.SelectedItem = null; List<Type> typeList = new List<Type>(); string selectedTypeFullName = EditorPrefs.GetString("DataBindingForUnityEditor_SelectedType"); if (!string.IsNullOrEmpty(typeFullName)) selectedTypeFullName = typeFullName; string selectedPath = EditorPrefs.GetString("DataBindingForUnityEditor_SelectedPath"); if (!string.IsNullOrEmpty(path)) selectedPath = path; foreach (var assembly in DataBinding.GetAssemblies()) { foreach (var type in assembly.GetTypes()) { if (!typeof(BindableObject).IsAssignableFrom(type)) continue; typeList.Add(type); List<TreeItem> trees = new List<TreeItem>(); foreach (var property in BindableProperty.GetProperties(type)) { TreeItem tree = new TreeItem() { Title = string.Format("{0} : ({1})", property.Name, GetTypeAlias(property.PropertyType.FullName)), Tag = property }; trees.Add(tree); CreateChildTreeItem(tree, selectedPath); } dic_type_propertyTrees[type] = trees.OrderBy(t => t.Title).ToArray(); if (type.FullName == selectedTypeFullName) SelectedType = type; } } types = typeList.OrderBy(t => t.FullName).ToArray(); }
private static void CreateChildTreeItem(TreeItem parent, string selectedPath) { if (parent.SelectedPath == selectedPath) TreeItem.SelectedItem = parent; if (parent.Tag == null) return; var property = parent.Tag as BindableProperty; if (property == null) return; if (!typeof(BindableObject).IsAssignableFrom(property.PropertyType)) return; List<TreeItem> trees = new List<TreeItem>(); foreach (var pro in BindableProperty.GetProperties(property.PropertyType)) { TreeItem tree = new TreeItem() { Title = string.Format("{0} : ({1})", pro.Name, GetTypeAlias(pro.PropertyType.FullName)), Tag = pro, Parent = parent }; //trees.Add(tree); CreateChildTreeItem(tree, selectedPath); } //foreach (var tree in trees.OrderBy(t => t.Title)) // tree.Parent = parent; }