Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by pzeronov · Dec 21, 2015 at 03:55 PM · unity 5networkingnetwork

Why my custom network script automatically adds a NetworkIdentity component every time I add it to my NetworkManager object?

Hi there,

I'm updating the network code of a videogame I was creating using the previous networking solution and I'm finding this issue:

Every time I add my script NetworkControl.cs to my gameObject NetworkManager it automatically adds a NetworkIdentity component which shouldn't be there, as far as I understand.

Why could this be happening? When I add other scripts to the same gameObject, there's no NetworkIdentity component that gets immediately attached to the very same object. It only happens with this one. What is more, no matter what gameObject I attach this script to, it will always automatically generate a NetworkManager component and a NetworkIdentity component, but I don't want the NetworkIdentity component in there at all (I read here that NetworkIdentity component should never be in the same object as the NetworkManager).

My network script simply has a public NetworkManager variable which I link to the NetworkManager component of that object by using classic GetComponent() and then I just access all unet functions from there.

My NetworkControl.cs script looks a bit like this:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.Networking;
         
 [AddComponentMenu("Network/NetworkManagerHUD")]
 [RequireComponent(typeof(NetworkManager))]
         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
 public class NetworkCtrl : NetworkBehaviour
 {
         public NetworkManager nmanager;
         
         void Awake()
         {
             // set new network manager
             nmanager = GetComponent<NetworkManager> ();
     
             PlayerPrefs.SetString (UPID, unetID.ToString());
         }
 }
 


(I'm skipping the rest of the code because is not related to the network set up itself and it's just a crazy mixed madness of good old RPCs and ClientRPCs/Commands but I'd say the problem is definitely not there as most of that code is simply commented out).

When running the game, I get the following error message:

 "NetworkManager has a NetworkIdentity component. This will cause the NetworkManager object to be disabled, so it is not recommended.
 UnityEditor.NetworkScenePostProcess:OnPostProcessScene()"
 

Best,

Pzeronov

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by seanr · Dec 21, 2015 at 05:02 PM

because NetworkCtrl derives from NetworkBehaviour instead of MonoBehaviour

Comment
Add comment · Show 2 · Share
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 pzeronov · Dec 21, 2015 at 05:20 PM 0
Share

Thanks a lot. That was it. I had changed that at some point when I wasn't sure how unet works to test some stuff and by changing it back to $$anonymous$$onoBehaviour everything went back to normal.

avatar image MrLucid72 · Nov 10, 2016 at 07:36 AM 0
Share

I found this at the top of Google --

Currently, you add a Network$$anonymous$$anager via a "Network$$anonymous$$anager" component.

However, if you also have a Lobby$$anonymous$$anager, you get this error and your lobbymgr poofs away.

This is built-into Unity so you can't just "remove" the NetworkBehavior. So... what do you do?

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

54 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 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 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

Lerping to Smooth Network Movement 0 Answers

UNET - How to wait for NetworkConnection.Send(...) to finish? 0 Answers

UNET (Multiplayer) calling [command] function twice 0 Answers

Command function called on server 0 Answers

What does this error mean? 1 Answer


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