// for use when the size changes public void ReInitialize(Color32[] pixels) { if (!m_BlueJobHandle.IsCompleted) { m_BlueJobHandle.Complete(); } if (m_SharedPixelBuffer == null) { m_SharedPixelBuffer = GetComponent <SharedPixelBuffer32>(); } m_SharedPixelBuffer.Initialize(pixels); m_SharedPixelBuffer.RegisterOnGetPixelBufferAction(FinishJobs); }
void OnEnable() { m_Data = new Color32[m_WebcamTextureSize.x * m_WebcamTextureSize.y]; m_SharedPixelBuffer.Initialize(m_Data); if (m_WebcamIndex >= WebCamTexture.devices.Length) { m_WebcamIndex = WebCamTexture.devices.Length - 1; } m_CamDevice = WebCamTexture.devices[m_WebcamIndex]; m_CamTexture = new WebCamTexture(m_CamDevice.name, m_WebcamTextureSize.x, m_WebcamTextureSize.y); Renderer renderer = GetComponent <Renderer>(); renderer.material.mainTexture = m_CamTexture; m_DynamicTexture = new Texture2D(m_WebcamTextureSize.x, m_WebcamTextureSize.y, TextureFormat.RGBA32, false); m_TargetRenderer.material.mainTexture = m_DynamicTexture; m_CamTexture.Play(); }