WebBrowserInputSample.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace Unity.RenderStreaming.Samples
  4. {
  5. class WebBrowserInputSample : MonoBehaviour
  6. {
  7. [SerializeField] SignalingManager renderStreaming;
  8. [SerializeField] Dropdown dropdownCamera;
  9. [SerializeField] Transform[] cameras;
  10. [SerializeField] CopyTransform copyTransform;
  11. RenderStreamingSettings settings;
  12. private void Awake()
  13. {
  14. settings = SampleManager.Instance.Settings;
  15. }
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. dropdownCamera.onValueChanged.AddListener(OnChangeCamera);
  20. if (renderStreaming.runOnAwake)
  21. return;
  22. if (settings != null)
  23. renderStreaming.useDefaultSettings = settings.UseDefaultSettings;
  24. if (settings?.SignalingSettings != null)
  25. renderStreaming.SetSignalingSettings(settings.SignalingSettings);
  26. renderStreaming.Run();
  27. }
  28. void OnChangeCamera(int value)
  29. {
  30. copyTransform.SetOrigin(cameras[value]);
  31. }
  32. }
  33. }