コード例 #1
0
        private void OnServerGUI()
        {
            EditorGUI.BeginChangeCheck();
            _socketPort = EditorGUILayout.IntField(new GUIContent("Socket Port", "The socket port used to host this server through."), _socketPort);

            if (EditorGUI.EndChangeCheck())
            {
                BuildScriptPrefs.SetSocketPort(_socketPort);
            }

            EditorGUILayout.Separator();

            var ip = IPUtils.GetLocalIPv4(NetworkInterfaceType.Ethernet);

            if (!string.IsNullOrEmpty(ip))
            {
                EditorGUILayout.DelayedTextField(new GUIContent("Ethernet IP v4 Address:", "Automatically identified local IP V4 address for Ethernet (Read Only)."), ip);
            }

            ip = IPUtils.GetLocalIPv4(NetworkInterfaceType.Wireless80211);
            if (!string.IsNullOrEmpty(ip))
            {
                EditorGUILayout.DelayedTextField(new GUIContent("Wireless IP v4 Address:", "Automatically identified local IP V4 address for Wireless (Read Only)."), ip);
            }

            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Build for Server"))
            {
                if (!Directory.Exists(_buildFolder))
                {
                    SetBuildFolder();
                }

                if (_buildAndRun)
                {
                    BuildScripts.BuildAndRunServer64(_serverOnlyScene, _buildFolder, _devBuild, _buildTarget, _socketPort);
                }
                else
                {
                    BuildScripts.BuildServer64(_serverOnlyScene, _buildFolder, _devBuild, _buildTarget, _socketPort);
                }

                GUIUtility.ExitGUI();
            }

            if (GUILayout.Button("Run as Server"))
            {
                BuildScripts.PlayAsServer(_serverOnlyScene, _socketPort);
                GUIUtility.ExitGUI();
            }

            EditorGUILayout.EndHorizontal();
        }