protected void LateUpdate() { bool needSendCommand = false; if (m_AsyncGPUReadbackRequest.done) { if (!m_AsyncGPUReadbackRequest.hasError) { Unity.Collections.NativeArray <RoleResult> resultBuffers = m_AsyncGPUReadbackRequest.GetData <RoleResult>(); resultBuffers.CopyTo(m_RoleResults); for (int iResult = 0; iResult < m_RoleResults.Length; ++iResult) { if (m_RoleResults[iResult].IsArrival == INT_TRUE) { m_RoleCommands[iResult].MoveTo = RandPositionOnGround(); needSendCommand = true; } } } else { Debug.LogError("AsyncGPUReadback Error"); } m_AsyncGPUReadbackRequest = UnityEngine.Rendering.AsyncGPUReadback.Request(m_CB_RoleResult); } if (needSendCommand) { m_CB_RoleCommand.SetData(m_RoleCommands); } MovementComputeShader.SetFloat(SHADER_PROPERTYID_DELTATIME, Time.deltaTime); MovementComputeShader.Dispatch(m_CS_UpdateKernel, RoleCount, 1, 1); Draw(MainCamera); }
public void CopyFrom(NativeArray <T> array) { array.CopyTo(this); }