SolidAlloy / GenericUnityObjects

Generic UnityEngine.Objects
Other
167 stars 13 forks source link

AssetDatabase does not contain a definition for 'SaveAssetIfDirty' #22

Closed styrbo2 closed 2 years ago

styrbo2 commented 3 years ago

I am getting that error after install packages from git url: https://github.com/SolidAlloy/SolidUtilities.git (version 1.32.2) https://github.com/SolidAlloy/ClassTypeReference-for-Unity.git (version 2.10.1) https://github.com/SolidAlloy/GenericUnityObjects.git (version 2.10.5)

Library\PackageCache\com.solidalloy.generic-unity-objects@ab08177a0d\Editor\GenericTypesAnalyzer\GenericTypesAnalyzer.cs(111,27): error CS0117: 'AssetDatabase' does not contain a definition for 'SaveAssetIfDirty'

Unity version 2020.3.10f1 and .net 4.x

SolidAlloy commented 3 years ago

Hi, thanks, I will check this bug with 2020.3.10f1. I looked for it in the documentation, and it seems the method is already added to 2020.3. Would you consider upgrading to the latest version of 2020.3 and checking it there?

SolidAlloy commented 3 years ago

Apparently, the method was added in 2020.3.16. I added a define directive to avoid errors in older versions, but would still recommend that you upgrade the project to at least 2020.3.16. The error should be gone in 2.10.6

mnicolas94 commented 2 years ago

I'm getting this error too. I'm using Unity 2021.1.13f1. I installed the package through openupm CLI. I see the define directive and my IDE is showing the lines in grey (see attached image) as if were ignored by compiler. However Unity keeps throwing the error. The com.solidalloy.generic-unity-objects package's installed version is 2.15.3.

Also, i'm testing this in a fresh new project. When I tried to install it in the project i'm working now, i got an error that i think is related to a GUID collision with one of my scripts. However i did not got this error in that project. SOATest  C_cosasDesarrolloGameDevProjectsSOATest  -  LibraryPackageCachecom solidalloy generic-unity-objects@2 15 3EditorGeneric

SolidAlloy commented 2 years ago

Thanks for reporting the issue. I hadn't realized the method was added in the middle of not only the 2020.3 cycle, but also 2021.1! Quite unusual for Unity to back-port such a major feature to release versions. The method was added in 2021.1.17, and I added an additional symbol to check for it before using AssetDatabase.SaveAssetIfDirty(), so the error should be gone. Please check it in the 2.16.0 version of the package.