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

Prototype namespaces and class references

Discussion in 'Scripting' started by eco_bach, Nov 27, 2017.

  1. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Hi

    I have a class definition which starts as

    Code (csharp):
    1.  
    2.     namespace Prototype.NetworkLobby
    3.     {
    4.    
    5.            public class LobbyPlayer : NetworkLobbyPlayer
    6.           {
    7.  
    How do I get a reference to the LobbyPlayer Class from another class?
    If I try adding
    Code (csharp):
    1.  using Prototype.NetworkLobby;
    I get 'Using directive is unnecessary' and 'The type or namespace Prototype could not be found'
     
  2. Talthilas

    Talthilas

    Joined:
    Apr 1, 2014
    Posts:
    44
    If the class you are trying to reference LobbyPlayer from is also part of the Prototype.NetworkLobby namespace, then you do not need to place the using Prototype.NetworkLobby reference up the top of your script. Ensure that the file name (i.e. the script name) of class LobbyPlayer exactly matches the class name.