void Update() { MultiARManager arManager = MultiARManager.Instance; ARPlatformInterface arInterface = arManager ? arManager.GetARInterface() : null; if (!levelLoaded && arManager && arManager.IsInitialized() && arInterface != null && arInterface.IsInitialized()) { Debug.Log("MultiARManager initialized. Loading 1st scene..."); levelLoaded = true; SceneManager.LoadScene(1); } }
// -- // -- // -- // -- // -- // -- // -- // -- // -- // -- // void Awake() { // initializes the singleton instance of MultiARManager if (instance == null) { instance = this; DontDestroyOnLoad(this); instanceInited = true; } else if (instance != this) { Destroy(gameObject); return; } // locate available AR interfaces in the scene MonoBehaviour[] monoScripts = FindObjectsOfType <MonoBehaviour>(); ARPlatformInterface arIntAvailable = null; arInterface = null; for (int i = 0; i < monoScripts.Length; i++) { if ((monoScripts[i] is ARPlatformInterface) && monoScripts[i].enabled) { ARPlatformInterface arInt = (ARPlatformInterface)monoScripts[i]; arInt.SetEnabled(false, null); if (arInt.IsPlatformAvailable()) { Debug.Log(arInt.GetARPlatform().ToString() + " is available."); if (arIntAvailable == null) { arIntAvailable = arInt; } if (arInt.GetARPlatform() == preferredPlatform) { arInterface = arInt; } } } } if (arInterface == null) { arInterface = arIntAvailable; } // report the selected platform if (arInterface != null) { arInterface.SetEnabled(true, this); Debug.Log("Selected AR-Platform: " + arInterface.GetARPlatform().ToString()); } else { Debug.LogError("No suitable AR-Interface found. Please check the scene setup."); } // set initialization status isInitialized = (arInterface != null); if (arInterface != null) { // check for augmented images AnchorImageManager imageManager = GameObject.FindObjectOfType <AnchorImageManager>(); if (imageManager != null && imageManager.anchorImages != null && imageManager.anchorImages.Count > 0) { // prepare images for tracking arInterface.InitImageAnchorsTracking(imageManager); arData.imageAnchorsEnabled = true; } } }