-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssetId.cs
More file actions
30 lines (24 loc) · 1.08 KB
/
Copy pathAssetId.cs
File metadata and controls
30 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using UnityEngine;
namespace AssetsPlugin
{
[Serializable]
public struct AssetId : IEquatable<AssetId>
{
[SerializeField] string _value;
public string Value => _value;
public AssetId(string value)
{
_value = value;
}
public static implicit operator AssetId(string value) => new(value);
public static implicit operator AssetId(Enum value) => new(Convert.ToString(value));
public static implicit operator string(AssetId id) => id._value;
public bool Equals(AssetId other) => string.Equals(_value, other._value, StringComparison.CurrentCulture);
public override bool Equals(object obj) => obj is AssetId other && Equals(other);
public override int GetHashCode() => _value.GetHashCode();
public static bool operator ==(AssetId left, AssetId right) => left.Equals(right);
public static bool operator !=(AssetId left, AssetId right) => !left.Equals(right);
public override string ToString() => _value;
}
}