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. Dismiss Notice

first script: namespace could not b e found

Discussion in 'Scripting' started by Mike4, Aug 10, 2014.

  1. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Hi
    I try to integrate some script in another, both in the same project and get:
    Error CS0246: The type or namespace name 'Ocean' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp-firstpass)

    Ocean.cs is in the project. What do I need to change for my first scripting attempt?
    Thanks
     
  2. NomadKing

    NomadKing

    Joined:
    Feb 11, 2010
    Posts:
    1,461
    It sounds like a naming issue, but if you want specific help, you need to post the script (inside Code Tags).
     
  3. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class AddBuoyancy : MonoBehaviour
    5. {
    6.     Ocean m_ocean;
    7.    
    I'm only pasting from the other script. I want to merge those two.
    Thanks
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Could you show the Ocean script?
     
  5. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Why? I don't modify that, only merge the two others. Anyway it starts alike:
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class Ocean : MonoBehaviour
    6. {
    7.    
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Because the error message says that there is no Ocean. In which folder do you have Ocean.cs and where is AddBuoyancy.cs?
     
  7. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    I want to merge buoyancy and mouselook ie integrate bouyancy into mouselook.
     
  8. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    That's not what I asked. Are you still getting the error from the first post?
     
  9. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Yes but it might be cause I'm on Linux? I'll try on Windows now.
     
  10. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Most likely it is not related to Linux. But I am still trying to help you to resolve that initial issue. That's why it would be extremely useful if you could answer my questions.
    Unity has several compilation steps for the scripts, depending on the folders in which the scripts are placed.
    http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html

    That's why it is important to know in which folder the scripts are.
     
  11. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    Well I didn't change anything. I only disabled buoyanc script and pasted most into mouse look. Both are parented by player. Unfortunately I've erased this and loaded a new script that I did last week. Now this seems ok so maybe you need
    a new script while changing deps? I might try again but not sure if I can redo the very same.
    Now for debugging the new script how to set the current debugger position visible. It debugs but I cannot see at what
    line the debugger currently is. (cs monodevelop on Windows)
    Thanks
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I am trying to help you. If you are not answering my questions, I can't help. Last chance:
    Please post the whole error message from the first post.
     
    NomadKing likes this.
  13. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    f: \ UnityprojWin \ Surfs_High2a \ Assets \ Standard Assets \ Character Controllers \ Sources \ Scripts \ MouseLook.cs (2,2): error CS0246: The type or namespace name "Ocean" could not be found. (Missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp-first pass)
     
  14. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The error happens in the MouseLook script. Please show that script.
     
    NomadKing likes this.
  15. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    using UnityEngine;
    using System.Collections;

    /// MouseLook rotates the transform based on the mouse delta.
    /// Minimum and Maximum values can be used to constrain the possible rotation

    /// To make an FPS style character:
    /// - Create a capsule.
    /// - Add the MouseLook script to the capsule.
    /// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
    /// - Add FPSInputController script to the capsule
    /// -> A CharacterMotor and a CharacterController component will be automatically added.

    /// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
    /// - Add a MouseLook script to the camera.
    /// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
    public class AddBuoyancy : MonoBehaviour
    {
    Ocean m_ocean;

    still the same as above. I only pasted from the other script as said multiple times.
     
  16. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    This is the MouseLook script? First the class and file name have to match. If the class name is MouseLook, the script name has to be MouseLook.cs, if it is a C# script.

    Besides that, you still didn't answer in which folder those scripts are. I don't care about how it is setup in the game object right now. What matters is the place where the script is stored, like Assets/Scripts/Ocean.cs.

    And please use code tags.
     
  17. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    A script cannot have multiple classes? So that's it. Thanks

    Any ideas why I cannot see the debugger yellow line?
     
  18. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    What do you want to do?
     
  19. Mike4

    Mike4

    Joined:
    Oct 24, 2013
    Posts:
    92
    debug my script. I set a breakpoint, attach to unity and press play in editor. I see it stops but I cannot see the yellow debug line.-
     
  20. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You should either create a new thread or check the existing ones if it is a different topic. Just in the case you are using Linux, make sure to mention it.