Thursday, January 24, 2019

Backporting Unity 2018.2 to Unity 2018.1

First off, I don't recommend back porting Unity projects as it usually never ends well.  Your best bet is to revert your repository to a date prior to updating Unity.  That said, sometimes it is unavoidable.  In our case, we updated to Unity 2018.2 awhile back for a Hololens project.  Then we were asked to port the Hololens application to Magic Leap which currently is only supported in a technical preview on 2018.1.  We've done too much development on 2018.2 for reverting to make sense so here we are.


Step 1:
Close Unity and delete the Library folder within your project as well as any build folders and other temporary folders.  The Library folder is important as you may experience the editor crashing while trying to run a project in 2018.1 with cached properties from 2018.2.  The build folders were throwing some access denied errors for me but that may be specific to UWP and probably not as important for most projects.

Step 2.
Open the power shell and navigate to your project folder. Enter in each of these four commands 1 at a time.  Note, these are compiled from a few stackoverflow answers which I am having trouble finding at the moment to link credit to.


$configFiles = Get-ChildItem . *.prefab -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_IsPrefabAsset", "m_IsPrefabParent" } |
     Set-Content $file.PSPath
 }


 $configFiles = Get-ChildItem . *.unity -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_IsPrefabAsset", "m_IsPrefabParent" } |
     Set-Content $file.PSPath
 }


 $configFiles = Get-ChildItem . *.unity -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_SourcePrefab", "m_ParentPrefab" } |
     Set-Content $file.PSPath
 }


I did not find any references to this last one online, but I ran into some issues with prefabs within the scene losing reference and this fixed it.

 $configFiles = Get-ChildItem . *.unity -rec
 foreach ($file in $configFiles)
 {
     (Get-Content $file.PSPath) |
     Foreach-Object { $_ -replace "m_CorrespondingSourceObject", "m_PrefabParentObject" } |
     Set-Content $file.PSPath
 }

Step 3:
Cross fingers and give 2018.1 a try!  You may have a few coding changes to make if you did not use macros to separate out builds. 

Example:
#if UNITY_2018_2_OR_NEWER
// put unity 2018_2 code here
#else
// put unity 2018._1 and below code here
#endif


Good luck!

9 comments:

Peyton said...

This internet web page has given me loads to maintain in thoughts how to market web design company and what I wanted for years!! What a first rate answer!!

Gilberto said...

Their level of responsiveness, their professionalism, and the quality of their work are all such rare finds!
design services company

Tom Ollie said...

They’re collaborative and engaged in developing the product according to its purpose and values.
San Francisco website design

Gary Ridgway said...

As your company’s public faces, and therefore it should talk for itself top app design consultancy, creating an unforgettable impact on prospects in the first impression

Lauren Chevalier said...

The entrepreneurial savvy differentiates them from other design firms and enables them to deliver on business goa
brand agency

Jamie Mack said...

This blog has very distinct features. Thanks
San Francisco branding agencies

Stephanie Clifton said...

The blog is good enough I again n again read this.
best web design companies

Aubrey Dickey said...

Cool blog site friend I'm about to suggest this to all my listing contacts.
best UX agencies

Gary White said...

Thanks for compiling such nicest information in your blogs. Articles are very informative and hope again I’ll find more like that.
user experience design firms