Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by CrilleStyles · Jun 19, 2014 at 10:30 AM · guierrornetworkingtutorial

Networkmanager errors and gui to small

Hello, I have followed Cg_cookie's tutorial on networking, But first i noticed that my GUI did not show up and I was never able to try if it worked because i always got errors. If someone here got time it would be nice if you could help me. Here's the errors [Note: I'm not hundered if I wrote it right because I never tried it because of errors]

 //errors
 Assets/Networking/NetworkManagerScript.js(49,10): BCE0044: expecting (, found 'OnServerInitialized'.
 Assets/Networking/NetworkManagerScript.js(49,31): UCE0001: ';' expected. Insert a semicolon at the end.
 Assets/Networking/NetworkManagerScript.js(51,15): BCE0043: Unexpected token: :.
 Assets/Networking/NetworkManagerScript.js(51,16): UCE0001: ';' expected. Insert a semicolon at the end.
 Assets/Networking/NetworkManagerScript.js(56,12): BCE0044: expecting (, found 'OnMasterServerEvent'.
 Assets/Networking/NetworkManagerScript.js(56,32): BCE0043: Unexpected token: mse.
 Assets/Networking/NetworkManagerScript.js(56,54): UCE0001: ';' expected. Insert a semicolon at the end.
 Assets/Networking/NetworkManagerScript.js(62,12): BCE0044: expecting (, found 'OnGUI'.
 Assets/Networking/NetworkManagerScript.js(62,19): UCE0001: ';' expected. Insert a semicolon at the end.
 Assets/Networking/NetworkManagerScript.js(81,1): BCE0044: expecting }, found ''.

And here's the tutorial http://vimeo.com/33996023

And here's the Code I tried to copy

 var playerPrefab:GameObject;
 var SpawnObject: Transform;
 var gameName:String = "Trackants";
 
 private var refreshing:boolean;
 private var hostData : HostData[];
 
 private var btnX : float;
 private var btnY : float;
 private var btnW : float;
 private var btnH : float;
  
  function Start(){
     bntX = Screen.width * 0.05;
     bntY = Screen.height * 0.05;
     bntW = Screen.width * 0.1;
     bntH = Screen.width * 0.1;
 }
  
  function   startServer(){
   Network.InitializeServer(32,25000, !Network.HavePublicAddress);
   MasterServer.RegisterHost(gameName, "Trackant game", "This is a co-op game!");
 }
 
 function  refreshHostList(){
   MasterServer.RequireHostList(gameName);
   refreshing = true;
 
   Debug.Log(MasterServer.PollHostList().Length);
 }
 
 function Update(){
   if(refreshing){
     if (MasterServer.PollHostList().Length <0){
     refreshing = false;
     Debug.Log(MasterServer.PollHostList().Length);
     hostData=MasterServer.PollHostList();
      }
   }
 }
 
 function SpawnPlayer(){
 Network.Instantiate(playerPrefab, spawnObject.position, Quaternion.identity,0);
 }
 function OnConnectedToServer(){
   spawnPlayer();
 
 //Messages
 function OnServerInitialized(){
  Debug.Log("Server initialized!");
  spawnPlayer():
 }
 
 
 
   function OnMasterServerEvent(mse:MasterServerEvent){
     if(mse == MasterServerEvent.RegistrationSucceeded){
       Debug.Log("Redistered Server!");
 
     }
 }
   function OnGUI(){
     if(Network.isClient && !Network.isServer ){
       if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Start server")){
       Debug.log("starting server");
       startServer();
       }
         if(GUI.Button(Rect(btnX, btnY * 1.2 + btnH, btnW, btnH), "Refresh hosts")){
          Debug.log ("refreshing");
          refreshHostList();
       }
       
       if(hostData){
       for(var i:int = 0; i<hostData.lenght; int++){
       if (GUI.Button(Rect(btnX *1.5 + btnW, btnY*1.2 + (btnH * i), btnW*3, btnH*.5), hostData[i].gameName));
         Network.Connect(hostData[i]);
       }
      }
     }
    }
Comment
Add comment · Show 2
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 HarshadK · Jun 19, 2014 at 12:07 PM 1
Share

There are just simple errors like bracket missing or typos and nothing much.

$$anonymous$$g.

  • There is no closing bracket to function OnConnectedToSer ver() function which should be placed after spawnPlayer(); line in that function.

  • Under this function

    function OnServerInitialized(){ Debug.Log("Server initialized!"); spawnPlayer(): }

there should be semicolon ';' after spawnPlayer() and not ':'

Find remaining error that are just like the ones specified above.

Best luck!

avatar image CrilleStyles · Jun 19, 2014 at 03:42 PM 0
Share

Thank you!

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.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is networkbehaviour underlined in green? 1 Answer

Error when I try to run the build in tutorial (roll a ball, tanks, and etc.) 0 Answers

Error in my script i don't understand. 0 Answers

How do I change the text of a gui image text 1 Answer

Unity Gui lable problem with showing js var using C# 2 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