Exemplo n.º 1
0
 internal static void ResetGlobals()
 {
     s_AllUserCount           = 0;
     s_AllUsers               = null;
     s_AllUserData            = null;
     s_AllDeviceCount         = 0;
     s_AllDevices             = null;
     s_OnChange               = new InlinedArray <Action <IInputUser, InputUserChange> >();
     s_OnUnassignedDeviceUsed = new InlinedArray <Action <IInputUser, InputAction, InputControl> >();
     s_OnActionTriggered      = null;
 }
Exemplo n.º 2
0
        // Notify observers that we have changed state.
        private void CallListeners(ref InlinedArray <InputActionListener> listeners)
        {
            // Should always have a control that triggered the state change.
            Debug.Assert(m_LastTrigger.control != null);

            if (listeners.firstValue == null)
            {
                return;
            }

            IInputActionModifier modifier = null;
            var startTime = 0.0;

            if (m_LastTrigger.modifierIndex != -1)
            {
                var modifierState = m_ResolvedBindings[m_LastTrigger.bindingIndex].modifiers[m_LastTrigger.modifierIndex];
                modifier  = modifierState.modifier;
                startTime = modifierState.startTime;
            }

            // We store the relevant state directly on the context instead of looking it
            // up lazily on the action to shield the context from value changes. This prevents
            // surprises on the caller side (e.g. in tests).
            var context = new CallbackContext
            {
                m_Action    = this,
                m_Control   = m_LastTrigger.control,
                m_Time      = m_LastTrigger.time,
                m_Modifier  = modifier,
                m_StartTime = startTime
            };

            #if ENABLE_PROFILER
            Profiler.BeginSample("InputActionCallback");
            #endif

            listeners.firstValue(context);
            if (listeners.additionalValues != null)
            {
                for (var i = 0; i < listeners.additionalValues.Length; ++i)
                {
                    listeners.additionalValues[i](context);
                }
            }

            #if ENABLE_PROFILER
            Profiler.EndSample();
            #endif
        }
Exemplo n.º 3
0
    public void Utilities_InlinedArray_CanRemoveElementAtIndex(int count, int removeAt)
    {
        var comparisonList = new List <string>();
        var array          = new InlinedArray <string>();

        for (var i = 0; i < count; ++i)
        {
            comparisonList.Add(i.ToString());
            array.Append(i.ToString());
        }

        Assert.That(array.length, Is.EqualTo(comparisonList.Count));

        array.RemoveAt(removeAt);
        comparisonList.RemoveAt(removeAt);

        Assert.That(array, Is.EquivalentTo(comparisonList));
    }
        private void DrawControlTree()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Label("Controls", GUILayout.MinWidth(100), GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();

            // Allow plugins to add toolbar buttons.
            for (var i = 0; i < s_OnToolbarGUIActions.length; ++i)
            {
                s_OnToolbarGUIActions[i](m_Device);
            }

            if (GUILayout.Button(Contents.stateContent, EditorStyles.toolbarButton))
            {
                var window = CreateInstance <InputStateWindow>();
                window.InitializeWithControl(m_Device);
                window.Show();
            }

            GUILayout.EndHorizontal();

            ////TODO: detect if dynamic is disabled and fall back to fixed
            var updateTypeToShow = EditorApplication.isPlaying ? InputUpdateType.Dynamic : InputUpdateType.Editor;

            try
            {
                // Switch to buffers that we want to display in the control tree.
                InputStateBuffers.SwitchTo(InputSystem.s_Manager.m_StateBuffers, updateTypeToShow);

                ////REVIEW: I'm not sure tree view needs a scroll view or whether it does that automatically
                m_ControlTreeScrollPosition = EditorGUILayout.BeginScrollView(m_ControlTreeScrollPosition);
                var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandHeight(true));
                m_ControlTree.OnGUI(rect);
                EditorGUILayout.EndScrollView();
            }
            finally
            {
                // Switch back to editor buffers.
                InputStateBuffers.SwitchTo(InputSystem.s_Manager.m_StateBuffers, InputUpdateType.Editor);
            }
        }
        public void ContinueWithDataFrom(InputActionMapState state)
        {
            totalMapCount         = state.totalMapCount;
            totalActionCount      = state.totalActionCount;
            totalBindingCount     = state.totalBindingCount;
            totalInteractionCount = state.totalInteractionCount;
            totalProcessorCount   = state.totalProcessorCount;
            totalCompositeCount   = state.totalCompositeCount;
            totalControlCount     = state.totalControlCount;
            totalDeviceCount      = state.totalDeviceCount;

            maps                       = state.maps;
            mapIndices                 = state.mapIndices;
            actionStates               = state.triggerStates;
            bindingStates              = state.bindingStates;
            interactionStates          = state.interactionStates;
            interactions               = state.interactions;
            processors                 = state.processors;
            composites                 = state.composites;
            controls                   = state.controls;
            devices                    = state.devices;
            controlIndexToBindingIndex = state.controlIndexToBindingIndex;
        }
Exemplo n.º 6
0
 public void Reset()
 {
     pointerTarget = null;
     hoverTargets  = new InlinedArray <GameObject>();
 }