MonoBehaviourComparator.cs
1.98 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using UnityEngine;
namespace UniGLTF
{
public static class MonoBehaviourComparator
{
public static bool AssertAreEquals(GameObject l, GameObject r)
{
return
l.name == r.name
&& AssertAreEquals<Transform>(l, r,
(x, y) => AssertAreEquals(x[0], y[0]))
&& AssertAreEquals<MeshFilter>(l, r,
(x, y) => AssertAreEquals(x[0], y[0]))
&& AssertAreEquals<MeshRenderer>(l, r,
(x, y) => AssertAreEquals(x[0], y[0]))
&& AssertAreEquals<SkinnedMeshRenderer>(l, r,
(x, y) => AssertAreEquals(x[0], y[0]))
;
}
public static bool AssertAreEquals<T>(GameObject l, GameObject r, Func<T[], T[], bool> pred) where T : Component
{
var ll = l.GetComponents<T>();
var rr = r.GetComponents<T>();
if (ll.Length != rr.Length)
{
return false;
}
if (ll.Length == 0)
{
return true;
}
return pred(ll, rr);
}
public static bool AssertAreEquals(Transform l, Transform r)
{
return
(l.localPosition == r.localPosition)
&& (l.localRotation == r.localRotation)
&& (l.localScale == r.localScale)
;
}
public static bool AssertAreEquals(MeshFilter l, MeshFilter r)
{
throw new NotImplementedException();
}
public static bool AssertAreEquals(MeshRenderer l, MeshRenderer r)
{
throw new NotImplementedException();
}
public static bool AssertAreEquals(SkinnedMeshRenderer l, SkinnedMeshRenderer r)
{
throw new NotImplementedException();
}
public static bool AssetAreEquals(Texture2D l, Texture2D r)
{
throw new NotImplementedException();
}
}
}