Unity/μœ λ‹ˆν‹° 포톀(λ„€νŠΈμ›Œν¬)

포톀 λ¬΄λ£Œλ²„μ „ μ‚¬μš©ν•˜κΈ°(1) 포톀 IDλ°›μ•„μ„œ μž„ν¬νŠΈ, 방생성

Rainbow🌈Coder 2022. 1. 4. 10:33
728x90

2022λ…„ κΈ°μ€€μœΌλ‘œ 과거의 λ¬Έμ„œλŒ€λ‘œ λ”°λΌν•˜λ©΄ 포톀이 μ•ˆλ  수 μžˆλ‹€.

ν•΄λ‹Ή 글은 2022λ…„ 1μ›” 4일 κΈ°μ€€μœΌλ‘œ 포톀PUN2κ°€ λŒμ•„κ°€λŠ” 것을 ν™•μΈν•˜κ³  μž‘μ„±ν•˜λŠ” 글이닀.

 

 

μ†Œμˆ˜μ˜ λ©€ν‹°ν”Œλ ˆμ΄μ–΄ κ²Œμž„μ˜ μœ μ €λŠ” 무료 ν¬ν†€μœΌλ‘œ μˆ˜μš©κ°€λŠ₯ν•˜λ‹€.

 

 

μ•„λž˜ 포톀 μ‚¬μ΄νŠΈμ— κ°€μ„œ νšŒμ›κ°€μž…μ„ ν•œ λ‹€μŒμ— μ–΄ν”Œλ¦¬μΌ€μ΄μ…˜ 생성을 λˆ„λ₯΄κ³ 

μ λ‹Ήνžˆ ν”„λ‘œμ νŠΈ 이름을 써주면 IDκ°€ λœ¬λ‹€. 

 

https://www.photonengine.com/ko-KR/Photon

 

κΈ€λ‘œλ²Œ 크둜슀 ν”Œλž«νΌ μ‹€μ‹œκ°„ κ²Œμž„ 개발 | Photon Engine

Cookie Settings Photon uses cookies to identify you as logged-in user, to improve your experience and for marketing. Review and manage your cookie settings below to control your privacy. For more information on how we use cookies and what each cookie stand

www.photonengine.com

μœ λ‹ˆν‹° 에셋링크, λ§ν¬μ—μ„œ 에셋을 λ‹€μš΄λ‘œλ“œ ν›„ μž„ν¬νŠΈ μ‹œμΌœμ€€λ‹€.

μž„ν¬νŠΈ μ‹œν‚¬ λ•Œ IDλ₯Ό μž‘μ„±ν•΄μ€€λ‹€.

 

PUN 2 - FREE | Network | Unity Asset Store

 

PUN 2 - FREE | λ„€νŠΈμ›Œν¬ | Unity Asset Store

Get the PUN 2 - FREE package from Exit Games and speed up your game development process. Find this & other λ„€νŠΈμ›Œν¬ options on the Unity Asset Store.

assetstore.unity.com

μ΅œμ‹  버전 포톀Pun

using Photon.Pun;을 달아주고

public class NetworkManager : MonoBehaviourPunCallbacks
{

}

μ΄λ ‡κ²Œ MonoBehaviourPunCallbacksλ₯Ό 상속해주면 포톀 클래슀의 ν•¨μˆ˜λ“€μ„ μ˜€λ²„λΌμ΄λ”©ν•΄μ„œ μ‚¬μš©ν•  수 μžˆλ‹€.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class NetworkManager : MonoBehaviourPunCallbacks
{

}

포톀 클래슀λ₯Ό 톡해 μ‚¬μš©ν•  수 μžˆλŠ” ν•¨μˆ˜λ“€μ„ λ³Ό 수 μžˆλŠ” κ³΅μ‹λ¬Έμ„œμ΄λ‹€.

포톀 ν™ˆνŽ˜μ΄μ§€μ— μžμŠ΅μ„œκΉŒμ§€ 잘 μž‘μ„±λ˜μ–΄ μžˆμœΌλ‹ˆ

