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

Question Manually upgrade to C# 8

Discussion in 'Editor & General Support' started by theCodeHermit, Feb 17, 2023.

  1. theCodeHermit

    theCodeHermit

    Joined:
    Sep 20, 2018
    Posts:
    39
    During the years I have updated my project a few times from older unity version up to 2021.1.4.
    According to the wiki this version should support C# 8.
    https://docs.unity3d.com/2021.1/Documentation/Manual/CSharpCompiler.html

    However I am stuck on C# 7.4. How can I manually upgrade it to C# 8 ?
    In project settings I have only 2 options:
    - .NET 4x
    - .NET standard 2x
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Why not upgrade to 2021.3 LTS?
     
    DevDunk likes this.
  3. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,393
    What Preator said
    You cannot modify the engine code of unity (at least not within reasonal budget)
     
  4. theCodeHermit

    theCodeHermit

    Joined:
    Sep 20, 2018
    Posts:
    39
    2021.1.4 supports C# 8 the problem is I have transitioned to this version in a ... weird way so I still have older c# version.
    A new empty project of 2021.1.4 is running on C# 8

    I have seen few forum posts where they edit some file somewhere in the project... and they just change C# version string. I think this should work with me since this version of unity does run on C# 8. I probably did smth stupid while upgrading versions in the past and got stuck on lower version.
     
  5. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,845
    I would still upgrade your project to a more recent LTS version (backing up/version controlling your project as needed) so you aren't on an apparently messed up Unity install.

    Hell even do a minor version update to a newer 2021.1 version.
     
  6. theCodeHermit

    theCodeHermit

    Joined:
    Sep 20, 2018
    Posts:
    39
    I am kinda reluctant to upgrade to anything anymore to be honest. I have lots of plugins and I finally found a version where all of them were stable and working. Also I have made lots of custom changes to said plugins so I cant get them again from the package manager or I will loose my mofifications. I guess I could copy and paste the plugins folders from one project to another but that might also cause issues...
    That is why I was looking for an easier solution than upgrading to new unity version.
    As a last resort I can upgrade, but I am getting a headache just thinking of all the problems that will cause
     
  7. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    This is why version control was invented. All you have to do is make a commit of your project in its current state, then you can experiment as much as you want, safe in the knowledge you can always just roll back to a working version. If you are not using version control (e.g. Git, PlasticSCM) yet in your project, start using it, then experiment freely.
     
    DevDunk and Kurt-Dekker like this.
  8. theCodeHermit

    theCodeHermit

    Joined:
    Sep 20, 2018
    Posts:
    39
    Yeah sure, its easy to say just use a backup.... Snap your fingers and everything is fixed....

    I am aware of the existence of version control.... But the experimentation part where you test and retest and bugfix every single plugin or compatibility issue is not as trivial. You have to transfer all project settings, classes data and god knows what else as well. Have to keep all plugin modifications too... Some of the plugins wont work, the materials could be F***ed.. and so on and so on. There is a reason why game companies don't update their game engine versions every month.

    Sure I can upgrade and probably will. But that is why I am asking here for a better/faster solution....
    The same version on a new project is using C# 8 and my project uses 7.4. So there is clearly some option somewhere that I can change or graft so I wont have to go over with all that block of text I wrote above.
     
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    Maintaining software in general is hard.

    Modern software is a living thing that if not maintained and cared for will quickly rot and die and become necrotic baggage in your project. The more of your project that is allowed to fall into this state of disrepair, the harder it will be to fix (more confounding issue between parts) and the less-well-equipped you will be to fix it because you haven't already been doing it.

    While you might think that it is easier to maintain by not upgrading, this is an illusion.

    Yes, it may be easier for some amount of time.

    But at some point, something external to your world will require an update.

    Maintaining "special snowflake" software is even HARDER than if you stay current. At least if you stay current you're likely to find plenty of contemporary guidance (here, Stack Overflow, documentation, the internets at large) to help you.

    I'm not advocating upgrading your project "just for fun," but you already have identified a need by saying you want a particular version of C#. Don't make it hard on yourself by trying to get that C# update by making snowflake project changes.

    This also gets to why you even care what version of C# you're on. If you are using a third party library that requires it, you are almost certainly going to need to upgrade other parts of your toolchain for that library.

    Then use it. That way you have a fighting chance of trying to upgrade without sinking your entire project. You really are just one click away from complete disaster if you're not using source control. For instance, if you had some file somehow get corrupted and prevent your project from launching, how could you even begin to reason about it?

    Source control would show you the corrupted file and you could revert it with a click.

    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
    DevDunk likes this.
  10. theCodeHermit

    theCodeHermit

    Joined:
    Sep 20, 2018
    Posts:
    39
    I agree with you on the first part. That is exactly why I have upgraded my project in the past. I did that several times and each time while being difficult, I also gained a lot of positive things. It would definitely be a positive if I do so now as well. However I at this moment I do not have the time or energy to bother with all the side difficulties it would require. Mainly the time I would spend on it. Maybe/probably in the future I will upgrade again but am trying to avoid it at the moment. I would have liked to just be able to switch C# versions in 2 mins and get on with coding whatever functionality I was doing at the moment. But since I cant seem to figure a way around it I guess I can put the C# update on hold till I have time, or upgrade unity version now and try to migrate all my stuff properly this time.
    The main thing is time and maybe also my sanity but that is about it. I am sure I can figure it out eventually.

    As for the second part, maybe I didnt explain myself correctly. We are getting a bit off topic here but whatever. I am aware of version control and its importance. I have been utilizing it in one way or another for years, both as a wannabe game dev and a regular programmer. And being able to revert potential project crippling changes is not issue at all. It is starting to seem like the more I talk about it the less believable I seem that I have even heard of the concept to begin with :D

    The only thing I wanted to figure out with creating this topic was if anyone knows an easy way to change C# versions. Since my unity version does support a newer one but my project still has its old one. No version control, no unity upgrades or anything else. Yes those things are definitely important and will benefit me, but again, they do require allot of effort and most importantly time.

    Anyway I consider the topic closed and if I figure out how to do so will close it.