CodeSmile AssetDatabase 1.9
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;
8using Object = UnityEngine.Object;
9
10namespace CodeSmileEditor
11{
12 public sealed partial class Asset
13 {
18 public static partial class Database
19 {
32 [ExcludeFromCodeCoverage] // simple relay
33 public static Int32 DesiredWorkerCount
34 {
35 get => AssetDatabase.DesiredWorkerCount;
36 set
37 {
38 AssetDatabase.DesiredWorkerCount = value;
39 AssetDatabase.ForceToDesiredWorkerCount();
40 }
41 }
42
53 [ExcludeFromCodeCoverage] // simple relay
54 public static Boolean DirectoryMonitoring
55 {
56 get => AssetDatabase.IsDirectoryMonitoringEnabled();
57 set => EditorPrefs.SetBool("DirectoryMonitoring", value);
58 }
59
68 public static Boolean Contains(Object instance) => instance != null ? AssetDatabase.Contains(instance) : false;
69
78 [ExcludeFromCodeCoverage] // simple relay
79 public static Boolean Contains(Int32 instanceId) => AssetDatabase.Contains(instanceId);
80
95 [ExcludeFromCodeCoverage] // untestable
96 public static void AllowAutoRefresh() => AssetDatabase.AllowAutoRefresh();
97
109 [ExcludeFromCodeCoverage] // untestable
110 public static void DisallowAutoRefresh() => AssetDatabase.DisallowAutoRefresh();
111
123 [ExcludeFromCodeCoverage] // untestable
124 public static void ReleaseFileHandles() => AssetDatabase.ReleaseCachedFileHandles();
125
142 [ExcludeFromCodeCoverage] // untestable
143 public static void UpgradeAllAssetSerializationVersions() => AssetDatabase.ForceReserializeAssets();
144
163 [ExcludeFromCodeCoverage] // untestable
164 public static void UpgradeAssetSerializationVersion([NotNull] IEnumerable<Path> paths,
165 ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) =>
167
186 [ExcludeFromCodeCoverage] // untestable
187 public static void UpgradeAssetSerializationVersion([NotNull] IEnumerable<String> paths,
188 ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) =>
189 AssetDatabase.ForceReserializeAssets(paths, options);
190
206 public static void SaveAll() => AssetDatabase.SaveAssets();
207
260 public static void ImportAll(ImportAssetOptions options = ImportAssetOptions.Default) =>
261 AssetDatabase.Refresh(options);
262 }
263 }
264}
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 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 Boolean Contains(Int32 instanceId)
Tests if the asset is in the database.
static void SaveAll()
Saves all unsaved (dirty) assets.
static void ReleaseFileHandles()
Releases any cached file handles that Unity holds.
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