• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by slatius · Sep 28, 2011 at 08:04 PM · networknat

NAT ignored

It seams like NAT is ignored, even if I initialize the server with useNat to true, the element.useNat is always false any guesses?

 if(GUI.Button(Rect (xAmount+80, yAmount+140, 120,20), "Host Game")){
     creatingNewHostGame = false;
     HostNewGameButton.text = "Host New Game";
     
     Network.InitializeSecurity();
     if(password != "")
         Network.incomingPassword = password;
     var info : NetworkConnectionError = Network.InitializeServer(MaxPlayers - 1, serverPort, useNAT);
     MasterServer.RegisterHost(gameName, hostGameName, hostGameDescription);
     Debug.Log(info);
     LobbyGUI.menuCounter = 0;
 }

 for (var element : HostData in hostData){
         counter++;x = (counter-1) * 100;
         GUILayout.BeginHorizontal();
         hostNat = "";hostInfo = "";
         hostNat = element.useNat.ToString();
         for(var host in element.ip)
             hostInfo += host + " / " + element.port + " / " + hostNat; 
         GUI.color = Color.white;
         GUI.DrawTexture(new Rect(0, x, 300, 80), rowTexture, ScaleMode.ScaleToFit, true, 0);
         GUI.color = Color.black;
         GUI.Label(new Rect(0, x, 300 , 30), "Game Name : " + element.gameName);GUI.Label(new Rect(0, x + 15, 300 , 30), "Description : " + element.comment);
         GUI.Label(new Rect(0, x + 30, 300, 30), "Players : " + element.connectedPlayers + " / " + element.playerLimit);
         GUI.Label(new Rect(0, x + 45, 300, 30), "Private : " + element.passwordProtected);GUI.Label(new Rect(0, x + 60, 300, 30), "IP/Port/NAT : " + hostInfo);
         GUI.color = Color.white;
         if(GUI.Button(new Rect(0,x + 80, 80, 18), "Join")){
             LobbyGUI.menuCounter = 1;
             if(element.useNat){
                 Debug.Log("Connected with NAT");
                 if(element.passwordProtected)
                     Network.Connect(element.guid, tempPassword[counter - 1]);
                 else Network.Connect(element.guid);
             }else{
                 Debug.Log("Connected without NAT");
                 if(element.passwordProtected)
                     Network.Connect(element, tempPassword[counter - 1]);
                 else Network.Connect(element);
             }
         }if(element.passwordProtected){
             tempPassword[counter - 1] = GUI.TextField(new Rect(82,x + 80, 300 - 80, 18), tempPassword[counter - 1]);
         }GUILayout.EndHorizontal();    
     }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BerggreenDK · Sep 30, 2011 at 03:07 PM 0
Share

please comment your code, if you still need help with it. I dont have time to study why you do this and that. Either you tell me what you know, or I'll have to leave you alone with it. Sorry.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Network - Receiving NAT punchthrough failed 0 Answers

Custom master server 0 Answers

Network Connect to self after initializing server 3 Answers

UNET Direct IP Connection not working 0 Answers

What could be causing error: "Receiving NAT punchthrough attempt from target ############ failed" 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges