コード例 #1
0
        void TraceEvents()
        {
            if (Trace == null)
            {
                if (ShouldTrace)
                {
                    Debug.Log("Enabling Trace...");
                    EnableTrace();
                }
                else
                {
                    Debug.LogError($"Can't trace input; Trace is null! (ShouldTrace = {ShouldTrace}, isServer = {isServer})");
                }
            }
            if (Trace != null)
            {
                //go through new events since last update
                InputEventPtr curEvent = new InputEventPtr();
                while (Trace.GetNextEvent(ref curEvent))
                {
                    //turn into bytes now instead of later?
                    TraceQueue.Enqueue(curEvent);

                    if (DebugPrint)
                    {
                        Debug.Log($"Traced event {curEvent.ToEvent()}");
                    }
                }
                Trace.Clear();

                ProcessEventsBytes(TraceQueue);
            }
        }
コード例 #2
0
        protected override TreeViewItem BuildRoot()
        {
            Profiler.BeginSample("BuildEventTree");

            var root = new TreeViewItem
            {
                id          = 0,
                depth       = -1,
                displayName = "Root"
            };

            ////FIXME: doing this over and over is very inefficient
            var eventCount = m_EventTrace.eventCount;

            m_Events = new InputEventPtr[eventCount];
            var current = new InputEventPtr();

            for (var i = eventCount - 1; i >= 0; --i)
            {
                if (!m_EventTrace.GetNextEvent(ref current))
                {
                    break;
                }
                m_Events[i] = current;
            }

            if (eventCount == 0)
            {
                // TreeView doesn't allow having empty trees. Put a dummy item in here that we
                // render without contents.
                root.AddChild(new TreeViewItem(1));
            }

            for (var i = 0; i < eventCount; ++i)
            {
                var eventPtr = m_Events[i];

                var item = new TreeViewItem
                {
                    id          = i + 1,
                    depth       = 1,
                    displayName = eventPtr.id.ToString()
                };

                root.AddChild(item);
            }

            Profiler.EndSample();

            return(root);
        }