File tree Expand file tree Collapse file tree 4 files changed +43
-5
lines changed
Expand file tree Collapse file tree 4 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ public override readonly bool Equals(object obj)
142142 return false ;
143143 }
144144
145+ public override string ToString ( )
146+ {
147+ return $ "({ r } , { g } , { b } , { a } )";
148+ }
149+
145150 /// <summary>
146151 /// Mixes two colors
147152 /// </summary>
Original file line number Diff line number Diff line change @@ -146,6 +146,11 @@ public override readonly bool Equals(object obj)
146146 return false ;
147147 }
148148
149+ public override string ToString ( )
150+ {
151+ return $ "({ r } , { g } , { b } , { a } )";
152+ }
153+
149154 /// <summary>
150155 /// Mixes two colors
151156 /// </summary>
Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ namespace Staple.Internal;
77/// Direct access to a shader uniform, used for caching.
88/// </summary>
99/// <param name="uniform">The uniform to store</param>
10- public readonly struct ShaderHandle ( object owner , Shader . UniformInfo uniform )
10+ public readonly struct ShaderHandle ( IGuidAsset owner , Shader . UniformInfo uniform )
1111{
1212 internal readonly Shader . UniformInfo uniform = uniform ;
1313 internal readonly WeakReference < object > owner = new ( owner ) ;
1414
15- internal bool TryGetUniform ( object owner , out Shader . UniformInfo uniform )
15+ internal bool TryGetUniform ( IGuidAsset owner , out Shader . UniformInfo uniform )
1616 {
1717 if ( IsValid &&
1818 this . owner . TryGetTarget ( out var actualOwner ) &&
19- ReferenceEquals ( actualOwner , owner ) )
19+ ( ( IGuidAsset ) actualOwner ) . Guid . GuidHash == owner . Guid . GuidHash )
2020 {
2121 uniform = this . uniform ;
2222
Original file line number Diff line number Diff line change 1- namespace Staple ;
1+ using System ;
2+ using System . Diagnostics . CodeAnalysis ;
3+
4+ namespace Staple ;
25
36/// <summary>
47/// Manages a Guid Hash for faster Guid comparisons
58/// </summary>
6- public class GuidHasher
9+ public class GuidHasher : IEquatable < GuidHasher >
710{
811 private string guid ;
912
@@ -21,6 +24,31 @@ public string Guid
2124 }
2225 }
2326
27+ public static bool operator == ( GuidHasher lhs , GuidHasher rhs )
28+ {
29+ return lhs . GuidHash == rhs . GuidHash ;
30+ }
31+
32+ public static bool operator != ( GuidHasher lhs , GuidHasher rhs )
33+ {
34+ return lhs . GuidHash != rhs . GuidHash ;
35+ }
36+
37+ public override bool Equals ( object obj )
38+ {
39+ return obj is GuidHasher hasher && this == hasher ;
40+ }
41+
42+ public bool Equals ( GuidHasher other )
43+ {
44+ return this == other ;
45+ }
46+
47+ public override int GetHashCode ( )
48+ {
49+ return HashCode . Combine ( Guid , GuidHash ) ;
50+ }
51+
2452 public override string ToString ( )
2553 {
2654 return guid ;
You can’t perform that action at this time.
0 commit comments