diff Orchestland/Assets/LeapMotion/Scripts/Utils/Utils.cs @ 1:f7675884f2a1

Add Orchestland project
author Daiki OYAKAWA <e135764@ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2015 23:09:20 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Orchestland/Assets/LeapMotion/Scripts/Utils/Utils.cs	Fri Jul 17 23:09:20 2015 +0900
@@ -0,0 +1,33 @@
+/******************************************************************************\
+* Copyright (C) Leap Motion, Inc. 2011-2014.                                   *
+* Leap Motion proprietary. Licensed under Apache 2.0                           *
+* Available at http://www.apache.org/licenses/LICENSE-2.0.html                 *
+\******************************************************************************/
+
+using UnityEngine;
+using System.Collections;
+using Leap;
+
+namespace Leap {
+
+  public static class Utils {
+
+    public static void IgnoreCollisions(GameObject first, GameObject second, bool ignore = true) {
+      if (first == null || second == null)
+        return;
+
+      Collider[] first_colliders = first.GetComponentsInChildren<Collider>();
+      Collider[] second_colliders = second.GetComponentsInChildren<Collider>();
+
+      for (int i = 0; i < first_colliders.Length; ++i) {
+        for (int j = 0; j < second_colliders.Length; ++j) {
+          if (first_colliders[i] != second_colliders[j] &&
+              first_colliders[i].enabled && second_colliders[j].enabled) {
+            Physics.IgnoreCollision(first_colliders[i], second_colliders[j], ignore);
+          }
+        }
+      }
+    }
+
+  }
+}