public static IGraphElement CreateToken(this ElementBuilder elementBuilder, IStore store, IVariableModel model) { var isExposed = model.DeclarationModel?.IsExposed; Texture2D icon = (isExposed != null && isExposed.Value) ? GraphViewStaticBridge.LoadIconRequired("GraphView/Nodes/BlackboardFieldExposed.png") : null; var ui = new Token(); ui.Setup(model, store, elementBuilder.GraphView, icon); return(ui); }
public TokenDeclaration(Store store, IVariableDeclarationModel model, GraphView graphView) { m_Pill = new Pill(); Add(m_Pill); if (model is IObjectReference modelReference) { if (modelReference is IExposeTitleProperty titleProperty) { var titleLabel = m_Pill.Q <Label>("title-label"); titleLabel.bindingPath = titleProperty.TitlePropertyName; } } styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Token.uss")); Setup(model as IGTFGraphElementModel, store, graphView); m_Pill.icon = Declaration.IsExposed ? GraphViewStaticBridge.LoadIconRequired("GraphView/Nodes/BlackboardFieldExposed.png") : null; m_Pill.text = Declaration.Title; var variableModel = model as VariableDeclarationModel; Stencil stencil = store.GetState().CurrentGraphModel?.Stencil; if (variableModel != null && stencil != null && variableModel.DataType.IsValid) { string friendlyTypeName = variableModel.DataType.GetMetadata(stencil).FriendlyName; Assert.IsTrue(!string.IsNullOrEmpty(friendlyTypeName)); tooltip = $"{variableModel.VariableString} declaration of type {friendlyTypeName}"; if (!string.IsNullOrEmpty(variableModel.Tooltip)) { tooltip += "\n" + variableModel.Tooltip; } } SetClasses(); this.EnableRename(); if (model != null) { viewDataKey = model.GetId(); } }
void UpdateData() { title = modelNode.fieldName; if (modelNode.field == null) { if (panel != null) { if (m_ErrorBadge == null) { m_ErrorBadge = IconBadge.CreateError("Field not found"); } if (m_ErrorBadge.parent == null) { parent.Add(m_ErrorBadge); m_ErrorBadge.AttachTo(this, SpriteAlignment.TopCenter); } } icon = null; } else { icon = modelNode.field.exposed ? GraphViewStaticBridge.LoadIconRequired("GraphView/Nodes/BlackboardFieldExposed.png") : null; if (m_ErrorBadge == null) { m_ErrorBadge = IconBadge.CreateError("Field not found"); } if (m_ErrorBadge != null && m_ErrorBadge.parent != null) { m_ErrorBadge.Detach(); m_ErrorBadge.RemoveFromHierarchy(); } } }
public List <SearchTreeEntry> CreateSearchTree(SearchWindowContext context) { var tree = new List <SearchTreeEntry>(); Texture2D icon = GraphViewStaticBridge.LoadIconRequired("cs Script Icon"); tree.Add(new SearchTreeGroupEntry(new GUIContent("Create Node"), 0)); tree.Add(new SearchTreeGroupEntry(new GUIContent("Operators"), 1)); tree.Add(new SearchTreeEntry(new GUIContent("Addition", icon)) { level = 2, userData = typeof(MathAdditionOperator) }); tree.Add(new SearchTreeEntry(new GUIContent("Subtraction", icon)) { level = 2, userData = typeof(MathSubtractionOperator) }); tree.Add(new SearchTreeEntry(new GUIContent("Multiplication", icon)) { level = 2, userData = typeof(MathMultiplicationOperator) }); tree.Add(new SearchTreeEntry(new GUIContent("Division", icon)) { level = 2, userData = typeof(MathDivisionOperator) }); tree.Add(new SearchTreeEntry(new GUIContent("Result", icon)) { level = 2, userData = typeof(MathResult) }); tree.Add(new SearchTreeGroupEntry(new GUIContent("Functions"), 1)); tree.Add(new SearchTreeEntry(new GUIContent("Sin", icon)) { level = 2, userData = typeof(SinFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Asin", icon)) { level = 2, userData = typeof(AsinFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Cos", icon)) { level = 2, userData = typeof(CosFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Acos", icon)) { level = 2, userData = typeof(AcosFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Tan", icon)) { level = 2, userData = typeof(TanFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Atan", icon)) { level = 2, userData = typeof(AtanFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Min", icon)) { level = 2, userData = typeof(MinFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Max", icon)) { level = 2, userData = typeof(MaxFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Clamp", icon)) { level = 2, userData = typeof(ClampFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Exp", icon)) { level = 2, userData = typeof(ExpFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Log", icon)) { level = 2, userData = typeof(LogFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Pow", icon)) { level = 2, userData = typeof(PowFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Round", icon)) { level = 2, userData = typeof(RoundFunction) }); tree.Add(new SearchTreeEntry(new GUIContent("Sqrt", icon)) { level = 2, userData = typeof(SqrtFunction) }); tree.Add(new SearchTreeGroupEntry(new GUIContent("Values"), 1)); tree.Add(new SearchTreeEntry(new GUIContent("Constant value", icon)) { level = 2, userData = typeof(MathConstant) }); tree.Add(new SearchTreeEntry(new GUIContent("PI", icon)) { level = 2, userData = typeof(PIConstant) }); return(tree); }