private void OnUserJoined(uint uid, int elapsed) { Debug.Log("New user has joined channel with id: " + uid); GameObject go = GameObject.CreatePrimitive(PrimitiveType.Plane); go.name = uid.ToString(); VideoSurface o = go.AddComponent <VideoSurface>(); o.SetForUser(uid); //o.mAdjustTransfrom += OnTransformDelegate; o.SetEnable(true); o.transform.Rotate(-90.0f, 0.0f, 0.0f); float r = Random.Range(-5.0f, 5.0f); o.transform.position = new Vector3(0f, r, 0f); o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f); mRemotePeer = uid; /*Debug.Log("new person join channel " + " " + uid); * GameObject go; * go = GameObject.CreatePrimitive(PrimitiveType.Plane); * go.name = uid.ToString(); * VideoSurface o = go.AddComponent<VideoSurface>(); * o.SetForUser(uid); * o.mAdjustTransfrom += OnTransformDelegate; * o.SetEnable(true); * o.transform.Rotate(-90.0f, 0.0f, 0.0f); * float r = Random.Range(-5.0f, 5.0f); * o.transform.position = new Vector3(0f, r, 0f); * o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f); * mRemotePeer = uid; */ }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on it protected virtual void OnUserJoined(uint uid, int elapsed) { Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed); // find a game object to render video stream from 'uid' GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } // create a GameObject and assign to this new user VideoSurface videoSurface = makeImageSurface(uid.ToString()); if (!ReferenceEquals(videoSurface, null)) { // configure videoSurface videoSurface.SetForUser(uid); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(30); videoSurface.EnableFilpTextureApply(enableFlipHorizontal: true, enableFlipVertical: false); UserVideoDict[uid] = videoSurface; Vector2 pos = AgoraUIUtils.GetRandomPosition(100); videoSurface.transform.localPosition = new Vector3(pos.x, pos.y, 0); } }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on it private void onUserJoined(uint uid, int elapsed) { Debug.Log("onUserJoined: uid = " + uid); // this is called in main thread // find a game object to render video stream from 'uid' GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } numUsers++; // create a GameObject and assigne to this new user go = GameObject.CreatePrimitive(PrimitiveType.Plane); if (!ReferenceEquals(go, null)) { go.name = uid.ToString(); // configure videoSurface VideoSurface o = go.AddComponent <VideoSurface>(); o.SetForUser(uid); //o.mAdjustTransfrom += onTransformDelegate; /// o.SetEnable(true); o.transform.Rotate(-90.0f, 180.0f, 0.0f); //float r = Random.Range (-5.0f, 5.0f); /// var videoQuadPos = GameObject.Find("VideoSpawn").transform.position; o.transform.position = videoQuadPos + new Vector3(0, 0, 0); //y wie x o.transform.localScale = new Vector3(0.50f, (0.28125f), (0.50f)); //ohen die 5en 0.09475f 0.5f 0.094924f } // mRemotePeer = uid; }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on it private void onUserJoined(uint uid, int elapsed) { Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed); // this is called in main thread // find a game object to render video stream from 'uid' GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } // create a GameObject and assign to this new user VideoSurface videoSurface = makeImageSurface(uid.ToString()); if (!ReferenceEquals(videoSurface, null)) { // configure videoSurface videoSurface.SetForUser(uid); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(30); } }
public void showRemoteVideo(uint uid) { clearRemoteVideo(); if (remoteVideoObject != null) { VideoSurface videoSurface = remoteVideoObject.AddComponent <VideoSurface>() as VideoSurface; if (videoSurface != null) { videoSurface.SetForUser(uid); //videoSurface.SetEnable(true); if (isRemoteVideo3D) { videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.Renderer); } else { videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); } //videoSurface.SetGameFps(30); } } else { Debug.LogWarning("Cannot show remote video because remoteVideoObject is null!"); } }
public void showLocalVideo() { clearLocalVideo(); if (localVideoObject != null) { VideoSurface videoSurface = localVideoObject.AddComponent <VideoSurface>() as VideoSurface; if (videoSurface != null) { videoSurface.SetForUser(0); //0 is for local user //videoSurface.SetEnable(true); if (isLocalVideo3D) { videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.Renderer); } else { videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); } //videoSurface.SetGameFps(30); } } else { Debug.LogWarning("Cannot show local video because localVideoObject is null!"); } }
private void onUserJoined(uint uid, int elapsed) { Debug.Log("onUserJoined: uid = " + uid); // this is called in main thread // find a game object to render video stream from 'uid' GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } // create a GameObject and assigne to this new user go = GameObject.CreatePrimitive(PrimitiveType.Plane); if (!ReferenceEquals(go, null)) { go.name = uid.ToString(); // configure videoSurface VideoSurface o = go.AddComponent <VideoSurface> (); o.SetForUser(uid); o.mAdjustTransfrom += onTransformDelegate; o.SetEnable(true); o.transform.Rotate(-90.0f, 0.0f, 0.0f); float r = Random.Range(-5.0f, 5.0f); o.transform.position = new Vector3(0f, r, 0f); o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f); } mRemotePeer = uid; }
private void OnUserJoined(uint uid, int elapsed) { Debug.Log("New user has joined channel with id" + uid); // add remote stream to scene // create game object GameObject go; go = GameObject.CreatePrimitive(PrimitiveType.Plane); go.name = uid.ToString(); // configure video surface VideoSurface o = go.AddComponent <VideoSurface>(); o.SetForUser(uid); o.mAdjustTransform += OnTransformDelegate; o.SetEnable(true); o.transform.Rotate(-90.0f, 0.0f, 0.0f); float r = Random.Range(-5.0f, 5.0f); o.transform.position = new Vector3(0f, r, 0f); o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f); mRemotePeer = uid; }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on it private void onUserJoined(uint uid, int elapsed) { Debug.LogError("onUserJoined: uid = " + uid); // this is called in main thread // find a game object to render video stream from 'uid' GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } // create a GameObject and assigne to this new user go = GameObject.CreatePrimitive(PrimitiveType.Cube); if (!ReferenceEquals(go, null)) { go.name = uid.ToString(); // configure videoSurface VideoSurface o = go.AddComponent <VideoSurface>(); o.SetForUser(uid); o.SetEnable(true); o.transform.Rotate(-90.0f, 0.0f, 0.0f); o.transform.position = getNextCubePosition(); o.transform.localScale = Vector3.one; } OnEnable(); }
void OnUserJoinedHandler(uint uid, int elapsed) { Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed); // find a game object to render video stream from 'uid' GameObject go = GameObject.Find(uid.ToString()); if (go != null) { return; } // create a GameObject and assign to this new user VideoSurface videoSurface = makeImageSurface(uid.ToString()); if (videoSurface != null) { // configure videoSurface videoSurface.SetForUser(uid); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(30); } usersInChannel++; }
private void OnUserJoined(uint uid, int elapsed) { // Debug.Log("New User has joined the channel"); videoSurface.SetActive(true); videoSurface.name = uid.ToString(); VideoSurface o = videoSurface.GetComponent <VideoSurface>(); o.SetForUser(uid); o.SetEnable(true); mRemotePeer = uid; }
private void onJoinChannelSuccess(string channelName, uint uid, int elapsed) { Debug.Log("JoinChannelSuccessHandler: uid = " + uid); GameObject textVersionGameObject = GameObject.Find("VersionText"); textVersionGameObject.GetComponent <Text> ().text = "Version : " + getSdkVersion(); GameObject go1, go2, go3, go4; GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } go1 = GameObject.Find("Cylinder"); go2 = GameObject.Find("Cylinder2"); go3 = GameObject.Find("Cylinder3"); go4 = GameObject.Find("Cylinder4"); go2.GetComponent <Renderer>().enabled = false; go3.GetComponent <Renderer>().enabled = false; go4.GetComponent <Renderer>().enabled = false; GameObject go1_cp = new GameObject(); go1_cp = Instantiate(go1); go1_cp.GetComponent <Renderer>().enabled = true; go1.name = "C_" + uid.ToString(); go1_cp.name = uid.ToString(); anf = uid; go = go1_cp; if (!ReferenceEquals(go, null)) { go.name = uid.ToString(); // configure videoSurface VideoSurface o = go.GetComponent <VideoSurface> (); o.SetForUser(uid); o.SetEnable(true); } }
void OnUserJoined(uint uid, int elapsed) { GameObject go = GameObject.Find("RemoteView"); if (remoteView == null) { remoteView = go.AddComponent <VideoSurface>(); } remoteView.SetForUser(uid); remoteView.SetEnable(true); remoteView.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); remoteView.SetGameFps(30); }
private void OnUserJoined(uint uid, int elapsed) { print("user joined"); remoteVideo.name = uid.ToString(); VideoSurface videoSurface = makeImageSurface(uid.ToString()); if (!ReferenceEquals(videoSurface, null)) { videoSurface.SetForUser(uid); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(30); } }
// Create new image plane to display users in party. private void CreateUserVideoSurface(uint uid, bool isLocalUser) { // Avoid duplicating Local player VideoSurface image plane. for (int i = 0; i < playerVideoList.Count; i++) { if (playerVideoList[i].name == uid.ToString()) { return; } } // Get the next position for newly created VideoSurface to place inside UI Container. float spawnY = playerVideoList.Count * spaceBetweenUserVideos; Vector3 spawnPosition = new Vector3(0, -spawnY, 0); // Create Gameobject that will serve as our VideoSurface. GameObject newUserVideo = Instantiate(userVideoPrefab, spawnPosition, spawnPoint.rotation); if (newUserVideo == null) { Debug.LogError("CreateUserVideoSurface() - newUserVideoIsNull"); return; } newUserVideo.name = uid.ToString(); newUserVideo.transform.SetParent(spawnPoint, false); newUserVideo.transform.rotation = Quaternion.Euler(Vector3.right * -180); playerVideoList.Add(newUserVideo); // Update our VideoSurface to reflect new users VideoSurface newVideoSurface = newUserVideo.GetComponent <VideoSurface>(); if (newVideoSurface == null) { Debug.LogError("CreateUserVideoSurface() - VideoSurface component is null on newly joined user"); return; } if (isLocalUser == false) { newVideoSurface.SetForUser(uid); } newVideoSurface.SetGameFps(30); // Update our "Content" container that holds all the newUserVideo image planes content.sizeDelta = new Vector2(0, playerVideoList.Count * spaceBetweenUserVideos + 140); UpdatePlayerVideoPostions(); UpdateLeavePartyButtonState(); }
protected override void OnUserJoined(uint uid, int elapsed) { hostCount++; if (hostCount == 2) { host2.SetForUser(uid); host2.SetEnable(true); RemoteUID = uid; } else { return; } }
// Start is called before the first frame update void Start() { VideoSurface vo = GetComponent <VideoSurface>(); if (ReferenceEquals(vo, null)) { Debug.Log("cant find VO"); } else { Debug.Log("VO found and initialized"); vo.SetForUser(0); vo.SetEnable(true); } }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on itRecallController.GetInstanse private void onUserJoined(uint uid, int elapsed) { success = true; Debug.Log("agora_:" + "onUserJoined: uid = " + uid); // this is called in main thread RecallController.GetInstanse.StopWaytingDialog(); // find a game object to render video stream from 'uid' GameObject go = RecallController.GetInstanse.GetRemote; go.SetActive(true); VideoSurface o = go.AddComponent <VideoSurface> (); o.SetForUser(uid); o.SetEnable(true); mRemotePeer = uid; }
private void onUserJoined(uint uid, int elapsed) { Debug.Log("onUserJoined"); GameObject go = GameObject.Find("other"); // go.name = uid.ToString(); VideoSurface o = go.AddComponent <VideoSurface>(); o.SetForUser(uid); o.SetEnable(true); // o.transform.Rotate(-90, 0, 0); //o.transform.localScale = new Vector3(1, 1, 1); mRemotePeer = uid; }
void CreateNewUserVideoFrame(uint newUserUid) { if (photonView.isMine) { userCount++; GameObject newUserVideo = Instantiate(videoSurfacePrefab, transform.GetChild(1)); newUserVideo.GetComponent <RectTransform>().anchoredPosition += Vector2.right * 120 * userCount; VideoSurface videoControls = newUserVideo.GetComponent <VideoSurface>(); videoControls.SetForUser(newUserUid); videoControls.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoControls.SetEnable(true); } }
void OnUserJoinedHandler(uint uid, int elapsed) { logger.UpdateLog(string.Format("OnUserJoined uid: ${0} elapsed: ${1}", uid, elapsed)); GameObject go = Instantiate(userPrefab); RemoteUserObject[uid] = go; go.transform.SetParent(rootSpace); go.transform.localScale = Vector3.one; go.transform.localPosition = new Vector3(userCount * 2, 0, 0); VideoSurface v = go.AddComponent <VideoSurface>(); v.SetForUser(uid); v.SetEnable(true); v.SetVideoSurfaceType(AgoraVideoSurfaceType.Renderer); userCount++; }
// Create new image plane to display users in party. private void CreateUserVideoSurface(uint uid, bool isLocalUser) { // Avoid duplicating Local player VideoSurface image plane. for (int i = 0; i < playerVideoList.Count; i++) { if (playerVideoList[i].name == uid.ToString()) { return; } } // Create Gameobject that will serve as our VideoSurface. GameObject newUserVideo = GameObject.CreatePrimitive(PrimitiveType.Cube); if (newUserVideo == null) { Debug.LogError("CreateUserVideoSurface() - newUserVideoIsNull"); return; } newUserVideo.transform.localScale = Vector3.one * 3; newUserVideo.name = uid.ToString(); playerVideoList.Add(newUserVideo); // this is because we are using 4 spawn points per room if (playerVideoList.Count < 5) { newUserVideo.transform.position = spawnPointLocations[playerVideoList.Count - 1].position; } // Update our VideoSurface to reflect new users VideoSurface newVideoSurface = newUserVideo.AddComponent <VideoSurface>(); if (newVideoSurface == null) { Debug.LogError("CreateUserVideoSurface() - VideoSurface component is null on newly joined user"); return; } if (isLocalUser == false) { newVideoSurface.SetForUser(uid); } newVideoSurface.SetGameFps(30); }
void VideoImageClicked(string name) { if (bigPicTemp != null) { if (bigPicTemp.name == name) { removeObserver(uint.Parse(name)); AddObserver(uint.Parse(name)); } RemoveBig(); } else { GameObject go = null; for (int i = 0; i < allObserver.Count; i++) { if (allObserver[i].name == name) { go = allObserver[i]; break; } Debug.Log(name); } if (go != null) { VideoSurface video1 = go.GetComponent <VideoSurface>(); DestroyImmediate(video1); } bigPicTemp = Instantiate(bigPic); bigPicTemp.name = name; bigPicTemp.transform.parent = bkaVideoParent; bigPicTemp.GetComponent <RectTransform>().SetAsFirstSibling(); bigPicTemp.transform.localScale = new Vector3(1, -1, 1); bigPicTemp.SetActive(true); VideoSurface videoSurface = bigPicTemp.AddComponent <VideoSurface>(); videoSurface.resize = true; videoSurface.expert = isExpert; // configure videoSurface videoSurface.SetForUser(uint.Parse(name)); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(25); } }
VideoSurface CreateUserVideoSurface(uint uid, Vector3 spawnPosition, bool isLocalUser) { if (!pView.isMine) { print("Photon view isn't mine: " + gameObject.name); return(null); } GameObject newUserVideo = new GameObject(uid.ToString(), typeof(RawImage), typeof(VideoSurface)); if (newUserVideo == null) { print("new user video <GAMEOBJECT> couldn't be created: " + gameObject.name); return(null); } newUserVideo.transform.parent = transform.GetChild(0); newUserVideo.GetComponent <RectTransform>().anchoredPosition = spawnPosition + (Vector3.right * currentUsers * newVideoFrameOffsetAmount); newUserVideo.GetComponent <RectTransform>().sizeDelta = new Vector2(120, 120); newUserVideo.transform.rotation = Quaternion.Euler(Vector3.right * -180); newUserVideo.transform.localScale = Vector3.one; VideoSurface newVideoSurface = newUserVideo.GetComponent <VideoSurface>(); if (newVideoSurface == null) { print("new user video <VIDEOSURFACE> couldn't be created: " + gameObject.name); return(null); } if (isLocalUser == false) { newVideoSurface.SetForUser(uid); } print(gameObject.name + " creating new video surface for: " + uid); newVideoSurface.SetGameFps(30); currentUsers++; return(newVideoSurface); }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on it private void onUserJoined(uint uid, int elapsed) { success = true; //Debug.Log ("agora_:"+"onUserJoined: uid = " + uid); // this is called in main thread // find a game object to render video stream from 'uid' GameObject go = DisplayCamManager.GetInstance.GetRemote; //Debug.Log("agora_:" + "onUserJoined: GEted GO "); go.SetActive(true); VideoSurface o = go.AddComponent <VideoSurface> (); //Debug.Log("agora_:" + "onUserJoined:Video Surface Added"); o.SetForUser(uid); o.SetEnable(true); mRemotePeer = uid; //Debug.Log("agora_:" + "onUserJoined:Video Surface set video"); }
// When a remote user joined, this delegate will be called. Typically // create a GameObject to render video on it private void onUserJoined(uint uid, int elapsed) { Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed); if (remoteUserOnline) { return; } GameObject gameObject = GameObject.Find("RemoteImage"); if (gameObject != null) { VideoSurface videoSurface = gameObject.GetComponent <VideoSurface>(); if (videoSurface == null) { videoSurface = gameObject.AddComponent <VideoSurface>(); } videoSurface.SetForUser(uid); } }
private void makeVideoView(uint uid) { GameObject go = GameObject.Find(uid.ToString()); if (!ReferenceEquals(go, null)) { return; // reuse } // create a GameObject and assign to this new user VideoSurface videoSurface = makeImageSurface(uid.ToString()); if (!ReferenceEquals(videoSurface, null)) { // configure videoSurface videoSurface.SetForUser(uid); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(30); } }
IEnumerator SetupVideoSurface(TanksNetworkPlayer player) { Debug.Log("Tank initializing player:" + player); yield return(new WaitForFixedUpdate()); if (player.hasAuthority) { // doesn't seem necessary // DisableShooting(); } player.CmdSetReady(); if (videoSurface == null) { videoSurface = RenderObject.AddComponent <VideoSurface>(); } if (player.isLocalPlayer) { if (videoSurface != null) { videoSurface.gameObject.name = LocalTankVideoName; } } else { uint uid = AgoraPlayerController.instance.GetAgoraID(player); Debug.LogFormat("Tank player {0}: Found agora uid for player ------> {1} ", player, uid); if (uid != 0 && videoSurface != null) { videoSurface.gameObject.name = string.Format("video-{0}", uid); videoSurface.SetForUser(uid); } else { Debug.Assert(uid != 0, "Couldn't find uid for player:" + player.playerId); AgoraPlayerController.instance.Print(); Debug.Assert(videoSurface != null, "videoSurface = null"); } } }
public void AddObserver(uint uid) { GameObject go = Instantiate(prefab); go.name = uid.ToString(); go.transform.parent = transform; go.transform.localScale = new Vector3(1, -1, 1);// Vector3.one; go.GetComponent <Button>().onClick.AddListener(delegate { VideoImageClicked(go.name); }); // set up transform VideoSurface videoSurface = go.AddComponent <VideoSurface>(); // configure videoSurface videoSurface.SetForUser(uid); videoSurface.SetEnable(true); videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage); videoSurface.SetGameFps(25); allObserver.Add(go); //更新大小 UpdateSelfSize(allObserver.Count); }
void OnUserJoined(uint uid, int elapsed) { Debug.Log("UIDUIDUIDUIDUIDUIDUIDUIDUIUDIUDIUDIDUIDUIDUIDUIDUIDUIDUIDUIDUIDUIDUIDUIDU: " + uid); //remote stream to scene //create game object GameObject go; go = GameObject.CreatePrimitive(PrimitiveType.Plane); go.name = uid.ToString(); //configure video surface VideoSurface o = go.AddComponent <VideoSurface>(); o.SetForUser(uid); //o.mAdjustTransform += OnTransformDelegate; o.SetEnable(true); //timestamp if it breaks: 26:00 mRemotePeer = uid; }