public GraphElementSearcherDatabase AddGraphAssetMembers(IGraphModel graph) { SearcherItem parent = null; TypeHandle voidTypeHandle = Stencil.GenerateTypeHandle(typeof(void)); foreach (var functionModel in graph.NodeModels.OfType <FunctionModel>()) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, graph.Name); } if (functionModel.ReturnType == voidTypeHandle) { parent.AddChild(new StackNodeModelSearcherItem( new GraphAssetSearcherItemData(graph.AssetModel), data => data.CreateFunctionRefCallNode(functionModel), functionModel.Title )); continue; } parent.AddChild(new GraphNodeModelSearcherItem( new GraphAssetSearcherItemData(graph.AssetModel), data => data.CreateFunctionRefCallNode(functionModel), functionModel.Title )); } return(this); }
void CreateFieldItems(SearcherItem root, Type type, int depth) { var operators = GetOperatorsFromType(type); foreach (var op in operators) { root.AddChild(op); } depth--; if (depth <= 0) { return; } var infos = GetMemberInfos(type); foreach (var info in infos) { var itemType = info.MemberType == MemberTypes.Field ? (info as FieldInfo)?.FieldType : (info as PropertyInfo)?.PropertyType; var item = new TypeSearcherItem(itemType.GenerateTypeHandle(m_Stencil), info.Name); CreateFieldItems(item, itemType, depth); // We only display item with binary operators if (item.HasChildren) { root.AddChild(item); } } }
public GraphElementSearcherDatabase AddUnaryOperators() { SearcherItem parent = SearcherItemUtility.GetItemFromPath(Items, k_Operator); foreach (UnaryOperatorKind kind in Enum.GetValues(typeof(UnaryOperatorKind))) { if (kind == UnaryOperatorKind.PostDecrement || kind == UnaryOperatorKind.PostIncrement) { parent.AddChild(new StackNodeModelSearcherItem( new UnaryOperatorSearcherItemData(kind), data => data.CreateUnaryStatementNode(kind), kind.ToString() )); continue; } parent.AddChild(new GraphNodeModelSearcherItem( new UnaryOperatorSearcherItemData(kind), data => data.CreateUnaryStatementNode(kind), kind.ToString() )); } return(this); }
public GraphElementSearcherDatabase AddMethods( Type type, BindingFlags bindingFlags, Dictionary <string, List <Type> > blackList = null ) { SearcherItem parent = null; foreach (MethodInfo methodInfo in type.GetMethods(bindingFlags) .Where(m => !m.IsSpecialName && m.GetCustomAttribute <ObsoleteAttribute>() == null && m.GetCustomAttribute <HiddenAttribute>() == null && !m.Name.StartsWith("get_", StringComparison.Ordinal) && !m.Name.StartsWith("set_", StringComparison.Ordinal) && !m.GetParameters().Any(p => p.ParameterType.IsByRef || p.IsOut || p.ParameterType.IsPointer) && !SearcherItemCollectionUtility.IsMethodBlackListed(m, blackList)) .OrderBy(m => m.Name)) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } MethodDetails details = methodInfo.GetMethodDetails(); if (methodInfo.ReturnType == typeof(void)) { parent.AddChild(new StackNodeModelSearcherItem( new MethodSearcherItemData(methodInfo), data => ((StackBaseModel)data.StackModel).CreateFunctionCallNode( methodInfo, data.Index, data.SpawnFlags ), details.MethodName, details.Details )); continue; } if (!methodInfo.ReturnType.IsPointer) { parent.AddChild(new GraphNodeModelSearcherItem( new MethodSearcherItemData(methodInfo), data => ((VSGraphModel)data.GraphModel).CreateFunctionCallNode( methodInfo, data.Position, data.SpawnFlags ), details.MethodName, details.Details )); } } return(this); }
public GraphElementSearcherDatabase AddGraphsMethods() { string[] assetGUIDs = AssetDatabase.FindAssets($"t:{typeof(VSGraphAssetModel).Name}"); List <Tuple <IGraphModel, FunctionModel> > methods = assetGUIDs.SelectMany(assetGuid => { string assetPath = AssetDatabase.GUIDToAssetPath(assetGuid); VSGraphAssetModel graphAssetModel = AssetDatabase.LoadAssetAtPath <VSGraphAssetModel>(assetPath); if (!graphAssetModel || graphAssetModel.GraphModel == null) { return(Enumerable.Empty <Tuple <IGraphModel, FunctionModel> >()); } var functionModels = graphAssetModel.GraphModel.NodeModels.OfExactType <FunctionModel>() .Select(fm => new Tuple <IGraphModel, FunctionModel>(fm.GraphModel, fm)); return(functionModels.Concat(graphAssetModel.GraphModel.NodeModels.OfExactType <EventFunctionModel>() .Select(fm => new Tuple <IGraphModel, FunctionModel>(fm.GraphModel, fm)))); }).ToList(); if (methods.Count == 0) { return(this); } TypeHandle voidTypeHandle = typeof(void).GenerateTypeHandle(Stencil); foreach (Tuple <IGraphModel, FunctionModel> method in methods) { IGraphModel graphModel = method.Item1; FunctionModel functionModel = method.Item2; string graphName = graphModel.AssetModel.Name; SearcherItem graphRoot = SearcherItemUtility.GetItemFromPath(Items, $"{k_Graphs}/{graphName}"); if (functionModel.ReturnType == voidTypeHandle) { graphRoot.AddChild(new StackNodeModelSearcherItem( new FunctionRefSearcherItemData(graphModel, functionModel), data => data.CreateFunctionRefCallNode(functionModel), () => $"{k_Function} {functionModel.Title}" )); continue; } graphRoot.AddChild(new GraphNodeModelSearcherItem( new FunctionRefSearcherItemData(graphModel, functionModel), data => data.CreateFunctionRefCallNode(functionModel), () => $"{k_Function} {functionModel.Title}" )); } return(this); }
public GraphElementSearcherDatabase AddExtensionMethods(Type type) { Dictionary <Type, List <MethodInfo> > extensions = TypeSystem.GetExtensionMethods(Stencil.GetAssemblies()); if (!extensions.TryGetValue(type, out var methodInfos)) { return(this); } SearcherItem parent = null; foreach (MethodInfo methodInfo in methodInfos .Where(m => !m.GetParameters().Any(p => p.ParameterType.IsByRef || p.IsOut))) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } MethodDetails details = methodInfo.GetMethodDetails(); if (methodInfo.ReturnType != typeof(void)) { parent.AddChild(new GraphNodeModelSearcherItem( new MethodSearcherItemData(methodInfo), data => ((VSGraphModel)data.GraphModel).CreateFunctionCallNode( methodInfo, data.Position, data.SpawnFlags ), details.MethodName, details.Details )); continue; } parent.AddChild(new StackNodeModelSearcherItem( new MethodSearcherItemData(methodInfo), data => ((StackBaseModel)data.StackModel).CreateFunctionCallNode( methodInfo, data.Index, data.SpawnFlags ), details.MethodName, details.Details )); } return(this); }
public GraphElementSearcherDatabase AddFields(Type type, BindingFlags bindingFlags) { SearcherItem parent = null; foreach (FieldInfo fieldInfo in type.GetFields(bindingFlags) .OrderBy(f => f.Name) .Where(f => f.GetCustomAttribute <ObsoleteAttribute>() == null && f.GetCustomAttribute <HiddenAttribute>() == null)) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } parent.AddChild(new GraphNodeModelSearcherItem( new FieldSearcherItemData(fieldInfo), data => { INodeModel nodeModel = ((VSGraphModel)data.GraphModel).CreateGetPropertyGroupNode( data.Position, data.SpawnFlags ); ((GetPropertyGroupNodeModel)nodeModel).AddMember(fieldInfo.GetUnderlyingType(), fieldInfo.Name); return(nodeModel); }, fieldInfo.Name )); if (fieldInfo.CanWrite()) { parent.AddChild(new StackNodeModelSearcherItem( new FieldSearcherItemData(fieldInfo), data => { INodeModel nodeModel = ((StackBaseModel)data.StackModel).CreateSetPropertyGroupNode( data.Index ); ((SetPropertyGroupNodeModel)nodeModel).AddMember( fieldInfo.GetUnderlyingType(), fieldInfo.Name ); return(nodeModel); }, fieldInfo.Name )); } } return(this); }
public GraphElementSearcherDatabase AddGraphVariables(IGraphModel graphModel) { SearcherItem parent = null; var vsGraphModel = (VSGraphModel)graphModel; foreach (IVariableDeclarationModel declarationModel in vsGraphModel.GraphVariableModels) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, k_GraphVariables); } parent.AddChild(new GraphNodeModelSearcherItem( new TypeSearcherItemData(declarationModel.DataType, SearcherItemTarget.Variable), data => ((VSGraphModel)data.GraphModel).CreateVariableNode( declarationModel, data.Position, data.SpawnFlags ), declarationModel.Name.Nicify() )); } return(this); }
public GraphElementSearcherDatabase AddConstructors(Type type, BindingFlags bindingFlags) { SearcherItem parent = null; foreach (ConstructorInfo constructorInfo in type.GetConstructors(bindingFlags)) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } MethodDetails details = constructorInfo.GetMethodDetails(); parent.AddChild(new GraphNodeModelSearcherItem( new ConstructorSearcherItemData(constructorInfo), data => ((VSGraphModel)data.GraphModel).CreateFunctionCallNode( constructorInfo, data.Position, data.SpawnFlags ), details.MethodName, details.Details )); } return(this); }
public GraphElementSearcherDatabase AddFunctionMembers(IFunctionModel functionModel) { if (functionModel == null) { return(this); } SearcherItem parent = null; IEnumerable <IVariableDeclarationModel> members = functionModel.FunctionParameterModels.Union( functionModel.FunctionVariableModels); foreach (IVariableDeclarationModel declarationModel in members) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, k_FunctionMembers); } parent.AddChild(new GraphNodeModelSearcherItem( new TypeSearcherItemData(declarationModel.DataType, SearcherItemTarget.Variable), data => data.CreateVariableNode(declarationModel), declarationModel.Name.Nicify() )); } return(this); }
static void InitializeTypeItemsAndCache() { if (TypeItems != null) { return; } SearcherItem MakeItem(Type t, bool isShared) { s_TypeCache[t.FullName] = t; return(new PickTypeSearcherItem(t, isShared)); } IEnumerable <SearcherItem> MakeItems(bool isShared, IEnumerable <Type> types) => types.Select(t => MakeItem(t, isShared)); var l = new List <SearcherItem>(); SearcherItem common = new SearcherItem("Standard Types"); SearcherItem shared = new SearcherItem("Types available in Shared Components only"); l.Add(common); l.Add(shared); foreach (var searcherItem in MakeItems(false, new[] { typeof(int), typeof(bool), typeof(float), typeof(float2), typeof(float3), typeof(float4), typeof(quaternion), typeof(Entity), typeof(Color), })) { common.AddChild(searcherItem); } common.AddChild(MakeItem(typeof(GameObject), false)); foreach (var searcherItem in MakeItems(true, TypeCache.GetTypesDerivedFrom <Component>().Where(EcsStencil.IsValidGameObjectComponentType))) { shared.AddChild(searcherItem); } TypeItems = l; }
public Searcher.Searcher LoadSearchWindow() { GenerateNodeEntries(); //create empty root for searcher tree var root = new List <SearcherItem>(); var dummyEntry = new NodeEntry(); foreach (var nodeEntry in currentNodeEntries) { SearcherItem item = null; SearcherItem parent = null; for (int i = 0; i < nodeEntry.title.Length; i++) { var pathEntry = nodeEntry.title[i]; List <SearcherItem> children = parent != null ? parent.Children : root; item = children.Find(x => x.Name == pathEntry); if (item == null) { //if we have slot entries and are at a leaf, add the slot name to the entry title if (nodeEntry.compatibleSlotId != -1 && i == nodeEntry.title.Length - 1) { item = new SearchNodeItem(pathEntry + ": " + nodeEntry.slotName, nodeEntry); } //if we don't have slot entries and are at a leaf, add userdata to the entry else if (nodeEntry.compatibleSlotId == -1 && i == nodeEntry.title.Length - 1) { item = new SearchNodeItem(pathEntry, nodeEntry); } //if we aren't a leaf, don't add user data else { item = new SearchNodeItem(pathEntry, dummyEntry); } if (parent != null) { parent.AddChild(item); } else { children.Add(item); } } parent = item; if (parent.Depth == 0 && !root.Contains(parent)) { root.Add(parent); } } } var nodeDatabase = SearcherDatabase.Create(root, string.Empty, false); return(new Searcher.Searcher(nodeDatabase, new SearchWindowAdapter("Create Node"))); }
public GraphElementSearcherDatabase AddFields(Type type, BindingFlags bindingFlags) { SearcherItem parent = null; foreach (FieldInfo fieldInfo in type.GetFields(bindingFlags) .OrderBy(f => f.Name) .Where(f => f.GetCustomAttribute <ObsoleteAttribute>() == null && f.GetCustomAttribute <HiddenAttribute>() == null)) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } parent.AddChild(new GraphNodeModelSearcherItem( new FieldSearcherItemData(fieldInfo), data => { var getPropertyGroupModel = data.CreateGetPropertyGroupNode(); Undo.RegisterCompleteObjectUndo(getPropertyGroupModel.SerializableAsset, "Add Member"); getPropertyGroupModel.AddMember(fieldInfo.GetUnderlyingType(), fieldInfo.Name); EditorUtility.SetDirty(getPropertyGroupModel.SerializableAsset); return(getPropertyGroupModel); }, fieldInfo.Name )); if (fieldInfo.CanWrite()) { parent.AddChild(new StackNodeModelSearcherItem( new FieldSearcherItemData(fieldInfo), data => { SetPropertyGroupNodeModel nodeModel = data.CreateSetPropertyGroupNode(); Undo.RegisterCompleteObjectUndo(nodeModel.SerializableAsset, "Add Member"); nodeModel.AddMember(fieldInfo.GetUnderlyingType(), fieldInfo.Name); EditorUtility.SetDirty(nodeModel.SerializableAsset); return(nodeModel); }, fieldInfo.Name )); } } return(this); }
public GraphElementSearcherDatabase AddControlFlows() { AddIfCondition(IfConditionMode.Basic); AddIfCondition(IfConditionMode.Advanced); AddIfCondition(IfConditionMode.Complete); SearcherItem parent = null; var loopTypes = TypeCache.GetTypesDerivedFrom <LoopStackModel>(); foreach (var loopType in loopTypes.Where(t => !t.IsAbstract)) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, k_ControlFlow); } var name = $"{VseUtility.GetTitle(loopType)}{k_LoopStack}"; parent.AddChild(new StackNodeModelSearcherItem( new ControlFlowSearcherItemData(loopType), data => { var stackModel = (StackBaseModel)data.StackModel; var elements = new List <IGraphElementModel>(); var graphModel = (VSGraphModel)stackModel.GraphModel; var stackPosition = new Vector2( stackModel.Position.x + k_StackOffset.x, stackModel.Position.y + k_StackOffset.y ); LoopStackModel loopStack = graphModel.CreateLoopStack( loopType, stackPosition, data.SpawnFlags ); var node = loopStack.CreateLoopNode( stackModel, data.Index, data.SpawnFlags); elements.Add(node); elements.Add(loopStack); var edge = data.SpawnFlags.IsOrphan() ? graphModel.CreateOrphanEdge(loopStack.InputPort, node.OutputPort) : graphModel.CreateEdge(loopStack.InputPort, node.OutputPort); elements.Add(edge); return(elements.ToArray()); }, name )); } return(this); }
public ScriptView(ScriptsConfiguration config, Action drawHackGuiAction, Action saveAssetAction) { ScriptModified = false; this.config = config; this.saveAssetAction = saveAssetAction; editorResources = EditorResources.LoadOrDefault(); ViewRange = new IntRange(0, config.EditorPageLength - 1); styleSheets.Add(StyleSheet); if (EditorGUIUtility.isProSkin) { styleSheets.Add(DarkStyleSheet); } CustomStyleSheet = config.EditorCustomStyleSheet; if (CustomStyleSheet) { styleSheets.Add(CustomStyleSheet); } var commentItem = new SearcherItem("Comment"); var labelItem = new SearcherItem("Label"); var genericTextItem = new SearcherItem("Generic Text", config.InsertLineKey != KeyCode.None ? $"{(config.InsertLineModifier != EventModifiers.None ? $"{config.InsertLineModifier}+" : string.Empty)}{config.InsertLineKey}" : null); var commandsItem = new SearcherItem("Commands"); foreach (var commandId in Command.CommandTypes.Keys.OrderBy(k => k)) { commandsItem.AddChild(new SearcherItem(char.ToLowerInvariant(commandId[0]) + commandId.Substring(1))); } searchItems = new List <SearcherItem> { commandsItem, genericTextItem, labelItem, commentItem }; Add(new IMGUIContainer(drawHackGuiAction)); Add(new IMGUIContainer(() => HandleKeyDownEvent(null))); linesContainer = new VisualElement(); Add(linesContainer); paginationView = new PaginationView(SelectNextPage, SelectPreviousPage); paginationView.style.display = DisplayStyle.None; Add(paginationView); infoLabel = new Label("Loading, please wait..."); infoLabel.name = "InfoLabel"; ColorUtility.TryParseHtmlString(EditorGUIUtility.isProSkin ? "#cccccc" : "#555555", out var color); infoLabel.style.color = color; Add(infoLabel); RegisterCallback <KeyDownEvent>(HandleKeyDownEvent, TrickleDown.TrickleDown); RegisterCallback <MouseDownEvent>(HandleMouseDownEvent, TrickleDown.TrickleDown); new ContextualMenuManipulator(ContextMenu).target = this; }
public static void AddToSearcherDatabase(IGraphModel graphModel, GraphElementSearcherDatabase db) { SearcherItem parent = db.Items.GetItemFromPath("Fake"); parent.AddChild(new GraphNodeModelSearcherItem(graphModel, new NodeSearcherItemData(typeof(Type3FakeNodeModel)), data => data.CreateNode <Type3FakeNodeModel>(), nameof(Type3FakeNodeModel) )); }
public void TestFind_NotNull() { var parent = new SearcherItem("parent"); parent.AddChild(new SearcherItem("child")); var child = parent.Find("child"); Assert.NotNull(child); Assert.AreEqual(child.Name, "child"); }
public GraphElementSearcherDatabase AddMethods(IEnumerable <MethodInfo> methods) { SearcherItem parent = null; foreach (var method in methods.Where(m => !m.IsSpecialName && !m.Name.StartsWith("get_", StringComparison.Ordinal) && !m.Name.StartsWith("set_", StringComparison.Ordinal) && !m.GetParameters().Any(p => p.ParameterType.IsByRef || p.IsOut || p.ParameterType.IsPointer) && m.GetCustomAttribute <ObsoleteAttribute>() == null && m.GetCustomAttribute <HiddenAttribute>() == null)) { if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, method.ReflectedType.FriendlyName(false)); } MethodDetails details = method.GetMethodDetails(); if (method.ReturnType == typeof(void)) { parent.AddChild(new StackNodeModelSearcherItem( new MethodSearcherItemData(method), data => data.CreateFunctionCallNode(method), details.MethodName, details.Details )); continue; } if (!method.ReturnType.IsPointer) { parent.AddChild(new GraphNodeModelSearcherItem( new MethodSearcherItemData(method), data => data.CreateFunctionCallNode(method), details.MethodName )); } } return(this); }
public static void AddAtPath(this List <SearcherItem> items, SearcherItem item, string path = "") { if (!string.IsNullOrEmpty(path)) { SearcherItem parent = SearcherItemUtility.GetItemFromPath(items, path); parent.AddChild(item); } else { items.Add(item); } }
public GraphElementSearcherDatabase AddConstants(Type type) { TypeHandle handle = type.GenerateTypeHandle(Stencil); SearcherItem parent = SearcherItemUtility.GetItemFromPath(Items, k_Constant); parent.AddChild(new GraphNodeModelSearcherItem( new TypeSearcherItemData(handle, SearcherItemTarget.Constant), data => data.CreateConstantNode("", handle), $"{type.FriendlyName().Nicify()} {k_Constant}" )); return(this); }
public GraphElementSearcherDatabase AddBinaryOperators() { SearcherItem parent = SearcherItemUtility.GetItemFromPath(Items, k_Operator); foreach (BinaryOperatorKind kind in Enum.GetValues(typeof(BinaryOperatorKind))) { parent.AddChild(new GraphNodeModelSearcherItem( new BinaryOperatorSearcherItemData(kind), data => data.CreateBinaryOperatorNode(kind), kind.ToString() )); } return(this); }
public GraphElementSearcherDatabase AddMacros() { string[] assetGUIDs = AssetDatabase.FindAssets($"t:{typeof(VSGraphAssetModel).Name}"); List <VSGraphAssetModel> macros = assetGUIDs.Select(assetGuid => AssetDatabase.LoadAssetAtPath <VSGraphAssetModel>(AssetDatabase.GUIDToAssetPath(assetGuid))) .Where(x => { if (x.GraphModel == null) { Debug.Log("No GraphModel"); } else if (x.GraphModel.Stencil == null) { Debug.Log("No Stencil"); } else { return(x.GraphModel.Stencil.GetType() == typeof(MacroStencil)); } return(false); }) .ToList(); if (macros.Count == 0) { return(this); } SearcherItem parent = SearcherItemUtility.GetItemFromPath(Items, k_Macros); foreach (VSGraphAssetModel macro in macros) { parent.AddChild(new GraphNodeModelSearcherItem( new GraphAssetSearcherItemData(macro), data => ((VSGraphModel)data.GraphModel).CreateMacroRefNode( macro.GraphModel as VSGraphModel, data.Position, data.SpawnFlags ), $"{k_Macro} {macro.name}" )); } return(this); }
static ScriptView() { var styleSheetPath = PathUtils.AbsoluteToAssetPath(PathUtils.Combine(PackagePath.EditorResourcesPath, "VisualEditor.uss")); StyleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(styleSheetPath); var commentItem = new SearcherItem("Comment"); var labelItem = new SearcherItem("Label"); var genericTextItem = new SearcherItem("Generic Text"); var defineItem = new SearcherItem("Define"); var commandsItem = new SearcherItem("Commands"); foreach (var commandId in Commands.Command.CommandTypes.Keys.OrderBy(k => k)) { commandsItem.AddChild(new SearcherItem(char.ToLowerInvariant(commandId[0]) + commandId.Substring(1))); } searchItems = new List <SearcherItem> { commandsItem, genericTextItem, labelItem, commentItem, defineItem }; }
public static SearcherItem GetItemFromPath(this List <SearcherItem> items, string path) { Assert.IsFalse(string.IsNullOrEmpty(path)); string[] hierarchy = path.Split('/'); SearcherItem item = null; SearcherItem parent = null; for (var i = 0; i < hierarchy.Length; ++i) { string s = hierarchy[i]; if (i == 0 && s == "/" || s == string.Empty) { continue; } List <SearcherItem> children = parent != null ? parent.Children : items; item = children.Find(x => x.Name == s); if (item == null) { item = new SearcherItem(s); if (parent != null) { parent.AddChild(item); } else { children.Add(item); } } parent = item; } return(item ?? throw new InvalidOperationException( "[SearcherItemUtility.GetItemFromPath] : Returned item cannot be null" )); }
/// <summary> /// Adds searcher items for every graph variable to the database. /// </summary> /// <param name="graphModel">The GraphModel containing the variables.</param> /// <returns>The database with the elements.</returns> public GraphElementSearcherDatabase AddGraphVariables(IGraphModel graphModel) { SearcherItem parent = null; foreach (var declarationModel in graphModel.VariableDeclarations) { if (parent == null) { parent = Items.GetItemFromPath(k_GraphVariables); } parent.AddChild(new GraphNodeModelSearcherItem( Stencil.GraphModel, new TypeSearcherItemData(declarationModel.DataType), data => data.CreateVariableNode(declarationModel), declarationModel.DisplayTitle )); } return(this); }
public GraphElementSearcherDatabase AddProperties(Type type, BindingFlags bindingFlags) { SearcherItem parent = null; foreach (PropertyInfo propertyInfo in type.GetProperties(bindingFlags) .OrderBy(p => p.Name) .Where(p => p.GetCustomAttribute <ObsoleteAttribute>() == null && p.GetCustomAttribute <HiddenAttribute>() == null)) { var children = new List <SearcherItem>(); if (propertyInfo.GetIndexParameters().Length > 0) // i.e : Vector2.this[int] { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => ((VSGraphModel)data.GraphModel).CreateFunctionCallNode( propertyInfo.GetMethod, data.Position, data.SpawnFlags ), propertyInfo.Name )); } else { if (propertyInfo.CanRead) { if (propertyInfo.GetMethod.IsStatic) { if (propertyInfo.CanWrite) { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => ((VSGraphModel)data.GraphModel).CreateFunctionCallNode( propertyInfo.GetMethod, data.Position, data.SpawnFlags ), propertyInfo.Name )); } else { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => ((VSGraphModel)data.GraphModel).CreateSystemConstantNode( type, propertyInfo, data.Position, data.SpawnFlags ), propertyInfo.Name )); } } else { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => { INodeModel nodeModel = ((VSGraphModel)data.GraphModel).CreateGetPropertyGroupNode( data.Position, data.SpawnFlags ); ((GetPropertyGroupNodeModel)nodeModel).AddMember( propertyInfo.GetUnderlyingType(), propertyInfo.Name ); return(nodeModel); }, propertyInfo.Name )); } } if (propertyInfo.CanWrite) { children.Add(new StackNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => ((StackBaseModel)data.StackModel).CreateFunctionCallNode( propertyInfo.SetMethod, data.Index, data.SpawnFlags ), propertyInfo.Name )); } } if (children.Count == 0) { continue; } if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } foreach (SearcherItem child in children) { parent.AddChild(child); } } return(this); }
public GraphElementSearcherDatabase AddProperties(Type type, BindingFlags bindingFlags) { SearcherItem parent = null; foreach (PropertyInfo propertyInfo in type.GetProperties(bindingFlags) .OrderBy(p => p.Name) .Where(p => p.GetCustomAttribute <ObsoleteAttribute>() == null && p.GetCustomAttribute <HiddenAttribute>() == null)) { var children = new List <SearcherItem>(); if (propertyInfo.GetIndexParameters().Length > 0) // i.e : Vector2.this[int] { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => data.CreateFunctionCallNode(propertyInfo.GetMethod), propertyInfo.Name )); } else { if (propertyInfo.CanRead) { if (propertyInfo.GetMethod.IsStatic) { if (propertyInfo.CanWrite) { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => data.CreateFunctionCallNode(propertyInfo.GetMethod), propertyInfo.Name )); } else { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => data.CreateSystemConstantNode(type, propertyInfo), propertyInfo.Name )); } } else { children.Add(new GraphNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => { var getPropertyGroupModel = data.CreateGetPropertyGroupNode(); Undo.RegisterCompleteObjectUndo(getPropertyGroupModel.SerializableAsset, "Add Member"); getPropertyGroupModel.AddMember(propertyInfo.GetUnderlyingType(), propertyInfo.Name); EditorUtility.SetDirty(getPropertyGroupModel.SerializableAsset); return(getPropertyGroupModel); }, propertyInfo.Name )); } } if (propertyInfo.CanWrite) { children.Add(new StackNodeModelSearcherItem( new PropertySearcherItemData(propertyInfo), data => data.CreateFunctionCallNode(propertyInfo.SetMethod), propertyInfo.Name )); } } if (children.Count == 0) { continue; } if (parent == null) { parent = SearcherItemUtility.GetItemFromPath(Items, type.FriendlyName(false)); } foreach (SearcherItem child in children) { parent.AddChild(child); } } return(this); }
private static ECSComponentDatabase Populate <T>(NativeHashMap <int, int> map) { using (var pooledList = ListPool <SearcherItem> .GetDisposable()) using (var pooledDict = DictionaryPool <string, SearcherItem> .GetDisposable()) { var list = pooledList.List; var dict = pooledDict.Dictionary; var componentRoot = new SearcherItem(typeof(T).Name); list.Add(componentRoot); var collection = TypeCache.GetTypesDerivedFrom <T>(); foreach (var type in collection) { if (type.IsGenericType || type.IsAbstract || type.ContainsGenericParameters) { continue; } if (null != type.GetCustomAttribute <HideInInspectorAttribute>() || null != type.Assembly.GetCustomAttribute <HideInInspectorAttribute>() || ShouldTemporarilyIgnoreType(type)) { continue; } if (typeof(ISystemStateComponentData).IsAssignableFrom(type) || typeof(ISystemStateSharedComponentData).IsAssignableFrom(type) || typeof(ISystemStateBufferElementData).IsAssignableFrom(type)) { continue; } try { var index = TypeManager.GetTypeIndex(type); if (!map.TryGetValue(index, out _)) { var component = new TypeSearcherItem(type); var @namespace = type.Namespace ?? "Global"; if (!dict.TryGetValue(@namespace, out var item)) { dict[@namespace] = item = new SearcherItem(@namespace); componentRoot.AddChild(item); } item.AddChild(component); } } catch (Exception) { // ignored } } foreach (var kvp in dict) { kvp.Value.Children.Sort(CompareByName); } componentRoot.Children.Sort(CompareByName); return(new ECSComponentDatabase(list)); } }