/// <summary> /// Steal the already allocated arrays from the given state. /// </summary> /// <param name="state">Action map state that was previously created.</param> /// <param name="isFullResolve">If false, the only thing that is allowed to change in the re-resolution /// is the list of controls. In other words, devices may have been added or removed but otherwise the configuration /// is exactly the same as in the last resolve. If true, anything may have changed and the resolver will only reuse /// allocations but not contents.</param> public void StartWithPreviousResolve(InputActionState state, bool isFullResolve) { Debug.Assert(state != null, "Received null state"); Debug.Assert(!state.isProcessingControlStateChange, "Cannot re-resolve bindings for an InputActionState that is currently executing an action callback; binding resolution must be deferred to until after the callback has completed"); m_IsControlOnlyResolve = !isFullResolve; maps = state.maps; interactions = state.interactions; processors = state.processors; composites = state.composites; controls = state.controls; // Clear the arrays so that we don't leave references around. if (isFullResolve) { if (maps != null) { Array.Clear(maps, 0, state.totalMapCount); } if (interactions != null) { Array.Clear(interactions, 0, state.totalInteractionCount); } if (processors != null) { Array.Clear(processors, 0, state.totalProcessorCount); } if (composites != null) { Array.Clear(composites, 0, state.totalCompositeCount); } } if (controls != null) // Always clear this one as every resolve will change it. { Array.Clear(controls, 0, state.totalControlCount); } // Null out the arrays on the state so that there is no strange bugs with // the state reading from arrays that no longer belong to it. state.maps = null; state.interactions = null; state.processors = null; state.composites = null; state.controls = null; }
/// <summary> /// Steal the already allocated arrays from the given state. /// </summary> /// <param name="state">Action map state that was previously created.</param> /// <remarks> /// This is useful to avoid allocating new arrays from scratch when re-resolving bindings. /// </remarks> public void StartWithArraysFrom(InputActionState state) { Debug.Assert(state != null); maps = state.maps; interactions = state.interactions; processors = state.processors; composites = state.composites; controls = state.controls; // Clear the arrays so that we don't leave references around. if (maps != null) { Array.Clear(maps, 0, state.totalMapCount); } if (interactions != null) { Array.Clear(interactions, 0, state.totalInteractionCount); } if (processors != null) { Array.Clear(processors, 0, state.totalProcessorCount); } if (composites != null) { Array.Clear(composites, 0, state.totalCompositeCount); } if (controls != null) { Array.Clear(controls, 0, state.totalControlCount); } // Null out the arrays on the state so that there is no strange bugs with // the state reading from arrays that no longer belong to it. state.maps = null; state.interactions = null; state.processors = null; state.composites = null; state.controls = null; }