온라인 구현

This commit is contained in:
김도환
2026-05-01 05:47:12 +09:00
parent 5695b4036f
commit a36270f77a
996 changed files with 267058 additions and 75 deletions

View File

@@ -0,0 +1,188 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DemoHubManager.cs" company="Exit Games GmbH">
// Part of: Photon Unity Demos
// </copyright>
// <summary>
// Used as starting point to let developer choose amongst all demos available.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using Photon.Pun.Demo.Cockpit;
namespace Photon.Pun.Demo.Hub
{
public class DemoHubManager : MonoBehaviour {
public Text TitleText;
public Text DescriptionText;
public GameObject OpenSceneButton;
public GameObject OpenTutorialLinkButton;
public GameObject OpenDocLinkButton;
string MainDemoWebLink = "https://doc.photonengine.com/en-us/pun/v2/getting-started/pun-intro";
struct DemoData
{
public string Title;
public string Description;
public string Scene;
public string TutorialLink;
public string DocLink;
}
Dictionary<string,DemoData> _data = new Dictionary<string, DemoData>();
string currentSelection;
// Use this for initialization
void Awake () {
PunCockpit.Embedded = false;
OpenSceneButton.SetActive(false);
OpenTutorialLinkButton.SetActive(false);
OpenDocLinkButton.SetActive(false);
// Setup data
_data.Add(
"BasicTutorial",
new DemoData()
{
Title = "Basic Tutorial",
Description = "All custom code for connection, player and scene management.\n" +
"Auto synchronization of room levels.\n" +
"Uses PhotonAnimatoView for Animator synch.\n" +
"New Unity UI all around, for Menus and player health HUD.\n" +
"Full step by step tutorial available online.",
Scene = "PunBasics-Launcher" ,
TutorialLink = "https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro"
}
);
_data.Add(
"Chat",
new DemoData()
{
Title = "Chat",
Description = "Uses the Chat API.\n" +
"Simple UI.\n" +
"You can enter any User ID.\n" +
"Automatically subscribes some channels.\n" +
"Allows simple commands via text.\n" +
"\n" +
"Requires configuration of Chat App ID in ServerSettings.",
Scene = "Chat-Scene",
DocLink = "http://j.mp/2iwQkPJ"
}
);
_data.Add(
"Asteroids",
new DemoData()
{
Title = "Asteroids",
Description = "Simple asteroid game based on the Unity learning asset.\n",
Scene = "DemoAsteroids-LobbyScene",
TutorialLink = "https://doc.photonengine.com/pun/current/demos-and-tutorials/package-demos/asteroidsdemo"
}
);
_data.Add(
"SlotRacer",
new DemoData()
{
Title = "Slot Racer",
Description = "Simple SlotRacing game.\n",
Scene = "SlotCar-Scene"
}
);
_data.Add(
"Procedural",
new DemoData()
{
Title = "Procedural World",
Description = "Shows how to synchronize the seed of a procedural world with deterministic generation.\n" +
"Simple modifications to the world are possible." +
"\n" +
"This is a simple test scene to connect and join a random room, without using PUN but the actual LoadBalancing api only",
Scene = "Procedural-Scene",
TutorialLink = "https://doc.photonengine.com/pun/current/demos-and-tutorials/package-demos/proceduraldemo"
}
);
_data.Add(
"PunCockpit",
new DemoData()
{
Title = "Cockpit",
Description = "Controls most aspect of PUN.\n" +
"Connection, Lobby, Room access, Player control",
Scene = "PunCockpit-Scene"
}
);
}
public void SelectDemo(string Reference)
{
currentSelection = Reference;
TitleText.text = _data[currentSelection].Title;
DescriptionText.text = _data[currentSelection].Description;
OpenSceneButton.SetActive(!string.IsNullOrEmpty(_data[currentSelection].Scene));
OpenTutorialLinkButton.SetActive(!string.IsNullOrEmpty(_data[currentSelection].TutorialLink));
OpenDocLinkButton.SetActive(!string.IsNullOrEmpty(_data[currentSelection].DocLink));
}
public void OpenScene()
{
if (string.IsNullOrEmpty(currentSelection))
{
Debug.LogError("Bad setup, a CurrentSelection is expected at this point");
return;
}
SceneManager.LoadScene(_data[currentSelection].Scene);
}
public void OpenTutorialLink()
{
if (string.IsNullOrEmpty(currentSelection))
{
Debug.LogError("Bad setup, a CurrentSelection is expected at this point");
return;
}
Application.OpenURL(_data[currentSelection].TutorialLink);
}
public void OpenDocLink()
{
if (string.IsNullOrEmpty(currentSelection))
{
Debug.LogError("Bad setup, a CurrentSelection is expected at this point");
return;
}
Application.OpenURL(_data[currentSelection].DocLink);
}
public void OpenMainWebLink()
{
Application.OpenURL(MainDemoWebLink);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: ed6ca7d1055974cc7847025558e8a903
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonUnityNetworking/Demos/DemoHub/Scripts/DemoHubManager.cs
uploadId: 817708

View File

@@ -0,0 +1,97 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ToDemoHubButton.cs" company="Exit Games GmbH">
// Part of: Photon Unity Demos
// </copyright>
// <summary>
// Present a button on all launched demos from hub to allow getting back to the demo hub.
// </summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.EventSystems;
namespace Photon.Pun.Demo.Hub
{
/// <summary>
/// Present a button on all launched demos from hub to allow getting back to the demo hub.
/// </summary>
public class ToDemoHubButton : MonoBehaviour
{
private static ToDemoHubButton instance;
CanvasGroup _canvasGroup;
public static ToDemoHubButton Instance
{
get
{
if (instance == null)
{
#if UNITY_6000_0_OR_NEWER
instance = FindFirstObjectByType<ToDemoHubButton>();
#else
instance = FindObjectOfType(typeof (ToDemoHubButton)) as ToDemoHubButton;
#endif
}
return instance;
}
}
public void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
}
}
// Use this for initialization
public void Start()
{
DontDestroyOnLoad(gameObject);
_canvasGroup = GetComponent<CanvasGroup>();
}
public void Update()
{
bool sceneZeroLoaded = false;
#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 || UNITY_5_3_OR_NEWER
sceneZeroLoaded = SceneManager.GetActiveScene().buildIndex == 0;
#else
sceneZeroLoaded = Application.loadedLevel == 0;
#endif
if (sceneZeroLoaded && _canvasGroup.alpha!= 0f)
{
_canvasGroup.alpha = 0f;
_canvasGroup.interactable = false;
}
if (!sceneZeroLoaded && _canvasGroup.alpha!= 1f)
{
_canvasGroup.alpha = 1f;
_canvasGroup.interactable = true;
}
}
public void BackToHub()
{
PhotonNetwork.Disconnect();
SceneManager.LoadScene(0);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: f877c2f2d403a4d4f975fb1fd64fe7e8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.52
assetPath: Assets/Photon/PhotonUnityNetworking/Demos/DemoHub/Scripts/ToDemoHubButton.cs
uploadId: 817708