// Starts up the QCAR extension with the properties that were set in the // Unity inspector. void Start() { // First we check if QCAR initialized correctly. if (QCAR.CheckInitializationError() != QCAR.InitError.INIT_SUCCESS) { mIsInitialized = false; return; } // Initialize the trackers if they haven't already been initialized. if (TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER) == null) { TrackerManager.Instance.InitTracker(Tracker.Type.MARKER_TRACKER); } if (TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) == null) { TrackerManager.Instance.InitTracker(Tracker.Type.IMAGE_TRACKER); } // Cache the camera start values mCachedDrawVideoBackground = QCARManager.Instance.DrawVideoBackground; mCachedCameraClearFlags = this.camera.clearFlags; mCachedCameraBackgroundColor = this.camera.backgroundColor; // Reset the camera clear flags and create a simple material ResetCameraClearFlags(); mClearMaterial = new Material(Shader.Find("Diffuse")); // Set QCAR hints from the Inspector options QCAR.SetHint(QCAR.QCARHint.HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, MaxSimultaneousImageTargets); QCAR.SetHint(QCAR.QCARHint.HINT_IMAGE_TARGET_MULTI_FRAME_ENABLED, MultiFrameEnabled ? 1 : 0); // Set the Unity version for internal use QCAR.SetUnityVersion(); // Find markers in the scene and register them with QCAR MarkerBehaviour[] markerBehaviours = (MarkerBehaviour[]) UnityEngine.Object.FindObjectsOfType(typeof(MarkerBehaviour)); MarkerTracker markerTracker = (MarkerTracker)TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER); if (markerTracker != null) { markerTracker.AddMarkers(markerBehaviours); } // Start the camera and tracker StartQCAR(); // Initialize the QCARManager QCARManager.Instance.WorldCenterMode = mWorldCenterMode; QCARManager.Instance.WorldCenter = mWorldCenter; QCARManager.Instance.ARCamera = camera; QCARManager.Instance.Init(); // Initialize local variables mIsInitialized = true; mHasStartedOnce = true; }