mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-21 10:04:50 -05:00
Merge pull request #891 from ousttrue/fix/impl_SubAssetKey_equals
SubAssetKey == を実装した
This commit is contained in:
@@ -63,7 +63,7 @@ namespace UniGLTF
|
||||
case TextureImportTypes.StandardMap:
|
||||
{
|
||||
// write converted texture
|
||||
var (_, subAsset) = m_subAssets.FirstOrDefault(kv => kv.Key.Equals(key));
|
||||
var (_, subAsset) = m_subAssets.FirstOrDefault(kv => kv.Key == key);
|
||||
if (subAsset == null)
|
||||
{
|
||||
throw new KeyNotFoundException();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace UniGLTF
|
||||
/// の呼び出し時に、identifier.name と externalObject.name が同じでない運用にしてみる。
|
||||
///
|
||||
/// </summary>
|
||||
public struct SubAssetKey
|
||||
public struct SubAssetKey : IEquatable<SubAssetKey>
|
||||
{
|
||||
public readonly Type Type;
|
||||
public readonly string Name;
|
||||
@@ -36,5 +36,37 @@ namespace UniGLTF
|
||||
{
|
||||
return $"{Type}:{Name}";
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is SubAssetKey key)
|
||||
{
|
||||
return this == key;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(SubAssetKey other)
|
||||
{
|
||||
return Type == other.Type && Name == other.Name;
|
||||
}
|
||||
|
||||
public static bool operator ==(SubAssetKey l, SubAssetKey r)
|
||||
{
|
||||
return l.Equals(r);
|
||||
}
|
||||
|
||||
public static bool operator !=(SubAssetKey l, SubAssetKey r)
|
||||
{
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Name.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user