public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { dstManager.AddComponentData(entity, new LaserPointerState { State = _baseState, StateJustChangedToOn = false }); dstManager.AddComponentData(entity, new LaserPointerVisibility { DisappearanceSpeed = _disappearanceSpeed }); dstManager.AddComponentData(entity, new LaserPointerWidth { BaseWidth = _pointerWidth }); VRRaycastAuthoring raycastAuthoring = GetComponent <VRRaycastAuthoring>(); dstManager.AddComponentData(entity, new LaserPointerLength { BaseLength = raycastAuthoring.MaxRaycastDistance, ShouldPointTo3DObjectsCenter = _shouldPointTo3DObjectCenter, ShouldPointToUICenter = _shouldPointToUICenter }); dstManager.AddComponentData(entity, new DestroyOnSceneUnloaded()); #if UNITY_EDITOR // Set the name of the entity in Editor Mode for the Entity Debugger Window dstManager.SetName(entity, string.Format("Laser Pointer {0}", raycastAuthoring.RayOrigin.ToString())); #endif Destroy(GetComponent <ConvertToEntity>()); Destroy(this); }
protected override void Reset() { base.Reset(); VRRaycastAuthoring.CheckSceneContainsRaycaster(); }
/// <summary> /// Add all components required to calculate the Laser Pointer position and width /// </summary> /// <param name="entity">the entity to which we want to add the components</param> /// <param name="entityManager">The entity manager, so we don't have to fetch it again</param> /// <param name="raycastAuthoring">The raycast authoring to set the base distance of the line</param> public void AddLaserPointerComponents(ref Entity entity, ref EntityManager entityManager, VRRaycastAuthoring raycastAuthoring) { entityManager.AddComponentData(entity, new LaserPointerState { State = _baseState, StateJustChangedToOn = false }); if (_disappearanceSpeed > 0.0f) { entityManager.AddComponentData(entity, new LaserPointerVisibility { DisappearanceSpeed = _disappearanceSpeed, BaseWidth = _pointerWidth, CurrentWidth = _pointerWidth }); } entityManager.AddComponentData(entity, new LaserPointerLength { BaseLength = raycastAuthoring.MaxRaycastDistance, ShouldPointTo3DObjectsCenter = _shouldPointTo3DObjectCenter, ShouldPointToUICenter = _shouldPointToUICenter }); // Check if a line renderer is already present on the gameObject, and if not, add one if (GetComponent <LineRenderer>() == null) { var lineRenderer = gameObject.AddComponent <LineRenderer>(); lineRenderer.startWidth = _pointerWidth; lineRenderer.endWidth = _pointerWidth; lineRenderer.startColor = Color.blue; lineRenderer.endColor = Color.white; } // Check if a LaserLengthSetter is already present on the gameObject, and if not, add one if (GetComponent <LaserLengthSetter>() == null) { gameObject.AddComponent <LaserLengthSetter>(); } // Check if a LaserWidthSetter is already present on the gameObject, and if not, add one if (GetComponent <LaserWidthSetter>() == null) { gameObject.AddComponent <LaserWidthSetter>(); } #if UNITY_EDITOR // Set the name of the entity in Editor Mode for the Entity Debugger Window entityManager.SetName(entity, string.Format("Laser Pointer {0}", raycastAuthoring.RayOrigin.ToString())); #endif Destroy(this); }