File tree 1 file changed +37
-1
lines changed
1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ namespace DevLocker.Utils
26
26
[ InitializeOnLoad ]
27
27
#endif
28
28
[ Serializable ]
29
- public class SceneReference : ISerializationCallbackReceiver
29
+ public class SceneReference : ISerializationCallbackReceiver , IEquatable < SceneReference > , IComparable < SceneReference >
30
30
{
31
31
32
32
#if UNITY_EDITOR
@@ -94,6 +94,42 @@ public string ScenePath
94
94
/// </summary>
95
95
public int BuildIndex => UnityEngine . SceneManagement . SceneUtility . GetBuildIndexByScenePath ( ScenePath ) ;
96
96
97
+
98
+ public override bool Equals ( object obj )
99
+ {
100
+ if ( obj is SceneReference other ) {
101
+ return Equals ( other ) ;
102
+ }
103
+
104
+ return false ;
105
+ }
106
+
107
+ public bool Equals ( SceneReference other )
108
+ {
109
+ if ( other == null )
110
+ return false ;
111
+
112
+ return ScenePath == other . ScenePath ;
113
+ }
114
+
115
+ public bool Equals ( string scenePath )
116
+ {
117
+ return ScenePath == scenePath ;
118
+ }
119
+
120
+ public override int GetHashCode ( )
121
+ {
122
+ return ScenePath ? . GetHashCode ( ) ?? 0 ;
123
+ }
124
+
125
+ public int CompareTo ( SceneReference other )
126
+ {
127
+ if ( other == null )
128
+ return 1 ;
129
+
130
+ return ScenePath . CompareTo ( other . ScenePath ) ;
131
+ }
132
+
97
133
public SceneReference ( ) { }
98
134
99
135
public SceneReference ( string scenePath )
You can’t perform that action at this time.
0 commit comments