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

Question How do I install NodaTime in Unity 2021.3?

Discussion in 'Scripting' started by Faustob64, Jan 31, 2023.

  1. Faustob64

    Faustob64

    Joined:
    Nov 28, 2022
    Posts:
    17
    I used Tools -> ManageNuGet Packages from Visual Studio and everything seemd fine, VS even automatically added "using NodaTime" directives in my C# script.

    But when I tried to compile from Unity, I got these errors in the Console:

    " CS0246: The type or namespace name 'NodaTime' could not be found (are you missing a using directive or an assembly reference?)"

    What am I missing?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Nothing you configure in Visual Studios matters. It has to be installed IN Unity first.

    Some ways might be:

    - copy / drag it into your Unity project
    - install it as a .unitypackage
    - install it through the Unity Package Manager

    Remember that Unity doesn't need VS at all. You could edit all your code with
    vi
    . :)

    Once installed, sometimes intellisense gets fudgy.

    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.

    Barring all that, move on to other ideas:

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
    Bunny83 likes this.
  3. Faustob64

    Faustob64

    Joined:
    Nov 28, 2022
    Posts:
    17
    Hmm... NodaTime is a .NET package distributed via NuGet. I can't think of a way to install it directly in Unity.
    VS has its own NuGet package manager, and I thought it would take care of making this package available across other development tools.

    Other people have been using it in Unity (to replace the broken TimeZone functions in Unity), maybe I need to adjust something in Unity -> Preferences -> External Tools ?

    I am using IL2CPP as backend, and tried both .NET Framework and .NET Standard 2.1.
    Will keep looking for a solution and report back...
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Steps to success:

    - find those people

    - ask them what they did

    - mimic it!

    - ???

    - profit!

    :)
     
  5. Faustob64

    Faustob64

    Joined:
    Nov 28, 2022
    Posts:
    17
    Thanks, doing just that :)
     
  6. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,475
    It seems like you are in luck - the NET universe when not having the source code, does not always play fine with Unity without much manual work. But since in your case the software is distributed via nuget, have a look at this: https://github.com/GlitchEnzo/NuGetForUnity
     
    ProGameDevUser and Faustob64 like this.
  7. Faustob64

    Faustob64

    Joined:
    Nov 28, 2022
    Posts:
    17
    Thanks DragonCoder, I'll check it out!
     
  8. Faustob64

    Faustob64

    Joined:
    Nov 28, 2022
    Posts:
    17
    Worked like a charm!

    - install NuGetForUnity (instructions in link above)
    - from the Unity Menu -> NuGet, search for NodaTime, and install

    Thank you all
     
    ProGameDevUser and Kurt-Dekker like this.
  9. nostalgicbear

    nostalgicbear

    Joined:
    Mar 21, 2013
    Posts:
    98
    Thank you for being one of the people that actually report back when they find a solution :)
     
    Faustob64 likes this.
  10. VINNUSAURUS

    VINNUSAURUS

    Joined:
    Jul 6, 2017
    Posts:
    18
    Just Download Noda Package forn Nuget https://www.nuget.org/api/v2/package/NodaTime/3.1.9 and unzip it, you find dll in lib/netstandard20. folder . copy and past dll into your project