Beispiel #1
0
 //try to populate plan snap manager
 void PopulateManager()
 {
     if (!planSnapManager)
     {
         try
         {
             planSnapManager = FindObjectOfType <PlanSnapManager>();
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
     if (!managedObject)
     {
         try
         {
             managedObject = planSnapManager.managedObject;
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
     if (!cropBox)
     {
         try
         {
             cropBox = planSnapManager.cropBox;
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
 }
Beispiel #2
0
        // Use this for initialization
        void Start()
        {
            //try to find missing references
            if (objectManager == null)
            {
                try
                {
                    objectManager = FindObjectOfType <ObjectManager>().gameObject;
                }
                catch (System.Exception)
                {
                    Debug.LogWarning("Unable to find Object Manager script. " +
                                     "Either include script, or manually populate object manager field.");
                    //throw;
                }
            }
            if (cropBox == null)
            {
                try
                {
                    cropBox = FindObjectOfType <BoxMaskMaterialAligner>();
                }
                catch (System.Exception)
                {
                    Debug.LogWarning("Unable to find Box Mask Material Aligner script. " +
                                     "If using a crop box, either include script, or manually populate Crop Box field.");
                    //throw;
                }
            }
            if (managedObject == null)
            {
                try
                {
                    managedObject = FindObjectOfType <SnappedObject>().gameObject;
                }
                catch (System.Exception)
                {
                    Debug.LogWarning("Unable to find Snapped Object script. " +
                                     "If using a crop box, either include script, or manually populate Managed Object field.");
                    //throw;
                }
            }

            //grab all the plan snaps, ALL OF THEM!! (including inactive)
            planSnaps = GetComponentsInChildren <PlanSnap>(true);

            //check for ARKit setup
#if UNITY_IOS
            try
            {
                UnityARCameraManager cameraManager = FindObjectOfType <UnityARCameraManager>();
                if (cameraManager.detectionImages == null)
                {
                    Debug.LogWarning("No reference image set found. Define image set in your Unity AR Camera Manager.");
                }
            }
            catch (System.Exception)
            {
                Debug.LogWarning("No Unity AR Camera Manager found. Your scene doesn't seem to be setup for AR.");
                //throw;
            }
#endif

            //populates collection for turning on/off at activation/deactivation
            planSnaps = GetComponentsInChildren <PlanSnap>(true);

            ResetPlanSnaps();

            //subscribe to ARMarker events
            ARMarker.changeMarker += ClearContent;
            ARMarker.changeMarker += ResetPlanSnaps;
        }