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 are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

"Using Cinemachine;" not recognized.

Discussion in 'Cinemachine' started by Hagen, Jun 23, 2018.

  1. Hagen

    Hagen

    Joined:
    Aug 16, 2014
    Posts:
    34
    I need to access some properties on a CinemachineFreeLook Camer but, Visual Studio does not recognize "Cinemachine" as a valid namespace. My game has the CM FreeLook in place in the scene and it works fine, but it is not accessible at all on Visual Studio.
    Anyone had this issue before?
     
    matvey231 likes this.
  2. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    I'm having this issue while trying to figure out how to change freelook deadzones. I'm not entirely sure what to do. Does it work with monodevelop?
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    Could you try a test with a new project? Create a new project, install Cinemachine, create a vcam, add a new script to it that has "using Cinemachine" in it. It all works correctly for me on all versions of Unity, in Windows, with Visual Studio 2017.
     
  4. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    I'm not OP but I gave it a try in a new project, and it seems to actually recognize it in the new one.

    In the one I'm trying to use it in, it says "using directive is unnecessary" along with the usual "
    The type or namespace name could not be found" error.

    https://i.imgur.com/eUjamK8.png
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    What version of Unity are you using?
    Maybe it's a cache thing. Have you tried restarting Unity and Visual Studio?
     
  6. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    I'm currently using 2018.1.5f1. Restarting did not help, but it did get rid of one of the two "The type or namespace name could not be found" errors, which is strange to begin with.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    If it got rid of the errors then it helped. You should be able to reference the Cinemachine stuff now in your script.
     
  8. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    It technically ""helped"" but not to where I can reference things. https://i.imgur.com/whdbeXs.png

    I think it was just a visual error. Not sure why it works in the empty project and not in this one
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    You're using Cinemachine from the package manager, correct?
    Did you at an earlier time have the Asset Store version of CM in stalled in your project?
     
  10. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    I clicked the install button from Chrome, which opened it in Unity and I installed it from there. I installed it soon after updating to 2018.1.5f1, which was a few days ago
    https://assetstore.unity.com/packages/essentials/cinemachine-79898
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    With 2018, Cinemachine has been moved to the Package Manager, and new releases are made there. You're using an outdated version of CM. I suggest you upgrade. Do do this, here are the steps:
    1. open an empty scene
    2. Delete the Cinemachine asset from your project. This includes CinemachineExamples (if you have them) and CinemachinePostProcessing (if you installed it).
    3. Open the Package Manager (windows/PackageManager)
    4. Find Cinemachine and install the latest version
    Then your existing scenes should work with the new CM, and probably the scripting problem will be gone. Let me know if this solves it.
     
  12. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    Unfortunately, it didn't work. Cinemachine is now updated from the package manager, and it updated with the cameras that were present in my scenes, but it didn't allow me to use "using Cinemachine;"
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    I'm suspecting that you have some kind of cache issue. Your visual studio solution should now see the Cinemachine assemblies. Can you force a re-creation of your solution files? Do this by closing VS and Unity, and deleting the VS solution from your project.
     
    Last edited: Jun 24, 2018
    ThisDuke likes this.
  14. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    I'll give this a try. This won't damage my project?

    I'm reinstalling VS as well to see if that does anything
     
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    Unity generates the solution files if they are absent or outdated, so no worries there.
     
  16. PegasiStudios

    PegasiStudios

    Joined:
    Dec 22, 2014
    Posts:
    26
    Managed to fix it. Just uninstalling/reinstalling Visual Studio or updating Visual Studio fixes the issue.
     
    AssassinSquid and Gregoryl like this.
  17. Jack-Kheir

    Jack-Kheir

    Joined:
    Apr 12, 2016
    Posts:
    3
    Hi, Is there a way that I can pause input to the virtual POV camera when locked in to an animation through code? And then resume input after animation has played?
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    I think you may have posted this question to the wrong thread.

    Have a look at CinemachineCore.GetInputAxis(). Cinemachine calls that delegate to get its user input. By default it's set to Input.GetAxis(). Set the delegate to point to a function that calls Input.GetAxis() when you want input, or returns 0 when you don't.
     
  19. caustin742

    caustin742

    Joined:
    Jul 4, 2020
    Posts:
    1
    Late to the party, but I just had this error happen to me.

    My solution that fixed it:
    • Close VS and Unity
    • Delete the .sln solution file and C# project files from your project folder. I also deleted my hidden .vs folder. Not sure which of these were necessary to delete.
    • Reopen Unity and VS as usual. Cinemachine reference should now be working as expected
     
    Deathate and mjc33 like this.
  20. mjc33

    mjc33

    Joined:
    Oct 9, 2019
    Posts:
    24
    Also had this happen, I followed the suggestion above to delete the SLN and project files, but they weren't being regenerated afterwards. It turned out the issue was a setting in preferences had changed of its own accord, to fix go to Edit > Preferences > External Tools and change the first drop down from "Open by file extension" to "Visual Studio...".

    After this everything is working fine again
     
  21. Bensirpent07

    Bensirpent07

    Joined:
    Feb 7, 2014
    Posts:
    6
    I am having this same error. None of these recommendations solved my problem
     
  22. MhhPineapples

    MhhPineapples

    Joined:
    Nov 14, 2020
    Posts:
    2
    Yeah I also have the same problem, in 2019.4.14f1 unity and Cinemachine 2.6.3.

    My problem is that unity doesn't seem to generate any csproj for cinemachine, and thus the .sln doesnt have any references. If I manually delete the .sln, .csproj and the .vs and .vscode folders, unity continues to give the same error, both before and after regenerating files.

    Any thoughts?
     
  23. MhhPineapples

    MhhPineapples

    Joined:
    Nov 14, 2020
    Posts:
    2
    I solved my issue by deleting:
    .vs, .vscode, .sln, .csproj, Library and most importantly the Obj folder.

    Then suddenly after re-opening the project cinemachine showed up in the unity main menu and correctly integrated with visual studio.
     
    terostora and Gregoryl like this.
  24. Dwarf-Cavern

    Dwarf-Cavern

    Joined:
    Apr 7, 2013
    Posts:
    6
    Maybe a bit late to the party, but I ran into the same issue and I solved it by doing a hybrid solution already mentioned here, but with one more added thing:

    1. Be sure your VS is closed.
    2. In Unity go to Edit > Preferences > External Tools and change from whatever option you have at the moment and then back to Visual Studio you are using.
    3. In the same window, underneath the "Generate .csproj files" checkboxes you will find a button "Regenerate Project Files", click it and wait for Unity to do its thing.
    4. Fire up VS and for me, it worked again.

    Hope this helps someone.
     
  25. wechat_os_Qy0xhY4tYURxUo31CD61Q22sE

    wechat_os_Qy0xhY4tYURxUo31CD61Q22sE

    Joined:
    Jul 29, 2021
    Posts:
    1

    This works for me! Thanks!
     
  26. SleepyWolfie

    SleepyWolfie

    Joined:
    Jun 8, 2020
    Posts:
    22
    None of the aforementioned methods have worked. I cant get to use Cinemachine on code, the using directive doesn't work. Note:
    - Creating a new Unity Project, "using Cinemachine;" works.

    But on my current project, I can't get the IDE to make "using Cinemachine;" work. I tried:
    - Delete and regenerate VS files, including: obj and Library folders, all .sln files, .csproj files, .vs and .vscode hidden folders.
    - Switching external tools.
    - Uninstalling and reinstalling Cinemachine through the Package Manager.
    - Reinstalling Visual Studio.

    Basically I've tried every approach this thread offers. Can't find anything else on the internet.
    Anyone have any idea of what else I could try?

    Edit: Its IDE independent, as I've tried with VSCode and it still doesn't work.

    Edit2: I found the solution, seen in this thread: https://forum.unity.com/threads/hel...-cinemachine-and-my-defined-assembly.1161038/
     
    Last edited: Aug 24, 2021
    Gregoryl likes this.
  27. sitnduck

    sitnduck

    Joined:
    Jun 29, 2016
    Posts:
    15
    This helped me, thank you! :)
     
  28. Le_Jo

    Le_Jo

    Joined:
    Jan 24, 2019
    Posts:
    6
    It's working :D
    Thank you ♥
     
  29. kornel-l-varga

    kornel-l-varga

    Joined:
    Jan 18, 2013
    Posts:
    43
    Same issue, same solution, thanks!
     
  30. ky124hoangthe

    ky124hoangthe

    Joined:
    Sep 8, 2019
    Posts:
    1
    If you have tried any of the upper solutions but still did not work like me, try this: (I'm using unity 2020.3.12f1)

    - Delete all the .csproj files along with your project .sln file (vs code closed or any other IDE you using)
    - In unity go Edit > Preferences > External Tools https://ibb.co/RbGK7F9
    - Check any of the checkbox that when you "Regenerate Project Files", it only generates Assembly-CSharp.csproj file (for me, I use git clone project so I check "git packages")
    - Click "Regenerate Project Files" and open up vs code to check
     
  31. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,241
    It's possible that you have a .asmdef file in your project, which holds an explicit list of the assemblies that your project can see. If that's the case then you need to add Cinemachine there.
     
  32. ZeyFight

    ZeyFight

    Joined:
    Aug 13, 2020
    Posts:
    5
    For people who haven't succeeded yet, for me the problem was that I downloaded cinemachine with VS open. Despite relaunching unity and VS nothing to do so I quit VS and reinstall Cinemachine and everything was working as it should!
     
  33. ottt

    ottt

    Joined:
    Jul 26, 2020
    Posts:
    2
    I've just solved this problem. Make a cinemachine camera in the hierarachy, and make a script attached to it. And open the script and add 'using Cinemachine;' to the top of the script as usual. Then, the red lines(error) of other scripts have just disappeared suddenly. Idk why. Surely you need to import cinemachin package first.
     
  34. Dragonhill

    Dragonhill

    Joined:
    Jun 2, 2010
    Posts:
    22
    Apparently, using failure.PNG unity does not like to include external packages by default... grrrr.... snap
     
    mivasiliauskas likes this.
  35. Krugmeisteren

    Krugmeisteren

    Joined:
    Mar 23, 2013
    Posts:
    1
    I solved the issue by simply updating Visual Studio 22 community edition to the latest version then restarting Unity
     
  36. ApK_Unity

    ApK_Unity

    Joined:
    Jul 22, 2018
    Posts:
    1
    This worked like charm :rolleyes:
    Just close the code editor , Regenerate Project Files, Re open the code editor!
     
  37. xticxs

    xticxs

    Joined:
    May 8, 2022
    Posts:
    2
    just make a new script
     
  38. xticxs

    xticxs

    Joined:
    May 8, 2022
    Posts:
    2
    the script wont recognize cinemashine if you added it after making the script
     
  39. ManieBesselaar

    ManieBesselaar

    Joined:
    Nov 1, 2018
    Posts:
    21
    Hi hope this might help someone. I recently followed a tutorial where the instructor created a assembly definition in the scripts folder. This helps speed up build times because unity just builds the scripts included in that folder and sub folders instead of rebuilding the entire project including the imported packages, like Cinemachine. I may be off on the technical details , so please correct me if you can.
    I ran into the same issue as the op where the script could not reference Cinemachine. I thought it might be the assembly definition , so I looked at its properties and found the Assembly Definition References Section. Here I ticked the "Use GUIDs" box and added all the cinemachine references listed. Worked.

    Let me know if it works for you or if you have a good understanding of this system, write a little something to clarify for the rest of us.
    Meanwhile I am off to go read the rest of the documentation on assembly definitions. ;)
     
  40. fabledxx

    fabledxx

    Joined:
    Jul 24, 2020
    Posts:
    1
    ty
     
unityunity