using UnityEngine; using UnityEngine.UI; using UnityEngine.XR; using System; using System.Collections; using System.Collections.Generic; using SimpleJSON; using System.Linq; using System.IO; using MeshVR; // HZMCUACOLLISIONS v1.0 // // Improve CUA collisions when you need to interact with it namespace HZMCUACollisionsPlugin { public class HZMCUACollisions : MVRScript { // Game Objects and components private GameObject HZMCUACGO; private GameObject HZMCUACObjectGO; public override void Init() { try { if (containingAtom.type != "CustomUnityAsset") { SuperController.LogError("Please add HZMCUACollisions on a Custom Unity Asset Atom"); return; } } catch(Exception e) { SuperController.LogError("HZMCUACollisions - Exception caught: " + e); } } void Start() { try { InitCUA(); } catch(Exception e) { SuperController.LogError("HZMCUACollisions - Exception caught: " + e); } } void Update() { } // ************************** // Functions // ************************** protected void InitCUA() { try { // ****************************** // Getting button components // ****************************** HZMCUACGO = getCUAObject( containingAtom.reParentObject ).gameObject; Rigidbody RB = HZMCUACGO.GetComponent(); RB.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; } catch(Exception e) { SuperController.LogError("HZMCUACollisions - Exception caught while initializing: " + e); } } // ************************** // Callbacks & similar // ************************** // ************************** // Local Tools // ************************** private void logDebug( string debugText ) { SuperController.LogMessage( debugText ); } // Recursive function searching for a transform private Transform getCUAObject( Transform parent ) { foreach( Transform child in parent ) { if( child.name == "object" ) { return child; } else { Transform childSearch = getCUAObject(child); if (childSearch != null) return childSearch; } } return null; } // ************************** // Time to cleanup ! // ************************** void OnDestroy() { // Cleaning modified native VAM assets } } }