public void BeginGame() { GameBegun = true; Vector3 origin = Vector3.forward; #if !UNITY_EDITOR origin = GameObject.FindWithTag("SkeletonOriginMarker").transform.position; #endif skeletonScatter.transform.position = origin; skeletonScatter.gameObject.SetActive(true); StartCoroutine(GenericCoroutines.DoAfterSeconds(() => { skeletonScatter.ScatterSkeleton(); skeletonManager.gameObject.SetActive(true); skeletonManager.transform.position = origin; }, 2)); Instantiate(welbyOriginPrefab).transform.position = origin; ARPlaneManager arpm = FindObjectOfType <ARPlaneManager>(); arpm.SetTrackablesActive(false); arpm.enabled = false; ARPointCloudManager arpcm = FindObjectOfType <ARPointCloudManager>(); arpcm.SetTrackablesActive(false); arpcm.enabled = false; PlaceOnPlane placeOnPlane = FindObjectOfType <PlaceOnPlane>(); placeOnPlane.enabled = false; placeOnPlane.placedPrefab.SetActive(false); }
// Start is called before the first frame update void Start() { arSessionOrigin = FindObjectOfType <ARSessionOrigin>(); arPointCloudManager = FindObjectOfType <ARPointCloudManager>(); arPointCloudManager.pointCloudsChanged += UpdatedCloudPoints; arVisualizer = GetComponent <ARPointCloudParticleVisualizer>(); }
private void Awake() { RaycastManager = GetComponent <ARRaycastManager>(); PointCloudManager = GetComponent <ARPointCloudManager>(); PlaneManager = GetComponent <ARPlaneManager>(); SessionOrigin = GetComponent <ARSessionOrigin>(); }
void ClearArPlanes() { //Clear planes ARPlaneManager planeManager = GameObject.FindObjectOfType <ARPlaneManager>(); if (planeManager) { planeManager.enabled = false; } ARPlane[] ArPlanes = GameObject.FindObjectsOfType <ARPlane>(); foreach (var currPlane in ArPlanes) { Destroy(currPlane.gameObject); } //Clear point cloud ARPointCloudManager pointCloudManager = GameObject.FindObjectOfType <ARPointCloudManager>(); if (pointCloudManager) { pointCloudManager.enabled = false; foreach (var point in pointCloudManager.trackables) { Destroy(point.gameObject); } } }
void Start() { Message = GameObject.Find("Message").GetComponent <TMP_Text>(); Message.text = "Start"; planeManager = GameObject.Find("AR Session Origin").GetComponent <ARPlaneManager>(); pointCloudManager = GameObject.Find("AR Session Origin").GetComponent <ARPointCloudManager>(); ReferencePointManager = GameObject.Find("AR Session Origin").GetComponent <ARReferencePointManager>(); if (PhotonNetwork.LocalPlayer.IsMasterClient) { if (!photonView.IsMine) { Message.text = "Start IsMasterClient but not PhotonVIewIsMine"; return; } Message.text = "MasterClient - please place common reference point by tapping a plane... "; RaycastManager = GameObject.Find("AR Session Origin").GetComponent <ARRaycastManager>(); m_AppMode = AppMode.TouchToHostCloudReferencePoint; } else { //Only MasterClient needs to see the environment interpretation (Points Planes) //Only Masterclient sets Cloud Reference Point VisualizePlanes(false); VisualizePoints(false); Message.text = "Not MasterClient"; m_AppMode = AppMode.ResolveCloudReferencePoint; } }
private void Construct(ICalibrateState _state, ARPlaneManager _planeManager, ARPointCloudManager _pointCloudManager, Settings _settings, DialogBuilder.Factory _dialogBuilderFactory) { m_state = _state; m_settings = _settings; m_planeManager = _planeManager; m_pointCloudManager = _pointCloudManager; m_dialogBuilderFactory = _dialogBuilderFactory; UIFader fader = GetComponent <UIFader> (); fader.RegisterStateCallbacks((State)_state); ((State)_state).m_enteredState += Reset; m_planeSatisfaction = new ReactiveProperty <int> (); m_pointSatisfaction = new ReactiveProperty <int> (); m_resetButton.onClick.AddListener(Reset); m_skipButton.onClick.AddListener(OnSkipButtonPressed); gameObject.SetActive(false); }
void Awake() { arRaycastManager = GetComponent <ARRaycastManager>(); aRSessionOrigin = GetComponent <ARSessionOrigin>(); aRplaneManager = GetComponent <ARPlaneManager>(); pCloudManager = GetComponent <ARPointCloudManager>(); scaleSlider.onValueChanged.AddListener(ScaleChanged); togglePlaneDetection.onClick.AddListener(ToggleDetection); }
// Start is called before the first frame update void Start() { arOrigin = FindObjectOfType <ARSessionOrigin>(); arSession = FindObjectOfType <ARSession>(); arPlaneManager = FindObjectOfType <ARPlaneManager>(); arPointCloudManager = FindObjectOfType <ARPointCloudManager>(); startTouchTime = endTouchTime = 0.0f; }
/// <summary> /// Initializes the aRRaycastManager and the pointCloudManager /// </summary> private void initARManagerScripts() { aRRaycastManager = FindObjectOfType <ARRaycastManager>(); pointCloudManager = FindObjectOfType <ARPointCloudManager>(); if (aRRaycastManager == null || pointCloudManager == null) { logger.Log("Error in the CustomAnchorManager.initGlobals(), pointCloudManager and RayCastmanager should not be null!!", TextState.ERROR); } logger.Log("Globals initialized."); }
void Awake() { arRaycastManager = GetComponent <ARRaycastManager>(); arReferencePointManager = GetComponent <ARReferencePointManager>(); arPointCloudManager = GetComponent <ARPointCloudManager>(); toggleButton.onClick.AddListener(ToggleDetection); clearReferencePointsButton.onClick.AddListener(ClearReferencePoints); debugLog.gameObject.SetActive(false); }
void Awake() { session = FindObjectOfType <ARSession>(); sessionGameObject = session.gameObject; sessionOrigin = FindObjectOfType <ARSessionOrigin>(); planeManager = GetComponent <ARPlaneManager>(); pointCloudManager = GetComponent <ARPointCloudManager>(); rayManager = GetComponent <ARRaycastManager>(); anchorManager = GetComponent <ARAnchorManager>(); }
void Awake() { m_RaycastManager = GetComponent <ARRaycastManager>(); ARplaneManager = GetComponent <ARPlaneManager>(); ARpointCloudManager = GetComponent <ARPointCloudManager>(); ARplaneManager.planesChanged += PlaneChanged; if (ARpointCloudManager != null) { ARpointCloudManager.pointCloudsChanged += PointChanged; } }
void EnablePoints() { ARPointCloudManager pointManager = m_SessionOrigin.GetComponent <ARPointCloudManager>(); List <ARPointCloud> allPoints = new List <ARPointCloud>(); pointManager.enabled = true; foreach (var point in pointManager.trackables) { point.gameObject.SetActive(true); } pointsDisabled = false; }
void Awake() { arPlaneManager = GetComponent<ARPlaneManager>(); arPointCloudManager = GetComponent<ARPointCloudManager>(); arPlaneManager.planesChanged += PlanesChanged; #if UNITY_EDITOR OnInitialized?.Invoke(); Initialized = true; AllowCloudAnchorDelay = false; arPlaneManager.enabled = false; arPointCloudManager.enabled = false; #endif }
void Start() { aRPointCloudManager = FindObjectOfType <ARPointCloudManager>(); cloudSystem = GetComponent <ParticleSystem>(); aRPointCloudManager.pointCloudsChanged += CloudUpdate; color = cloudSystem.main.startColor.color; size = cloudSystem.main.startSize.constant; VoxelSet = new VoxelSet1(0.02f) { CheckRadix = true, Online2 = online2 }; ReadFle(); }
// Start is called before the first frame update void Start() { aRPointCloudManager = FindObjectOfType <ARPointCloudManager>(); if (aRPointCloudManager == null) { throw new UnityException("No ARPointCloudManager in the scene"); } //voxelSet = new VoxelSet(); voxelSet.ChangeSize(voxelSize); voxelSet.CheckRadix = useRadix; voxelSet.SmartUpdate = smartUpdate; voxelSet.SmartUpdateIterations = smartUpdateIterations; aRPointCloudManager.pointCloudsChanged += ARPointCloudManager_pointCloudsChanged; }
// Use this for initialization protected virtual void Start() { // map static debug flag if (_Debug.HasValue) { DebugMode = _Debug.Value; } // find sessionOrigin in scene if not referenced if (ARSessionOrigin == null) { ARSessionOrigin = FindObjectOfType <ARSessionOrigin>(); } // find planeManager in scene if not referenced if (ARPlaneManager == null) { ARPlaneManager = FindObjectOfType <ARPlaneManager>(); } if (ARPlaneManager != null) { // set plane detection flags ARPlaneManager.detectionFlags = PlaneTypes; } // find pointCloudManager in scene if not referenced if (ARPointCloudManager == null) { ARPointCloudManager = FindObjectOfType <ARPointCloudManager>(); } // setup Plane & Cloud Prefabs SetupARPrefabs(); // subscribe to AR Events to track Ready state SubscribeAREvents(); // editor set ready because there are no AR Events triggered if (Application.isEditor) { isTracking = true; hasPlanes = true; CheckARReadyState(); } }
private void Init() { updatedPoints = new List <Vector3>(); updatedPoints.Clear(); Debug.Log("Initializing point cloud manager...."); // Look for ARPointCloudManager if not assigned if (pointCloudManager == null) { Debug.Log("pointCloudManager is null!!"); pointCloudManager = Camera.main.gameObject.GetComponentInParent <ARPointCloudManager>(); } pointCloudManager.pointCloudsChanged += OnPointCloudsChanged; timerManager = timerManager.GetComponent <TimerManager>(); }
void IFunctionalityProvider.LoadProvider() { ARFoundationSessionProvider.RequireARSession(); var currentSession = ARFoundationSessionProvider.currentSession; if (currentSession) { m_ARPointCloudManager = UnityEngine.Object.FindObjectOfType <ARPointCloudManager>(); if (!m_ARPointCloudManager) { m_ARPointCloudManager = currentSession.gameObject.AddComponent <ARPointCloudManager>(); m_ARPointCloudManager.hideFlags = HideFlags.DontSave; m_NewARPointCloudManager = m_ARPointCloudManager; } m_ARPointCloudManager.pointCloudsChanged += ARPointCloudManagerOnPointCloudsChanged; } #if UNITY_EDITOR var data = new PointCloudData(); m_Identifiers = new NativeArray <ulong>(k_NumPoints, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_Positions = new NativeArray <Vector3>(k_NumPoints, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_ConfidenceValues = new NativeArray <float>(k_NumPoints, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); for (var i = 0; i < k_NumPoints; i++) { m_Identifiers[i] = (ulong)i; m_Positions[i] = Random.insideUnitSphere * k_PointCloudSize; m_ConfidenceValues[i] = Random.Range(0, 1); } data.Identifiers = new NativeSlice <ulong>(m_Identifiers); data.Positions = new NativeSlice <Vector3>(m_Positions); data.ConfidenceValues = new NativeSlice <float>(m_ConfidenceValues); m_Data[MarsTrackableId.Create()] = data; EditorApplication.delayCall += () => { if (PointCloudUpdated != null) { PointCloudUpdated(GetPoints()); } }; #endif }
virtual protected void Start() { InitMesh(); m_MainCamera = Camera.main; camPrevPos = m_MainCamera.transform.position; camPrevRot = m_MainCamera.transform.rotation; m_AutomaticCapture = GetComponent <AutomaticCapture>(); m_ArPointCloudManager = FindObjectOfType <ARPointCloudManager>(); m_CaptureButtonIcon.sprite = m_StartCaptureSprite; if (m_AutomaticCapture != null) { m_AutomaticCapture.OnImageUploaded += OnImageUploaded; } if (m_ArPointCloudManager != null) { m_ArPointCloudManager.pointCloudsChanged += PointCloudManager_pointCloudsChanged; } }
public override void FinishInit() { base.FinishInit(); ARPlaneManager planeManager = sceneObj.GetComponentInChildren <ARPlaneManager>(); List <ARPlane> planes = new List <ARPlane>(); planeManager.GetAllPlanes(planes); for (int i = 0; i < planes.Count; i++) { GameObject.Destroy(planes[i].gameObject); } planeManager.enabled = false; ARPointCloudManager cloudManager = sceneObj.GetComponentInChildren <ARPointCloudManager>(); if (cloudManager.pointCloud != null) { GameObject.Destroy(cloudManager.pointCloud.gameObject); } cloudManager.enabled = false; sceneObj.GetComponentInChildren <ARReferencePointManager>().enabled = false; }
// Start is called before the first frame update void Awake() { Screen.sleepTimeout = SleepTimeout.NeverSleep; //disable screen dimming on Mobile Devices. We might want to change so that it dims while in the menu. Application.targetFrameRate = 60; //Set framerate to 60hz. This improves plane detection in my experience. arOrigin = FindObjectOfType <ARSessionOrigin>(); arRaycast = arOrigin.GetComponent <ARRaycastManager>(); arPlanes = arOrigin.GetComponent <ARPlaneManager>(); arCloud = arOrigin.GetComponent <ARPointCloudManager>(); arCameraManager = Camera.main.GetComponent <ARCameraManager>(); arImageManager = arOrigin.GetComponent <ARTrackedImageManager>(); mapCreator = GetComponentInChildren <MapCreator>(); spawnedCans = new Dictionary <TrackableId, GameObject>(); spawnPoints = new List <Vector3>(); placeButton = GameObject.Find("PlaceScene"); resetButton = GameObject.Find("Reset"); resetButton.SetActive(false); }
// Start is called before the first frame update void Start() { isPlaying = false; isOriginFound = false; isVisible = true; isGPSEnabled = false; isAtOriginPoint = false; arRaycastManager = FindObjectOfType <ARRaycastManager>(); arPlaneManager = FindObjectOfType <ARPlaneManager>(); arPointCloudManager = FindObjectOfType <ARPointCloudManager>(); GetScreenPoints(); initialCoordinates.gpsLat = 12.99699f; initialCoordinates.gpsLong = 77.62651f; finalCoordinates.gpsLat = 12.99673f; finalCoordinates.gpsLong = 77.62669f; StartCoroutine(GenerateRoutePrefabs()); }
void Awake() { arRaycastManager = GetComponent <ARRaycastManager>(); arPointCloudManager = GetComponent <ARPointCloudManager>(); }
private void Awake() { arReferencePointManager = GetComponent <ARReferencePointManager>(); arPlaneManager = GetComponent <ARPlaneManager>(); arPointCloudManager = GetComponent <ARPointCloudManager>(); }
void Awake() { m_ReferencePointManager = GetComponent <ARReferencePointManager>(); m_ReferencePointCloudManager = GetComponent <ARPointCloudManager>(); m_ReferencePoints = new List <ARReferencePoint>(); }
private void Awake() { m_ARPlaneManager = GetComponent <ARPlaneManager>(); m_ARPiontCloudManager = GetComponent <ARPointCloudManager>(); }
private void Start() { aRPointCloudManager = GetComponent <ARPointCloudManager>(); aRPlaneManager = GetComponent <ARPlaneManager>(); }
private void Start() { this._aRPointCloudManager = GetComponent <ARPointCloudManager>(); }
public void ARScene() { EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), "Assets/Scenes/Menu.unity", true); if (arCloudDetection == false && arPlaneDetection == false) { Debug.Log("Choose Tracking Methode !"); } else { var newScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); EditorSceneManager.SaveScene(newScene, "Assets/Scenes/ARScene.unity", true); Scene sceneRef = EditorSceneManager.OpenScene("Assets/Scenes/ARScene.unity", OpenSceneMode.Single); GameObject _directionLight = new GameObject("Directional light"); _directionLight.AddComponent <Light>(); _directionLight.GetComponent <Light>().type = LightType.Directional; _directionLight.transform.Rotate(50, -30, 0); GameObject scriptManager = new GameObject("ScriptManager"); scriptManager.AddComponent <pluginAR>(); GameObject _ARsession = new GameObject("ARsession"); _ARsession.AddComponent <ARSession>(); _ARsession.AddComponent <ARInputManager>(); GameObject _ARsessionOrigin = new GameObject("AR Session Origin"); _ARsessionOrigin.tag = "GameController"; _ARsessionOrigin.AddComponent <ARSessionOrigin>(); _ARsessionOrigin.AddComponent <ARPlaneManager>(); _ARsessionOrigin.AddComponent <ARPointCloudManager>(); _ARsessionOrigin.AddComponent <TapToPlace>(); _ARsessionOrigin.AddComponent <InteractManager>(); _ARsessionOrigin.GetComponent <TapToPlace>()._objectToPlace = Resources.Load("3D/_3DModel") as GameObject; GameObject _ARcamera = new GameObject("AR Camera"); _ARcamera.tag = "MainCamera"; _ARcamera.AddComponent <Camera>(); _ARcamera.AddComponent <TrackedPoseDriver>(); _ARcamera.AddComponent <ARCameraManager>(); _ARcamera.AddComponent <ARCameraBackground>(); _ARcamera.GetComponent <Camera>().clearFlags = CameraClearFlags.SolidColor; _ARcamera.GetComponent <Camera>().farClipPlane = 20; _ARcamera.GetComponent <Camera>().nearClipPlane = 0.1f; _ARcamera.GetComponent <TrackedPoseDriver>().SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.ColorCamera); _ARcamera.GetComponent <Camera>().backgroundColor = Color.black; _ARcamera.transform.SetParent(_ARsessionOrigin.transform, false); Material _customDebugBorder = new Material(Shader.Find("Standard")); Material _customDebugPlane = new Material(Shader.Find("Standard")); Material _customDebugPoint = new Material(Shader.Find("Standard")); AssetDatabase.CreateAsset(_customDebugBorder, "Assets/Editor/Resources/MATERIALS/customDebugBorder.mat"); AssetDatabase.CreateAsset(_customDebugPlane, "Assets/Editor/Resources/MATERIALS/PlaneRenderer.mat"); AssetDatabase.CreateAsset(_customDebugPoint, "Assets/Editor/Resources/MATERIALS/PointRenderer.mat"); _customLine = Resources.Load("MATERIALS/customDebugBorder") as Material; _customLine.color = new Color32(80, 80, 80, 255); _customLine.SetFloat("_Mode", 3); _customPlane = Resources.Load("MATERIALS/PlaneRenderer") as Material; _customPlane.SetFloat("_Mode", 3); _customPlane.color = new Color32(5, 5, 5, 5); _customPoint = Resources.Load("MATERIALS/PointRenderer") as Material; _customPoint.SetFloat("_Mode", 1); _customPoint.color = new Color(255, 210, 0, 50); _particleTexture = Resources.Load("2D/_Particle") as Texture; _customPoint.mainTexture = _particleTexture; if (arPlaneDetection == true) { GameObject _ARplane = new GameObject("AR Default Plane"); _ARplane.AddComponent <ARPlane>(); _ARplane.AddComponent <ARPlaneMeshVisualizer>(); _ARplane.AddComponent <MeshCollider>(); _ARplane.AddComponent <MeshFilter>(); _ARplane.AddComponent <MeshRenderer>(); _ARplane.AddComponent <LineRenderer>(); _ARplane.GetComponent <LineRenderer>().startWidth = 0.010F; _ARplane.GetComponent <LineRenderer>().receiveShadows = false; _ARplane.GetComponent <LineRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; _ARplane.GetComponent <LineRenderer>().material = _customLine; _ARplane.GetComponent <LineRenderer>().loop = true; _ARplane.GetComponent <LineRenderer>().numCornerVertices = 4; _ARplane.GetComponent <LineRenderer>().numCapVertices = 4; _ARplane.GetComponent <LineRenderer>().useWorldSpace = false; _ARplane.GetComponent <MeshRenderer>().material = _customPlane; m_arPlaneManager = FindObjectOfType <ARPlaneManager>(); m_arPlaneManager.planePrefab = FindObjectOfType <ARPlane>().gameObject; } if (arCloudDetection == true) { GameObject _ARPointCloud = new GameObject("AR Default Point Cloud"); _ARPointCloud.AddComponent <ARPointCloud>(); _ARPointCloud.AddComponent <ARPointCloudParticleVisualizer>(); _ARPointCloud.AddComponent <ParticleSystem>(); _ARPointCloud.GetComponent <ParticleSystem>().startSize = 0.01f; _ARPointCloud.GetComponent <ParticleSystem>().playOnAwake = false; _ARPointCloud.GetComponent <ParticleSystem>().loop = false; _ARPointCloud.GetComponent <ParticleSystem>().scalingMode = ParticleSystemScalingMode.Hierarchy; _ARPointCloud.GetComponent <ParticleSystem>().startColor = new Color(253, 184, 19, 255); _ARPointCloud.GetComponent <ParticleSystem>().enableEmission = false; var _paramShape = _ARPointCloud.GetComponent <ParticleSystem>().shape; var _paramEmission = _ARPointCloud.GetComponent <ParticleSystem>().emission; _paramEmission.enabled = false; _paramShape.enabled = false; _ARPointCloud.GetComponent <ParticleSystemRenderer>().material = _customPoint; m_arPointCloud = FindObjectOfType <ARPointCloudManager>(); m_arPointCloud.pointCloudPrefab = FindObjectOfType <ARPointCloud>().gameObject; } GameObject _placementIndicator = new GameObject("Placement Indicator"); GameObject _placementRef = GameObject.CreatePrimitive(PrimitiveType.Quad); _placementIndicator.AddComponent <PlacementIndicator>(); _placementRef.transform.Rotate(90.0f, 0f, 0f); _placementRef.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); Material _imageRef = new Material(Shader.Find("Standard")); AssetDatabase.CreateAsset(_imageRef, "Assets/Editor/Resources/MATERIALS/TrackingMaterial.mat"); _customTracker = Resources.Load("MATERIALS/TrackingMaterial") as Material; _indicatorTexture = Resources.Load("2D/_TapToPlace") as Texture; _customTracker.mainTexture = _indicatorTexture; _customTracker.SetFloat("_Mode", 1); _customTracker.color = new Color(255, 255, 0, 255); _placementRef.GetComponent <Renderer>().material = _imageRef; _placementRef.transform.SetParent(_placementIndicator.transform, false); m_arSess = FindObjectOfType <ARSessionOrigin>(); m_arSess.camera = FindObjectOfType <Camera>(); AssetDatabase.Refresh(); EditorSceneManager.SaveScene(sceneRef); } }