private void AddScriptableElement(PropertyInfo prop, Dictionary <string, string> properties) { var items = ScriptableExtensions.GetAllInstances(prop.PropertyType); _properties[prop.Name] = properties.ContainsKey(prop.Name) && items.Any(x => x.name == properties[prop.Name]) ? items.First(x => x.name == properties[prop.Name]).name : items.First().name; var dictionary = new Dictionary <string, Action>(); items.ForEach(item => dictionary[item.name] = () => _properties[prop.Name] = item.name); _elements.Add(new ElementLabel(new OptionsElement(dictionary, _properties[prop.Name], 200), prop.Name.WithSpaceBetweenWords())); }
public void LoadAssets() { var orchestrator = (NodeTreeOrchestrator)target; var scriptableObjectArrayFields = typeof(NodeTreeOrchestrator) .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) .Where(x => x.FieldType.IsArray && typeof(ScriptableObject).IsAssignableFrom(x.FieldType.GetElementType())) .ToArray(); foreach (var f in scriptableObjectArrayFields) { var arrItemType = f.FieldType.GetElementType(); var instances = ScriptableExtensions.GetAllInstances(arrItemType); ReflectionUtilities.SetArrayValueOnField(f, target, instances); } orchestrator.NodeTrees = Resources.LoadAll <TextAsset>("NodeTrees").Where(x => !x.name.ToLower().Contains("autosave")).ToArray(); orchestrator.CurrentNodeTree = ScriptableExtensions.GetAllInstances <CurrentNodeTree>().First(); }