void OnDestroy() { if (Instance == this) { Instance = null; } }
void Awake() { if (Instance == null) { Instance = this; } }
static void MakeARCamera() { ARManager arManager = GameObject.FindObjectOfType <ARManager>(); if (arManager != null) { Debug.LogWarning("已经存在ARManager"); Selection.activeObject = arManager.gameObject; } else { if (Camera.main != null) { Camera.main.gameObject.AddComponent <ARManager>(); Selection.activeObject = Camera.main.gameObject; Debug.LogWarning("添加成功"); } else { GameObject camObject = GameObject.FindObjectOfType <Camera>().gameObject; if (camObject == null) { Debug.LogWarning("场景中需添加摄像机"); return; } else { camObject.AddComponent <ARManager>(); Selection.activeObject = camObject; Debug.LogWarning("添加成功"); } } } }
/// <summary> /// 检查设置 /// </summary> public void CheckDataSetting() { bool result = false; ARManager sceneARManager = GameObject.FindObjectOfType <ARManager>(); if (sceneARManager != null) { sceneARManager.ARAssetsConfig = ConfigObject; result = true; } for (int i = 0; i < TrackAssets.Count; i++) { for (int j = 0; j < TrackAssets[i].targetObjects.Count; j++) { if (TrackAssets[i].targetObjects[j].ManagerComponent == "") { TrackTarget trackObject = TrackAssets[i].targetObjects[j]; trackObject.ManagerComponent = AssetDatabase.LoadAssetAtPath <MonoScript>("Assets/Vuforia/Scripts/DefaultTrackableEventHandler.cs").GetClass().Name; //Debug.LogWarning(AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/Vuforia/Scripts/DefaultTrackableEventHandler.cs").GetClass().Name); // Debug.Log(trackObject.ManagerComponent.name); TrackAssets[i].targetObjects[j] = trackObject; result = true; } } } if (result) { Debug.LogWarning("配置文件设置已更新!"); } }
public override void Init(GameObject parentObject) { ARManager.SetPlanesActive(false); //Incase theres existing planes ARManager.SetPlaneManagerActive(false); instructionUI.SetActive(true); mainMenuButton.SetActive(false); if (minionPrefabs != null) { foreach (Minion m in minionPrefabs) { minionDictionary.Add(m.gameObject.name, m.gameObject); } } //ARDebug.Log("Loaded prefabs", 5); imageManager = FindObjectOfType <ARTrackedImageManager>(); if (imageManager == null) { imageManager = ARManager.arSessionOrigin.gameObject.AddComponent <ARTrackedImageManager>(); imageManager.referenceLibrary = ContentLoader.LoadReferenceLibrary(); imageManager.maxNumberOfMovingImages = 2; //imageManager.trackedImagePrefab = spawnObject; } imageManager.enabled = true; imageManager.trackedImagesChanged += UpdateImage; //ARDebug.Log("Finish Init", 5); }
public override void OnInspectorGUI() { if (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab) { return; } arManager = (ARManager)target; isDirty = false; EditorGUILayout.LabelField("App Signature : "); string appSignature = arManager.AppSignature; arManager.AppSignature = EditorGUILayout.TextArea(appSignature, GUILayout.MaxHeight(40)); if (string.Equals(appSignature, arManager.AppSignature) == false) { isDirty = true; } if (GUI.changed) { if (isDirty) { EditorUtility.SetDirty(arManager); } SceneManager.Instance.SceneUpdated(); } }
public override void Init(GameObject parentObject) { ARManager.SetPlaneManagerActive(true); ARManager.TogglePlanePrefab(true); visualMarkerBlock = Instantiate(visualMarkerBlockPrefab, Vector3.one * 100, Quaternion.identity); }
public void TogglePlanes() { planesOn = !planesOn; if (ARManager.arPlaneManager != null) { ARManager.SetPlanesInvisible(planesOn); } }
public void Init() { _rect = GetComponent <RectTransform>(); _image = GetComponent <Image>(); _collapsedSize = _dummyRect.sizeDelta; _transforming = null; _arManager = ARManager.Instance; _state = TransitionState.Collapsed; }
public static IEnumerator RestartARSession() { ARManager.DestroyCurrentARSession(); yield return(null); ARManager.AssignNewARSession(Instantiate((GameObject)Resources.Load("AR Session"))); ARManager.SetPlaneManagerActive(false); }
// Use this for initialization void Start() { ARManager arManager = GameObject.FindObjectOfType <ARManager>(); ImageTrackableBehaviour [] imageTrackables = GameObject.FindObjectsOfType <ImageTrackableBehaviour>(); if (arManager != null) { arManager.SetTrackables(imageTrackables); } }
IEnumerator RestartLocalARSession() { yield return(new WaitForSeconds(0.2f)); StartCoroutine(GameManager.RestartARSession()); yield return(new WaitForSeconds(0.5f)); ARManager.SetPlaneManagerActive(true); SpawnARObjectPlacement(); }
public void BackToMainMenu() { DestroyGameSessionObjects(); ARManager.SetPlanesInvisible(false); ARManager.SetPlanesActive(false); ARManager.SetPlaneManagerActive(false); MenuManager.instance.SpawnMenu(eMenus.MAIN_MENU); GameModeManager.instance.DestroyActiveGameMode(); }
void Awake() { if (_instance == null) { _instance = this; } else { Destroy(this.gameObject); } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; //DontDestroyOnLoad(this); } }
// Use this for initialization void Start() { if (_instance == null) { _instance = this; } else if (_instance != this) { Destroy(this); } DontDestroyOnLoad(this); }
IEnumerator RestartLocalARSession() { yield return(new WaitForSeconds(0.1f)); StartCoroutine(GameManager.RestartARSession()); ChangeState(ePlacementState.PLANE_DETECTION); yield return(new WaitForSeconds(0.5f)); ActivateClick(); scaleSlider.value = defaultSliderValue; Destroy(spawnedPrefab); ARManager.SetPlaneManagerActive(true); }
private void OnDisable() { UIManager.onDrawModeButtonPressed -= ChangeDrawState; UIManager.onBlockDisplayButtonPressed -= ChangeBlock; UIManager.onEnemyDisplayButtonPressed -= ChangeEnemy; if (worldZeroBlock != null) { Destroy(worldZeroBlock); } ARManager.SetPlanesInvisible(true); ARManager.SetPlanesActive(false); ARManager.SetPlaneManagerActive(false); }
public void Awake() { Instance = this; if (SetTargetFrameRateTo60Mhz) { Application.targetFrameRate = 60; } MainCamera = Camera ? Camera : Camera.main; if (MainCamera == null) { throw new NullReferenceException("[AR+GPS][ARLocationManager#Start]: Missing Camera. " + "Either set the 'Camera' property to the AR Camera, or tag it as a 'MainCamera'."); } }
public void GoToMainMenu() { UIManager.onDrawModeButtonPressed -= ChangeDrawState; UIManager.onBlockDisplayButtonPressed -= ChangeBlock; if (worldZeroBlock != null) { Destroy(worldZeroBlock); } ARManager.SetPlanesActive(false); ARManager.SetPlaneManagerActive(false); MenuManager.instance.SpawnMenu(eMenus.MAIN_MENU); GameModeManager.instance.DestroyActiveGameMode(); }
private void Awake() { if (_instance == null) { _instance = this; } else { Destroy(this); } /* * currPubData = GeneralManager.GetPubSelected(); * #if UNITY_EDITOR * if(currPubData == null) currPubData = GeneralManager.SelectPub(testPubName); #endif * LoadSceneTrackers(); */ }
static void MakeARResources() { ARManager armanager = GameObject.FindObjectOfType <ARManager>(); if (armanager == null) { Debug.LogError("需配置ARManager"); return; } string sourcesPath = Application.streamingAssetsPath + "/Vuforia"; if (armanager.LoadLocalPath == "") { Selection.activeObject = armanager.gameObject; Debug.LogError("DataSet路径为空"); return; } string resourcesPath = Application.dataPath + "/Resources/" + armanager.LoadLocalPath; List <string> files = new List <string>(from string file in Directory.GetFiles(sourcesPath) where !file.EndsWith(".meta") && (file.EndsWith(".xml") || file.EndsWith(".dat")) select file); Dictionary <string, string> targetPath = new Dictionary <string, string>(); if (!Directory.Exists(resourcesPath)) { Directory.CreateDirectory(resourcesPath); } foreach (string file in files) { string targetFilePath = file.Replace(sourcesPath, ""); targetFilePath = targetFilePath.Replace(".dat", "_dat.bytes"); targetFilePath = targetFilePath.Replace(".xml", "_xml.txt"); targetFilePath = resourcesPath + targetFilePath; if (File.Exists(targetFilePath)) { File.Delete(targetFilePath); } File.Copy(file, targetFilePath, true); Debug.Log(targetFilePath); } AssetDatabase.Refresh(); }
void ChangeState(ePlacementState newState) { //Exiting State if (placementState == ePlacementState.PLANE_DETECTION) { planeDetectionUI.SetActive(false); } else if (placementState == ePlacementState.SCALE_OBJECT) { if (newState != ePlacementState.FINISH) { scaleUI.SetActive(false); } } placementState = newState; if (placementState == ePlacementState.PLANE_DETECTION) { ARManager.SetPlaneManagerActive(true); planeDetectionUI.SetActive(true); curTimeSpentOnPlaneDetection = 0; instructionsText.text = "Slowly pan your phone around your play area to discover surfaces"; } else if (placementState == ePlacementState.OBJECT_PLACEMENT) { instructionsText.text = "Tap anywhere within the surface to spawn the " + gameObjectName; } else if (placementState == ePlacementState.SCALE_OBJECT) { scaleUI.SetActive(true); instructionsText.text = "Use the slider to adjust the size to fit your environment if neccesary"; } else if (placementState == ePlacementState.FINISH) { FinishObjectPlacement(); } }
void Awake() { m_RaycastManager = GetComponent <ARRaycastManager>(); arManager = GameObject.Find("ARManager").GetComponent <ARManager>(); }
private void Start() { ARManager.SetPlaneManagerActive(false); //ARManager.SetPointCloudManagerActive(false); }
private void Awake() { Debug.Log("ARManager awake"); Instance = this; }
void ChangeState(eTrashkitballState newState) { //Exiting State if (trashkitballState == eTrashkitballState.IN_PLAY) { if (newState != eTrashkitballState.GAME_OVER) { generalUI.SetActive(false); } } else if (trashkitballState == eTrashkitballState.GAME_OVER) { gameOverUI.SetActive(false); } trashkitballState = newState; //Entering State if (trashkitballState == eTrashkitballState.INIT) { ARManager.SetPlaneManagerActive(true); ARManager.SetPlanesInvisible(false); ARManager.TogglePlanePrefab(false); SpawnARObjectPlacement(); trashCount = 10; score = 0; currentDisplayedScore = 0; animatingScore = false; scoreText.text = "0"; trashCountText.text = trashCount.ToString(); } else if (trashkitballState == eTrashkitballState.IN_PLAY) { //Deactivate any planes that may be above the trashcan var planes = ARManager.arPlaneManager.trackables; foreach (var p in planes) { if (p.transform.position.y > (spawnedTrashcan.transform.position.y + spawnedTrashcan.GetComponentInChildren <MeshRenderer>().bounds.size.y / 2)) { //ARDebug.Log("Turned off plane above trashcan", 5); p.gameObject.SetActive(false); } } ARManager.SetPlaneManagerActive(false); ARManager.SetPlanesInvisible(true); generalUI.SetActive(true); //This is a stupid way to do this, use triggers in the animator and have them be able to call themselves of the Any state //canvasAnimator.Play("New State"); canvasAnimator.SetTrigger("Play"); StartCoroutine(SpawnTrashTimed(1.5f)); } else if (trashkitballState == eTrashkitballState.RESETTING_AR) { DestroyGameSessionObjects(); StartCoroutine(RestartLocalARSession()); } else if (trashkitballState == eTrashkitballState.GAME_OVER) { gameOverUI.SetActive(true); toCloseUI.SetActive(false); goScoreText.text = score.ToString(); canvasAnimator.SetTrigger("GameOver"); SoundManager.instance.PlaySound(gameOver_sfx); } }