private void ConfigureCollider(TeleportationProperty teleportationAnchor) { BoxCollider propertyCollider = teleportationAnchor.GetComponent <BoxCollider>(); propertyCollider.center = new Vector3(0f, 0.02f, 0f); propertyCollider.size = new Vector3(1f, 0.01f, 1f); }
private void ConfigureTeleportationAnchor(TeleportationProperty teleportationAnchor, Transform prefabTransform) { TeleportationAnchor teleportAnchor = teleportationAnchor.GetComponent <TeleportationAnchor>(); teleportAnchor.teleportAnchorTransform = prefabTransform; teleportAnchor.interactionLayerMask = 1 << teleportLayer; teleportAnchor.customReticle = Resources.Load <GameObject>(ReticlePrefab); teleportAnchor.matchOrientation = MatchOrientation.TargetUpAndForward; }
private void OnEnable() { TeleportationProperty teleportationProperty = target as TeleportationProperty; TeleportationAnchor teleportAnchor = teleportationProperty.GetComponent <TeleportationAnchor>(); if (teleportationProperty.transform.childCount != 0 && teleportAnchor.teleportAnchorTransform.name == AnchorPrefabName) { isSetup = true; } }
private GameObject CreateVisualEffect(TeleportationProperty teleportationAnchor) { Transform anchorTransform = teleportationAnchor.transform; GameObject anchorPrefab = Instantiate(Resources.Load <GameObject>(AnchorPrefabName)); anchorPrefab.name = anchorPrefab.name.Remove(AnchorPrefabName.Length); anchorPrefab.transform.SetPositionAndRotation((anchorTransform.position + (Vector3.up * 0.01f)), anchorTransform.rotation); anchorPrefab.transform.SetParent(anchorTransform); teleportationAnchor.gameObject.layer = teleportLayer; return(anchorPrefab); }
private void ConfigureDefaultTeleportationAnchor(TeleportationProperty teleportationAnchor) { teleportLayer = LayerMask.NameToLayer(TeleportLayerName); try { GameObject anchorPrefab = CreateVisualEffect(teleportationAnchor); ConfigureTeleportationAnchor(teleportationAnchor, anchorPrefab.transform); ConfigureCollider(teleportationAnchor); isSetup = true; } catch (Exception e) { Debug.LogError($"There was an exception of type '{e.GetType()}' when trying to setup {name} as default Teleportation Anchor\n{e.Message}", teleportationAnchor.gameObject); } }