bool LoadLiveViewFromComponent(string url, ref ResourceResponseUIGT response) { var liveViewComponent = m_UISystem.LiveGameViewComponents[url]; if (liveViewComponent) { RenderTexture tex = liveViewComponent.SourceTexture; if (tex != null) { ResourceResponseUIGT.UserImageData data = new ResourceResponseUIGT.UserImageData(); data.Width = (uint)tex.width; data.Height = (uint)tex.height; data.ContentRectX = 0; data.ContentRectY = 0; data.ContentRectWidth = (uint)tex.width; data.ContentRectHeight = (uint)tex.height; data.Texture = tex.GetNativeTexturePtr(); if (liveViewComponent.ImageHandle == 0) { liveViewComponent.ImageHandle = m_UISystem.GetNextFreeImageHandle(); } data.ImageHandle = liveViewComponent.ImageHandle; response.ReceiveUserImage(data); return(true); } } Debug.LogError("[Coherent GT] RenderTexture " + url + " not found"); return(false); }
bool TrySetLiveViewTexture() { if (m_TargetView != null && m_TargetView.ViewRenderer != null && m_SourceTexture != null && m_SourceTexture.IsCreated()) { if (m_ImageHandle != 0) { ResourceResponseUIGT.UserImageData data = new ResourceResponseUIGT.UserImageData(); data.ImageHandle = m_ImageHandle; data.Width = (uint)m_Width; data.Height = (uint)m_Height; data.ContentRectX = 0; data.ContentRectY = 0; data.ContentRectWidth = data.Width; data.ContentRectHeight = data.Height; data.Texture = m_SourceTexture.GetNativeTexturePtr(); m_UISystem.UISystem.ReplaceUserImage(data); CoherentUIGTRenderEvents.SendRenderEvent( CoherentRenderEventType.SetLiveViewTexture, m_TargetView.View.GetId()); } return(true); } return(false); }
void UnsetLiveViewTexture() { ResourceResponseUIGT.UserImageData data = new ResourceResponseUIGT.UserImageData(); data.ImageHandle = m_ImageHandle; data.Width = 0; data.Height = 0; data.ContentRectX = 0; data.ContentRectY = 0; data.ContentRectWidth = 0; data.ContentRectHeight = 0; data.Texture = System.IntPtr.Zero; m_UISystem.UISystem.ReplaceUserImage(data); CoherentUIGTRenderEvents.SendRenderEvent( CoherentRenderEventType.SetLiveViewTexture, m_TargetView.View.GetId()); }
bool LoadPreloadedImage(string texturePath, ref ResourceResponseUIGT response) { Texture tex = Resources.Load <Texture>(texturePath); if (tex != null) { ResourceResponseUIGT.UserImageData data = new ResourceResponseUIGT.UserImageData(); data.Width = (uint)tex.width; data.Height = (uint)tex.height; data.ContentRectX = 0; data.ContentRectY = 0; data.ContentRectWidth = (uint)tex.width; data.ContentRectHeight = (uint)tex.height; data.Texture = tex.GetNativeTexturePtr(); data.ImageHandle = 0; // PreloadedImages should use ImageHandle = 0 m_UISystem.AddPreloadedImageTextureAsset(ref tex); response.ReceiveUserImage(data); return(true); } Debug.LogError("[Coherent GT] Texture asset " + texturePath + " not found"); return(false); }