Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

NetworkBehaviour namespace could not be found

Discussion in 'Scripting' started by amirasgari12, Apr 25, 2019.

  1. amirasgari12

    amirasgari12

    Joined:
    Apr 19, 2019
    Posts:
    1
    Hi, I'm having a problem with using NetworkBehaviour even though I have added the required namespaces my visual studio doesn't recognize NetworkBehaviour.
    Here is a picture:

    here is the image link if it doesn't open
    https://imgur.com/BGkAR8C
     
    emilnyberg116 likes this.
  2. APSchmidtOfOld

    APSchmidtOfOld

    Joined:
    Aug 8, 2016
    Posts:
    4,473
  3. brlan10

    brlan10

    Joined:
    Mar 23, 2015
    Posts:
    5
    Deprecated, not removed...so why can't we use it still?
     
    emilnyberg116 likes this.
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,920
    You can use it, add the proper package to your project through package manager and you can use it. VS recognition is not necessary to use it. It is deprecated, do not expect support for this package.
     
  5. itsmerishabofficial

    itsmerishabofficial

    Joined:
    Nov 24, 2020
    Posts:
    2
    which package should we use
     
  6. andresmqa

    andresmqa

    Joined:
    Nov 10, 2016
    Posts:
    4
    Also me I would like to know it
     
  7. oroivirtual

    oroivirtual

    Joined:
    Aug 28, 2019
    Posts:
    5
    The package is "Multiplayer HLAPI"
     
    CaptainOppai likes this.
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd go with Mirror instead of installing the HLAPI package.
     
  9. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,920
    Joe-Censored likes this.
  10. StarLord2811

    StarLord2811

    Joined:
    Jun 23, 2021
    Posts:
    1
    What do I use instead of NetworkBehaviour. I am using Mirror API but the tutorial I was following is using HLAPI.
     
  11. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Mirror and the Unet HLAPI are very similar. This is because Mirror actually is a fork of the Unet HLAPI original code. So in most cases instructions or tutorials for Unet work almost unchanged with Mirror. You can see the specific differences in the Mirror migration guide:
    https://mirror-networking.gitbook.io/docs/general/migration-guide
     
  12. USC12345

    USC12345

    Joined:
    Aug 3, 2022
    Posts:
    8
    using UnityEngine;
    using UnityEngine.Networking;

    public class PlayerSetup : NetworkBehaviour {

    [SerializeField]
    Behaviour[] componentsToDisable;

    void Start ()
    {
    if (!isLocalPlayer)
    {
    for (ints i = 0; i < componentsToDisable.Length; i++)
    {
    componentsToDisable.enabled = false;
    }
    }
    }

    }
     
  13. USC12345

    USC12345

    Joined:
    Aug 3, 2022
    Posts:
    8
    pls can someone also help im having the same problem
     
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    Did you even read the first response?!!!!! Here, I'll copy it for you:

    NetworkBehaviour has been deprecated in 2019.1. See blog post here: https://blogs.unity3d.com/2018/08/0...65.1606307406.1556038404-136028431.1556038404

    and here: https://forum.unity.com/threads/unet-deprecation-thread.543501/

    It's more than halfway through 2022. That entire subsystem is probably long gone by now.

    And please don't necro-post. Start your own post. When you post, keep this in mind:

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/
     
    suruz likes this.
  15. USC12345

    USC12345

    Joined:
    Aug 3, 2022
    Posts:
    8
    so instead of network behaviour what can i use
     
  16. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
  17. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,063
    Actually, Netcode for GameObjects package uses the class
    NetworkBehaviour
    .
    https://docs-multiplayer.unity3d.com/netcode/current/basics/networkbehavior

    If you use the Netcode for GameObjects package and VS doesn't recognize the NetworkBehaviour class. Then regenerate the csproj files.
     
    trustpivot and Giantbean like this.
  18. saharikrithik981

    saharikrithik981

    Joined:
    Dec 29, 2020
    Posts:
    1
    Why arent any of you telling what to just type instead of network behaviour after using Mirror;
     
  19. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    141
    Because odds are you don't have to type something instead of NetworkBehaviour. Its still used by Mirror, Fish-Net, Netcode, and likely other networking solutions. If you IDE is not showing it as valid you likely need to go to preferences make sure an external script editor is loaded and regenerate project files.


    Hope that helps anyone else finging this as the top search result.