CodeSmile AssetDatabase 1.9
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches
Asset.Static.cs
1// Copyright (C) 2021-2023 Steffen Itterheim
2// Refer to included LICENSE file for terms and conditions.
3
4using System;
5using System.Diagnostics.CodeAnalysis;
6using UnityEditor;
7using UnityEngine;
8using Object = UnityEngine.Object;
9
10namespace CodeSmileEditor
11{
12 public sealed partial class Asset
13 {
14 private static String s_LastErrorMessage = String.Empty;
15
16
17
26 [ExcludeFromCodeCoverage] // simple relay
27 public static Texture2D GetIcon([NotNull] Path path) => AssetDatabase.GetCachedIcon(path) as Texture2D;
28
37 [ExcludeFromCodeCoverage] // simple relay
38 public static Texture2D GetIcon([NotNull] Object asset) => GetIcon(Path.Get(asset));
39
54 public static String GetLastErrorMessage() => s_LastErrorMessage;
55
56 private static void SetLastErrorMessage(String message) =>
57 s_LastErrorMessage = message != null ? message : String.Empty;
58
59 private static Boolean Succeeded(String possibleErrorMessage)
60 {
61 SetLastErrorMessage(possibleErrorMessage);
62 return String.IsNullOrEmpty(GetLastErrorMessage());
63 }
64 }
65}
static Path Get([NotNull] Object asset)
Gets the relative path of an asset.
Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'.
Definition Asset.Path.cs:25
static Texture2D GetIcon([NotNull] Path path)
Returns the icon associated with the asset type.
static Texture2D GetIcon([NotNull] Object asset)
Returns the icon associated with the asset type.
static String GetLastErrorMessage()
Returns the last error message returned by some methods that provide such a failure message.