- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到此错误,我无法真正解决它,我不知道它要我做什么。
这是代码,如果您需要更多代码,请告诉我它们是否可以帮助您解决。
using System;
using UnityEngine;
using Random = UnityEngine.Random;
public class LobbyMenu : MonoBehaviour
{
//private string[]FirstName = new string[7]{"Clever", "Cunning", "Wise", "Awesome", "Amazing", "Dark", "Heroic"};
//private string[]LastName = new string[7]{"Rogue", "Wizard", "Mage", "Summoner", "Warrior", "Assassin", "Ranger"};
private string roomName = "myRoom";
private bool MessageRoomNameTaken = false;
private float MessageRoomTakenTimeToDisplay = 0;
private Vector2 scrollPos = Vector2.zero;
private bool connectFailed = false;
public static readonly string SceneNameMenu = "LobbyScene";
public static readonly string SceneNameGame = "GameScene";
public void Awake()
{
// this makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
PhotonNetwork.automaticallySyncScene = true;
// the following line checks if this client was just created (and not yet online). if so, we connect
if (PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
{
// Connect to the photon master-server. We use the settings saved in PhotonServerSettings (a .asset file in this project)
PhotonNetwork.ConnectUsingSettings("1.0");
}
// generate a name for this player, if none is assigned yet
if (String.IsNullOrEmpty(PhotonNetwork.playerName))
{
//PhotonNetwork.playerName = "Guest" + Random.Range(1, 9999);
//PhotonNetwork.playerName = FirstName[Random.Range(0, 6)] + " " + LastName[Random.Range(0, 6)];
PhotonNetwork.playerName = MainMenu.username;
}
// if you wanted more debug out, turn this on:
// PhotonNetwork.logLevel = NetworkLogLevel.Full;
}
public void OnGUI()
{
if (!PhotonNetwork.connected)
{
if (PhotonNetwork.connecting)
{
GUILayout.Label("Connecting to: " + PhotonNetwork.ServerAddress);
}
else
{
GUILayout.Label("Not connected. Check console output. Detailed connection state: " + PhotonNetwork.connectionStateDetailed + " Server: " + PhotonNetwork.ServerAddress);
}
if (this.connectFailed)
{
GUILayout.Label("Connection failed. Check setup and use Setup Wizard to fix configuration.");
GUILayout.Label(String.Format("Server: {0}", new object[] {PhotonNetwork.ServerAddress}));
GUILayout.Label("AppId: " + PhotonNetwork.PhotonServerSettings.AppID);
if (GUILayout.Button("Try Again", GUILayout.Width(100)))
{
this.connectFailed = false;
PhotonNetwork.ConnectUsingSettings("1.0");
}
}
return;
}
GUI.skin.box.fontStyle = FontStyle.Bold;
GUI.Box(new Rect((Screen.width - 400) / 2, (Screen.height - 350) / 2, 400, 300), "Join or Create a Room");
GUILayout.BeginArea(new Rect((Screen.width - 400) / 2, (Screen.height - 350) / 2, 400, 300));
GUILayout.Space(25);
// Player name
GUILayout.BeginHorizontal();
GUILayout.Label("Player name:", GUILayout.Width(100));
GUILayout.Label(PhotonNetwork.playerName);
//PhotonNetwork.playerName = GUILayout.TextField(PhotonNetwork.playerName);
GUILayout.Space(105);
if (GUI.changed)
{
// Save name
PlayerPrefs.SetString("playerName", PhotonNetwork.playerName);
}
GUILayout.EndHorizontal();
GUILayout.Space(15);
// Join room by title
GUILayout.BeginHorizontal();
GUILayout.Label("Roomname:", GUILayout.Width(100));
this.roomName = GUILayout.TextField(this.roomName);
if (GUILayout.Button("Create Room", GUILayout.Width(100)))
{
foreach (RoomInfo roomInfo in PhotonNetwork.GetRoomList())
{
if (roomInfo.name == this.roomName) {MessageRoomNameTaken = true; break;}
}
if (MessageRoomNameTaken==false) PhotonNetwork.CreateRoom(this.roomName, new RoomOptions() { maxPlayers = 2 }, null);
Debug.Log("OnJoinedRoom");
}
GUILayout.EndHorizontal();
// Create a room (fails if exist!)
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
//this.roomName = GUILayout.TextField(this.roomName);
if (GUILayout.Button("Join Room", GUILayout.Width(100)))
{
PhotonNetwork.JoinRoom(this.roomName);
}
GUILayout.EndHorizontal();
GUILayout.Space(15);
// Join random room
GUILayout.BeginHorizontal();
GUILayout.Label(PhotonNetwork.countOfPlayers + " users are online in " + PhotonNetwork.countOfRooms + " rooms.");
GUILayout.FlexibleSpace();
if (GUILayout.Button("Join Random", GUILayout.Width(100)))
{
PhotonNetwork.JoinRandomRoom();
}
GUILayout.EndHorizontal();
GUILayout.Space(15);
if (PhotonNetwork.GetRoomList().Length == 0)
{
GUILayout.Label("Currently no games are available.");
GUILayout.Label("Rooms will be listed here, when they become available.");
}
else
{
int roomcount = PhotonNetwork.GetRoomList().Length;
if (roomcount==1 )GUILayout.Label("1 room is currently available:");
else GUILayout.Label(PhotonNetwork.GetRoomList().Length + " rooms are currently available:");
// Room listing: simply call GetRoomList: no need to fetch/poll whatever!
this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
foreach (RoomInfo roomInfo in PhotonNetwork.GetRoomList())
{
GUILayout.BeginHorizontal();
GUILayout.Label(roomInfo.name + " " + roomInfo.playerCount + "/" + roomInfo.maxPlayers);
if (GUILayout.Button("Join"))
{
PhotonNetwork.JoinRoom(roomInfo.name);
}
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
}
GUILayout.EndArea();
if (MessageRoomNameTaken == true) {
MessageRoomTakenTimeToDisplay = 5; // we will display the warning for this number of seconds
MessageRoomNameTaken = false;
}
if (MessageRoomTakenTimeToDisplay >0 ) { GUI.contentColor = Color.red;
GUI.Label(new Rect(400,50,300,60), "The room with this name already exists");
MessageRoomTakenTimeToDisplay = MessageRoomTakenTimeToDisplay - Time.deltaTime;
}
}
// We have two options here: we either joined(by title, list or random) or created a room.
public void OnJoinedRoom()
{
Debug.Log("OnJoinedRoom");
}
public void OnCreatedRoom()
{
Debug.Log("OnCreatedRoom");
PhotonNetwork.LoadLevel(SceneNameGame);
}
public void OnDisconnectedFromPhoton()
{
Debug.Log("Disconnected from Photon.");
}
public void OnFailedToConnectToPhoton(object parameters)
{
this.connectFailed = true;
Debug.Log("OnFailedToConnectToPhoton. StatusCode: " + parameters + " ServerAddress: " + PhotonNetwork.networkingPeer.ServerAddress);
}
}
// the following line checks if this client was just created (and not yet online). if so, we connect
if (PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
{
// Connect to the photon master-server. We use the settings saved in PhotonServerSettings (a .asset file in this project)
PhotonNetwork.ConnectUsingSettings("1.0");
}
最佳答案
如果您检查PhotonNetwork的文档,您会看到PhotonNetwork.connectionStateDetailed
静态属性返回ClientState
枚举值(而不是PeerState
)。
来源: https://doc-api.photonengine.com/en/pun/current/class_photon_network.html
这是enum
文档:Enum Documentation
因此,更改:
if (PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
if (PhotonNetwork.connectionStateDetailed == ClientState.PeerCreated)
关于c# - Unity3d错误CS0103 : The name `PeerState' does not exist in the current context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43783772/
我有一个 jQuery 日期选择器。我想将默认日期设置为“当前月份、当前日期(当前年份-18)”,但在设置 defaultDate 属性时遇到问题。显示的默认年份是 1920 年,据说是 1995 年
我有下面的 C 程序来实现升序链表。问题出在 buildList() 函数中,因此您可以忽略除 main() 和 buildList() 之外的其他函数。 #include #include stru
嗯,想象一下 current.txt 文件: asdf base.txt 文件: asdf 其他.txt文件: asdf 当我进行三向 merge 时 git merge-file current.t
我试图在鼠标悬停时生成一个 :after 伪元素。例如: .email{ width:100px; overflow:hidden; text-overflow:ellipsi
为什么 $('a.current').removeClass('current'); 不适用于此 jquery 选项卡? http://jsfiddle.net/laukstein/ytnw9/8/
我正在创建一个应用程序(Outlook 的 Office 加载项) 我遇到的问题是更新我的屏幕。我知道我需要调用 Dispatcher,但是它在我的 ViewModel 中始终为 null p
我为客户开发网络和移动应用程序。在我当前的架构中,许多资源在 Web 访问和移动访问之间共享。 aspx 页面可以显示在网络上,也可以在移动应用程序中调用 WebView 。我的问题是: WebOpe
我通过调用 IEnumerable.GetEnumerator() 得到了一个枚举器,然后我称它为MoveNext()直到它返回false,然后访问它的Current属性(property)。令我惊讶
我正在尝试动态查找当前运行的函数(此函数)的名称,即 (defun my-func () (remove-hook 'some-hook this-function) (do-
阅读了短语 "The current SynchronizationContext is a property of the current thread" correct" ,我有点懵了…… 在 V
集成 IOS STRIPE TERMINAL SDK对于BBPOS Chipper 2X BT使用 swift 。我们已经开发并测试了该系统,并且运行良好。但是当我们将它交给其他国家的客户时,他们收到
当我在训练期间编写的类上实现 IEnumerable 和 IEnumerator 时,我注意到我需要为属性“Current”指定两个实现。 public class PeopleEnumerator
我原以为对实现了 IEnumerable 的空集合执行以下代码会抛出异常: var enumerator = collection.GetEnumerator(); enumerator.MoveNe
应Application.Current.Shutdown()不用作关闭 WPF 应用程序的最佳实践? 我有一个小的多窗口应用程序,“关机”似乎对我所有的退出命令都很好。但是,我被告知要始终使用 Ap
在 XPath 1.0 中,有一个函数 current() 可以派上用场,当我根据我当时所在的节点引用 XML 中其他地方的节点时。我的 XML 具有如下结构:
在 MVC 中,这两者有什么区别? 它们看起来相同,甚至返回相同的类型/类System.Web.Security.RolePrincipal,但有一些微妙之处。 例如。当针对通过 ClaimsPrin
这个问题在这里已经有了答案: What is the difference between an App and Application in c#.net? (1 个回答) 关闭 7 年前。 这两
我正在为我的团队开发一个代码生成器 (VSIX),在我与 VSIX 可扩展性框架作斗争之后,我打算使用 Roslyn 作为基础引擎。 我的代码生成器目前能够为解决方案生成一个新的 csproj,并且能
为什么 $('a.current').parent('li').addClass('current'); 和 $(this).hasClass('current')。 parent('li').add
当我使用 Xcode 调试我的 iOS 程序时,gdb 将其显示在控制台 View 上,并且没有发生任何错误。 我只想知道输出“Current language: auto; currently ob
我是一名优秀的程序员,十分优秀!