static unsafe TypeDependencyCache() { //TODO: Find a better way to enforce Version 2 compatibility bool v2Enabled = (bool)typeof(AssetDatabase).GetMethod("IsV2Enabled", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null); if (!v2Enabled) { throw new System.InvalidOperationException("com.unity.entities requires Asset Pipeline Version 2. Please enable Version 2 in Project Settings / Editor / Asset Pipeline / Mode"); } // Custom dependencies are transmitted to the import worker so dont spent time on registering them if (AssetDatabaseCompatibility.IsAssetImportWorkerProcess()) { return; } using (kRegisterComponentTypes.Auto()) RegisterComponentTypes(); using (kRegisterConversionSystemVersions.Auto()) RegisterConversionSystems(); int fileFormatVersion = SerializeUtility.CurrentFileFormatVersion; UnityEngine.Hash128 fileFormatHash = default; HashUnsafeUtilities.ComputeHash128(&fileFormatVersion, sizeof(int), &fileFormatHash); AssetDatabaseCompatibility.RegisterCustomDependency("EntityBinaryFileFormatVersion", fileFormatHash); int sceneFileFormatVersion = SceneMetaDataSerializeUtility.CurrentFileFormatVersion; UnityEngine.Hash128 sceneFileFormatHash = default; HashUnsafeUtilities.ComputeHash128(&sceneFileFormatVersion, sizeof(int), &sceneFileFormatHash); AssetDatabaseCompatibility.RegisterCustomDependency("SceneMetaDataFileFormatVersion", sceneFileFormatHash); }
public static void RegisterMonoScripts() { if (AssetDatabaseCompatibility.IsAssetImportWorkerProcess() || s_Initialized) { return; } s_Initialized = true; AssetDatabaseCompatibility.UnregisterCustomDependencyPrefixFilter("UnityEngineType/"); var behaviours = TypeCache.GetTypesDerivedFrom <UnityEngine.MonoBehaviour>(); var scripts = TypeCache.GetTypesDerivedFrom <UnityEngine.ScriptableObject>(); for (int i = 0; i != behaviours.Count; i++) { var type = behaviours[i]; if (type.IsGenericType) { continue; } var hash = TypeHash.CalculateStableTypeHash(type); AssetDatabaseCompatibility.RegisterCustomDependency(TypeString(type), new UnityEngine.Hash128(hash, hash)); } for (int i = 0; i != scripts.Count; i++) { var type = scripts[i]; if (type.IsGenericType) { continue; } var hash = TypeHash.CalculateStableTypeHash(type); AssetDatabaseCompatibility.RegisterCustomDependency(TypeString(type), new UnityEngine.Hash128(hash, hash)); } }