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 m_Events = m_EventTrace.ToArray(); Array.Sort(m_Events, (a, b) => { var aId = a.id; var bId = b.id; if (aId > bId) { return(-1); } if (aId < bId) { return(1); } return(0); }); if (m_Events.Length == 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 < m_Events.Length; ++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); }
public unsafe void Events_CanGetStatePointerFromEventThroughControl_EvenIfDeviceIsStateCallbackReceiver() { var touchscreen = InputSystem.AddDevice <Touchscreen>(); using (var trace = new InputEventTrace { deviceId = touchscreen.deviceId }) { trace.Enable(); BeginTouch(1, new Vector2(123, 234)); var statePtr = touchscreen.primaryTouch.position.GetStatePtrFromStateEvent(trace.ToArray()[0]); Assert.That(statePtr != null); // Attempt reading the position value from the touch event. Assert.That(touchscreen.primaryTouch.position.ReadValueFromState(statePtr), Is.EqualTo(new Vector2(123, 234)).Using(Vector2EqualityComparer.Instance)); // It only works with primaryTouch. See Touchscreen.GetStateOffsetForEvent for details. Assert.That(touchscreen.touches[1].position.GetStatePtrFromStateEvent(trace.ToArray()[0]) == null); } }