コード例 #1
0
ファイル: SearchExpression.cs プロジェクト: rx1242/unityEX
        private SearchExpressionNode LoadNodeData(SearchExpressionNode node, IDictionary info)
        {
            if (SJSON.TryGetValue(info, ExpressionField.name, out var name))
            {
                node.name = Convert.ToString(name);
            }

            if (SJSON.TryGetValue(info, ExpressionField.value, out var value))
            {
                node.value = value;
            }

            if (node.type == ExpressionType.Expression)
            {
                var nestedExpression = new SearchExpression(m_SearchOptions);

                if (node.value is string expressionPath && File.Exists(expressionPath))
                {
                    nestedExpression.Load(expressionPath);
                }
                else if (SJSON.TryGetValue(info, ExpressionField.source, out var source) && source is IDictionary sourceData)
                {
                    nestedExpression.Load(sourceData);
                }

                if (nestedExpression.m_EvalNode != null && nestedExpression.m_EvalNode.source != null)
                {
                    node.source = nestedExpression.m_EvalNode.source;
                }
            }
コード例 #2
0
ファイル: SearchService.cs プロジェクト: Yuceldd/2d-platform
        /// <summary>
        /// Parse a simple json document string as a SearchExpression.
        /// </summary>
        /// <param name="sjson">Simple Json string defining a SearchExpression</param>
        /// <param name="options">Options defining how the query will be performed</param>
        /// <returns>Returns a SearchExpression ready to be evaluated.</returns>
        public static ISearchExpression ParseExpression(string sjson, SearchFlags options = SearchFlags.Default)
        {
            var se = new SearchExpression(options);

            se.Parse(sjson);
            return(se);
        }
コード例 #3
0
        public ExpressionResultView(SearchExpression expression)
        {
            style.overflow = Overflow.Hidden;
            onGUIHandler   = OnGUI;

            this.expression = expression;
            m_View          = new ListView(this);
        }
コード例 #4
0
ファイル: SearchService.cs プロジェクト: Yuceldd/2d-platform
        /// <summary>
        /// Load a search expression asset.
        /// </summary>
        /// <param name="expressionPath">Asset path of the search expression</param>
        /// <param name="options">Options defining how the query will be performed</param>
        /// <returns>Returns a SearchExpression ready to be evaluated.</returns>
        public static ISearchExpression LoadExpression(string expressionPath, SearchFlags options = SearchFlags.Default)
        {
            if (!File.Exists(expressionPath))
            {
                throw new ArgumentException($"Cannot find expression {expressionPath}", nameof(expressionPath));
            }

            var se = new SearchExpression(options);

            se.Load(expressionPath);
            return(se);
        }
コード例 #5
0
        private void InitializeExpression()
        {
            if (m_Expression != null)
            {
                return;
            }

            m_ExpressionPath  = AssetDatabase.GetAssetPath(target);
            m_ExpressionName  = Path.GetFileNameWithoutExtension(m_ExpressionPath);
            m_ExpressionTitle = new GUIContent(m_ExpressionName, Icons.quicksearch, m_ExpressionPath);

            m_Expression = new SearchExpression(SearchSettings.GetContextOptions());
            m_Expression.Load(m_ExpressionPath);
            m_Expression.Evaluate();
        }
コード例 #6
0
        internal static void CreateIndexProject()
        {
            var folderPath = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (File.Exists(folderPath))
            {
                folderPath = Path.GetDirectoryName(folderPath);
            }

            var expressionPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(folderPath, "expression.qse"));
            var newExpression  = new SearchExpression(SearchFlags.Default);

            newExpression.Save(expressionPath);
            AssetDatabase.ImportAsset(expressionPath);
            Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(expressionPath);
        }
コード例 #7
0
        public ExpressionGraph(SearchExpression expression)
        {
            focusable = true;

            m_Expression = expression;

            SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);

            Insert(0, new GridBackground());

            this.AddManipulator(new ContentDragger());
            this.AddManipulator(new SelectionDragger());
            this.AddManipulator(new RectangleSelector());
            this.AddManipulator(new FreehandSelector());

            ReloadExpression();

            graphViewChanged += OnGraphViewChanged;
        }
コード例 #8
0
ファイル: ExpressionBuilder.cs プロジェクト: Buster-00/Q_G
        public void OnDisable()
        {
            SaveSplitterPosition();

            m_ExpressionGraph.nodeChanged      -= OnNodePropertiesChanged;
            m_ExpressionGraph.graphChanged     -= OnGraphChanged;
            m_ExpressionGraph.selectionChanged -= OnSelectionChanged;
            m_ExpressionGraph.Dispose();
            m_ExpressionGraph = null;

            m_NodeEditor.propertiesChanged -= OnNodePropertiesChanged;
            m_NodeEditor.variableAdded     -= OnNodeVariableAdded;
            m_NodeEditor.variableRemoved   -= OnNodeVariableRemoved;
            m_NodeEditor.variableRenamed   -= OnNodeVariableRenamed;
            m_NodeEditor.Dispose();
            m_NodeEditor = null;

            m_Expression.Dispose();
            m_Expression = null;
        }
コード例 #9
0
ファイル: ExpressionBuilder.cs プロジェクト: Buster-00/Q_G
        public void OnEnable()
        {
            m_Expression      = new SearchExpression(SearchSettings.GetContextOptions());
            m_ExpressionGraph = new ExpressionGraph(m_Expression);

            titleContent = new GUIContent("Expression Builder", Icons.quicksearch);

            #if UNITY_2020_2_OR_NEWER
            wantsLessLayoutEvents = true;
            #endif

            BuildUI();
            Reload();

            m_ExpressionGraph.nodeChanged      += OnNodePropertiesChanged;
            m_ExpressionGraph.graphChanged     += OnGraphChanged;
            m_ExpressionGraph.selectionChanged += OnSelectionChanged;
            m_NodeEditor.propertiesChanged     += OnNodePropertiesChanged;
            m_NodeEditor.variableAdded         += OnNodeVariableAdded;
            m_NodeEditor.variableRemoved       += OnNodeVariableRemoved;
            m_NodeEditor.variableRenamed       += OnNodeVariableRenamed;
        }
コード例 #10
0
 public static SearchVariable[] UpdateVariables(SearchExpression se, in SearchVariable[] variables)