protected override void SetupUI() { base.SetupUI(); Dropdown dropdown = GameObject.Find("Dropdown").GetComponent <Dropdown>(); if (dropdown != null) { #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX WindowList list = AgoraNativeBridge.GetMacWindowList(); if (list != null) { dropdown.options = list.windows.Select(w => new Dropdown.OptionData(w.kCGWindowOwnerName + "|" + w.kCGWindowNumber)).ToList(); } GameObject.Find("InputField").SetActive(false); GameObject.Find("WinHelpButton").SetActive(false); #else dropdown.gameObject.SetActive(false); inputField = GameObject.Find("InputField").GetComponent <InputField>(); #endif WindowOptionDropdown = dropdown; } Button button = GameObject.Find("ShareWindowButton").GetComponent <Button>(); if (button != null) { button.onClick.AddListener(OnShareWindowClick); } button = GameObject.Find("ShareDisplayButton").GetComponent <Button>(); if (button != null) { button.onClick.AddListener(ShareDisplayScreen); } button = GameObject.Find("StopShareButton").GetComponent <Button>(); if (button != null) { button.onClick.AddListener(() => { mRtcEngine.StopScreenCapture(); }); } GameObject quad = GameObject.Find("DisplayPlane"); if (ReferenceEquals(quad, null)) { Debug.Log("Error: failed to find DisplayPlane"); return; } else { quad.AddComponent <VideoSurface>(); } }
uint getDisplayId(int k) { #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX List <uint> ids = AgoraNativeBridge.GetMacDisplayIds(); #else List <uint> ids = new List <uint>(); #endif if (k < ids.Count) { return(ids[k]); } return(0); }
private void PrepareScreenCapture() { _winIdSelect = GameObject.Find("winIdSelect").GetComponent <Dropdown>(); if (_winIdSelect != null) { _winIdSelect.ClearOptions(); #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX var macDispIdList = AgoraNativeBridge.GetMacDisplayIds(); if (macDispIdList != null) { _winIdSelect.AddOptions(macDispIdList.Select(w => new Dropdown.OptionData( string.Format("Display {0}", w))).ToList()); } var macWinIdList = AgoraNativeBridge.GetMacWindowList(); if (macWinIdList != null) { _winIdSelect.AddOptions(macWinIdList.windows.Select(w => new Dropdown.OptionData( string.Format("{0, -20} | {1}", w.kCGWindowOwnerName, w.kCGWindowNumber))) .ToList()); } #elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN var winDispInfoList = AgoraNativeBridge.GetWinDisplayInfo(); if (winDispInfoList != null) { foreach (var dpInfo in winDispInfoList) { _dispRect.Add(dpInfo.MonitorInfo.flags, dpInfo.MonitorInfo.monitor); } _winIdSelect.AddOptions(winDispInfoList.Select(w => new Dropdown.OptionData( string.Format("Display {0}", w.MonitorInfo.flags))).ToList()); } Dictionary <string, IntPtr> winWinIdList; AgoraNativeBridge.GetDesktopWindowHandlesAndTitles(out winWinIdList); if (winWinIdList != null) { _winIdSelect.AddOptions(winWinIdList.Select(w => new Dropdown.OptionData(string.Format("{0, -20} | {1}", w.Key.Substring(0, Math.Min(w.Key.Length, 20)), w.Value))).ToList()); } #endif } _startShareBtn = GameObject.Find("startShareBtn").GetComponent <Button>(); _stopShareBtn = GameObject.Find("stopShareBtn").GetComponent <Button>(); if (_startShareBtn != null) { _startShareBtn.onClick.AddListener(OnStartShareBtnClick); } if (_stopShareBtn != null) { _stopShareBtn.onClick.AddListener(OnStopShareBtnClick); _stopShareBtn.gameObject.SetActive(false); } }
protected override void SetupUI() { base.SetupUI(); Dropdown dropdown = GameObject.Find("Dropdown").GetComponent <Dropdown>(); if (dropdown != null) { #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX MacDisplays = AgoraNativeBridge.GetMacDisplayIds(); WindowList list = AgoraNativeBridge.GetMacWindowList(); if (list != null) { dropdown.options = list.windows.Select(w => new Dropdown.OptionData(w.kCGWindowOwnerName + " | " + w.kCGWindowNumber)).ToList(); } #elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN // Monitor Display info var winDispInfoList = AgoraNativeBridge.GetWinDisplayInfo(); if (winDispInfoList != null) { foreach (var dpInfo in winDispInfoList) { WinDisplays.Add(dpInfo.MonitorInfo.monitor); } } // Window ID info Dictionary <string, System.IntPtr> winWinIdList; AgoraNativeBridge.GetDesktopWindowHandlesAndTitles(out winWinIdList); if (winWinIdList != null) { dropdown.options = (winWinIdList.Select(w => new Dropdown.OptionData(string.Format("{0, -20} | {1}", w.Key.Substring(0, System.Math.Min(w.Key.Length, 20)), w.Value))).ToList()); } #endif WindowOptionDropdown = dropdown; } Button button = GameObject.Find("ShareWindowButton").GetComponent <Button>(); if (button != null) { button.onClick.AddListener(OnShareWindowClick); } button = GameObject.Find("ShareDisplayButton").GetComponent <Button>(); if (button != null) { button.onClick.AddListener(ShareDisplayScreen); } button = GameObject.Find("StopShareButton").GetComponent <Button>(); if (button != null) { button.onClick.AddListener(() => { mRtcEngine.StopScreenCapture(); }); } GameObject quad = GameObject.Find("DisplayPlane"); if (ReferenceEquals(quad, null)) { Debug.Log("Error: failed to find DisplayPlane"); return; } else { quad.AddComponent <VideoSurface>(); } }