Exemple #1
0
        private void InitHierarchyView(VsScene scene, System.Collections.Generic.List <VsGameObject> objs)
        {
            hierarchyView.Items.Clear();

            TreeViewItem sceneItem = new TreeViewItem();

            sceneItem.Header = scene.name;

            foreach (var obj in objs)
            {
                MyTreeViewItem objItem = new MyTreeViewItem();
                objItem.Header         = obj.name;
                objItem.doubleClicked += () => Inspect(objItem);
                if (obj.childCount > 0)
                {
                    objItem.CreateDummy();
                    objItem.Expanded += ObjItem_Expanded;
                }
                sceneItem.Items.Add(objItem);
            }

            hierarchyView.Items.Add(sceneItem);
        }
Exemple #2
0
        private void ObjItem_Expanded(object sender, System.Windows.RoutedEventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (CheckNotInBreakMode())
            {
                return;
            }

            MyTreeViewItem item = sender as MyTreeViewItem;

            if (item == null)
            {
                return;
            }

            item.Expanded -= ObjItem_Expanded;

            int[] index = item.GetIndexOfItem();
            if (index == null)
            {
                return;
            }

            string transformQuery = GetTransformQuery(index);

            if (!isInitObj)
            {
                dte.Debugger.ExecuteStatement(Statement: "UnityEngine.Transform tf;");
                isInitObj = true;
            }

            EnvDTE.TextSelection selection = commandWindow?.Selection as EnvDTE.TextSelection;

            dte.Debugger.ExecuteStatement(Statement: $"tf = objs{transformQuery};");

            string childCountStr = GetDebuggerExecutionOutput(Statement: $"tf.childCount", TreatAsExpression: true, selection);

            int childCount = int.Parse(childCountStr.SplitAndTrim("\r\n", StringSplitOptions.RemoveEmptyEntries)[0]);

            if (item.hasDummy)
            {
                item.Items.Clear();

                // Get Name
                int lineNum;
                selection.SaveLinePosition(out lineNum);
                for (int i = 0; i < childCount; ++i)
                {
                    dte.Debugger.ExecuteStatement(Statement: $"tf.GetChild({i}).childCount", TreatAsExpression: true);
                }
                string   childCountsInfoStr = selection.GetTextBetweenCurPosToLine(lineNum);
                string[] childCounts        = childCountsInfoStr.SplitAndTrim("\r\n", StringSplitOptions.RemoveEmptyEntries);

                // Get childCount
                selection.SaveLinePosition(out lineNum);
                for (int i = 0; i < childCount; ++i)
                {
                    dte.Debugger.ExecuteStatement(Statement: $"tf.GetChild({i}).name", TreatAsExpression: true);
                }
                string   childNamesInfoStr = selection.GetTextBetweenCurPosToLine(lineNum);
                string[] childNames        = childNamesInfoStr.SplitAndTrim("\r\n", StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < childCount; ++i)
                {
                    MyTreeViewItem objItem = new MyTreeViewItem();
                    objItem.Header         = childNames[i].Trim('"');
                    objItem.doubleClicked += () => Inspect(objItem);
                    if (int.Parse(childCounts[i]) > 0)
                    {
                        objItem.CreateDummy();
                        objItem.Expanded += ObjItem_Expanded;
                    }
                    item.Items.Add(objItem);
                }
            }
            else
            {
                // if the item doesn't have dummy item, we don't need to initialize it again.
            }
        }