CodeSmile AssetDatabase 1.10
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches
Asset.Database.cs
1// Copyright (C) 2021-2023 Steffen Itterheim
2// Refer to included LICENSE file for terms and conditions.
3
4using System;
5using System.Collections.Generic;
6using System.Diagnostics.CodeAnalysis;
7using UnityEditor;
8// UnityEngine is imported for the EntityId type, which replaces the integer instance ID overloads
9// that Unity marked obsolete as a warning on 6000.3.23f1 and 6000.4.11f1 and as an error on
10// 6000.5.10f1.
11using UnityEngine;
12using Object = UnityEngine.Object;
13
14namespace CodeSmileEditor
15{
16 public sealed partial class Asset
17 {
22 public static partial class Database
23 {
36 [ExcludeFromCodeCoverage] // simple relay
37 public static Int32 DesiredWorkerCount
38 {
39 get => AssetDatabase.DesiredWorkerCount;
40 set
41 {
42 AssetDatabase.DesiredWorkerCount = value;
43 AssetDatabase.ForceToDesiredWorkerCount();
44 }
45 }
46
57 [ExcludeFromCodeCoverage] // simple relay
58 public static Boolean DirectoryMonitoring
59 {
60 get => AssetDatabase.IsDirectoryMonitoringEnabled();
61 set => EditorPrefs.SetBool("DirectoryMonitoring", value);
62 }
63
72 public static Boolean Contains(Object instance) => instance != null ? AssetDatabase.Contains(instance) : false;
73
74#if UNITY_6000_4_OR_NEWER
90 [ExcludeFromCodeCoverage] // simple relay
91 public static Boolean Contains(EntityId entityId) => AssetDatabase.Contains(entityId);
92#else
101 [ExcludeFromCodeCoverage] // simple relay
102 public static Boolean Contains(Int32 instanceId) =>
103#if UNITY_6000_3_OR_NEWER
104 AssetDatabase.Contains((EntityId)instanceId);
105#else
106 AssetDatabase.Contains(instanceId);
107#endif
108#endif
109
124 [ExcludeFromCodeCoverage] // untestable
125 public static void AllowAutoRefresh() => AssetDatabase.AllowAutoRefresh();
126
138 [ExcludeFromCodeCoverage] // untestable
139 public static void DisallowAutoRefresh() => AssetDatabase.DisallowAutoRefresh();
140
152 [ExcludeFromCodeCoverage] // untestable
153 public static void ReleaseFileHandles() => AssetDatabase.ReleaseCachedFileHandles();
154
171 [ExcludeFromCodeCoverage] // untestable
172 public static void UpgradeAllAssetSerializationVersions() => AssetDatabase.ForceReserializeAssets();
173
192 [ExcludeFromCodeCoverage] // untestable
193 public static void UpgradeAssetSerializationVersion([NotNull] IEnumerable<Path> paths,
194 ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) =>
196
215 [ExcludeFromCodeCoverage] // untestable
216 public static void UpgradeAssetSerializationVersion([NotNull] IEnumerable<String> paths,
217 ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) =>
218 AssetDatabase.ForceReserializeAssets(paths, options);
219
235 public static void SaveAll() => AssetDatabase.SaveAssets();
236
289 public static void ImportAll(ImportAssetOptions options = ImportAssetOptions.Default) =>
290 AssetDatabase.Refresh(options);
291 }
292 }
293}
static void UpgradeAssetSerializationVersion([NotNull] IEnumerable< Path > paths, ForceReserializeAssetsOptions options=ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata)
Updates all native asset files to reflect any changes in serialization in the current editor version.
static Boolean Contains(EntityId entityId)
Tests if the asset is in the database.
static void UpgradeAllAssetSerializationVersions()
Updates all native asset files to reflect any changes in serialization in the current editor version.
static Int32 DesiredWorkerCount
Gets or sets the desired worker count.
static void AllowAutoRefresh()
Will allow Unity to automatically import assets.
static Boolean DirectoryMonitoring
Returns whether directory monitoring is enabled in Preferences.
static void ImportAll(ImportAssetOptions options=ImportAssetOptions.Default)
Scans for external file system modifications and updates the Database accordingly....
static void UpgradeAssetSerializationVersion([NotNull] IEnumerable< String > paths, ForceReserializeAssetsOptions options=ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata)
Updates all native asset files to reflect any changes in serialization in the current editor version.
static Boolean Contains(Object instance)
Tests if the asset is in the database.
static void DisallowAutoRefresh()
Will stop Unity from automatically importing assets.
static void SaveAll()
Saves all unsaved (dirty) assets.
static void ReleaseFileHandles()
Releases any cached file handles that Unity holds.
Groups all asset database functionality.
static String[] ToStrings([NotNull] IEnumerable< Path > paths)
Converts an IEnumerable collection of Path instances to a string array.
Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'.
Definition Asset.Path.cs:25
Replacement implementation for Unity's massive AssetDatabase class with a cleaner interface and more ...