ν•˜λ‚˜μ”© λ”°λΌν•˜λ‹€λ³΄λ©΄ κ·Όμ‚¬ν•œ μ†Œκ·œλͺ¨ λ„€νŠΈμ›Œν¬ κ²Œμž„μ„ λ§Œλ“€ 수 μžˆμ„ 것이닀.

μ†Œκ°œ | κ΄‘μž μ—”μ§„ (photonengine.com)

 

Introduction | Photon Engine

Cookie Settings Photon uses cookies to identify you as logged-in user, to improve your experience and for marketing. Review and manage your cookie settings below to control your privacy. For more information on how we use cookies and what each cookie stand

doc.photonengine.com

 

Photon Unity Networking 2: MonoBehaviourPunCallbacks Class Reference

This class provides a .photonView and all callbacks/events that PUN can call. Override the events/methods you want to use. More... This class provides a .photonView and all callbacks/events that PUN can call. Override the events/methods you want to use. By

doc-api.photonengine.com

κ΄‘μž μœ λ‹ˆν‹° λ„€νŠΈμ›Œν‚Ή 2: λͺ¨λ…Έν–‰λ™νŽ€μ½œλ°± 클래슀 μ°Έμ‘° (photonengine.com)

 

Photon Unity Networking 2: MonoBehaviourPunCallbacks Class Reference

This class provides a .photonView and all callbacks/events that PUN can call. Override the events/methods you want to use. More... This class provides a .photonView and all callbacks/events that PUN can call. Override the events/methods you want to use. By

doc-api.photonengine.com

μ•„λž˜ μ½”λ“œλŠ” κ°„λ‹¨ν•œ ν¬ν†€ν΄λž˜μŠ€ λ‚΄ ν•¨μˆ˜λ“€μ„ μ˜€λ²„λΌμ΄λ”©ν•΄μ„œ

λ§ˆμŠ€ν„° μ—°κ²°, 랜덀 λ£Έ μž…μž₯ μ‹œλ„, λ°©μž…μž₯이 μ•ˆλ˜λ©΄ 방이 μƒμ„±λ˜μ§€ μ•Šμ•˜μŒμ„ 둜그둜 λ›°μš°κ³  λ°© 생성,

μƒμ„±λœ 방에 μž…μž₯ν•˜λŠ” κ²ƒκΉŒμ§€ 둜그둜 ν™•μΈν•˜λŠ” μ½”λ“œμ΄λ‹€. 

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
                                              //상속 받은 ν¬ν†€ν΄λž˜μŠ€μ˜ ν•¨μˆ˜λ“€μ„ μž¬μ •μ˜ν•΄μ„œ μ“΄λ‹€.
public class NetworkManager : MonoBehaviourPunCallbacks
{
    private void Awake()
    {
        PhotonNetwork.AutomaticallySyncScene = true;

        Debug.Log("TEST");
        //포톀 λ„€νŠΈμ›Œν¬μ— 접속
        PhotonNetwork.GameVersion = "1.0";
        PhotonNetwork.NickName = "test";
        PhotonNetwork.ConnectUsingSettings();
    }
        //μ—°κ²°λ˜μ—ˆμ„ λ•Œ μˆ˜ν–‰λ˜λŠ” 이벀트 ν•¨μˆ˜
    public override void OnConnectedToMaster()
    {
        Debug.Log("OnConnectedToMaster() λ§ˆμŠ€ν„°μ— μ—°κ²°λ˜μ—ˆλ‹€");
        PhotonNetwork.JoinRandomRoom();
    }
    // 랜덀 λ£Έ μž…μž₯에 μ‹€νŒ¨ν–ˆμ„ λ•Œ 호좜 λ˜λŠ” ν•¨μˆ˜
    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("방이 μ—†μŒ");
        PhotonNetwork.CreateRoom("TEST");
    }
    public override void OnCreatedRoom()
    {
        Debug.Log("OnCreatedRoom() 룸을 λ§Œλ“œλŠ” 데 μ„±κ³΅ν–ˆλ‹€");
    }
    public override void OnJoinedRoom()
    {
        Debug.Log("OnJoinedRoom() 룸에 λ“€μ–΄μ™”λ‹€");
    }

}
728x90