summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/VRM/VRM/UniVRM/Editor/VRMMonoBehaviourComparator.cs
blob: 7effc76f76c3a870c58ae188d5e3385034b1ebb8 (plain)
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;
using VRM;


public static class VRMMonoBehaviourComparator
{
    public static bool AssertAreEquals(GameObject l, GameObject r)
    {
        return
            AssertAreEquals<VRMMeta>(l, r,
            (x, y) => x[0].Meta.Equals(y[0].Meta))
            ;
    }

    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);
    }
}