Tanoda
EnableLeapTests.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System;
10using System.Linq;
11using System.Reflection;
12#if UNITY_EDITOR
13using UnityEditor;
14#endif
15
17
18 [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
19 public class SetupLeapTestsAttribute : Attribute { }
20
21 public static class EnableLeapTests {
22
23#if UNITY_EDITOR
24 [MenuItem("Assets/Enable Leap Tests")]
25 public static void enableTests() {
26 var assemblies = AppDomain.CurrentDomain.GetAssemblies();
27 foreach (var type in assemblies.SelectMany(a => a.GetTypes())) {
28 foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)) {
29 var attributes = method.GetCustomAttributes(typeof(SetupLeapTestsAttribute), inherit: true);
30 if (attributes.Length == 0) {
31 continue;
32 }
33
34 method.Invoke(null, null);
35 }
36 }
37
38 string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
39 PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, defines + " LEAP_TESTS");
40 }
41#endif
42 }
43}