Files
old-profesor-atom/Profesor Atom/Library/metadata/24/24c7d7d77dd0d2a4b8e1ad129b170ee3

104 lines
7.4 KiB
Plaintext
Raw Normal View History

2017-05-17 12:25:25 +03:00
a<1D>5.6.1f1<00><><EFBFBD><EFBFBD><00><><EFBFBD>0<05><><EFBFBD><EFBFBD>L.`?^<5E>0D7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00><00><00><00><00><00><00><00><00>#<00><00>+H<00>3<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00> Q<00>j<00>
<00><00>< <00><00>H H<00>Z<00><><EFBFBD><EFBFBD> <00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00><00><00>g<00><00><00><00><00><00>#<00><00>+v~<00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><> <00><00><>!<00><00><>"<00><00><>#<00><00>$<00><00>%<00><00>&<00><00>#<00><><EFBFBD><EFBFBD>'<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>(<00><00><00><00>)H<00>j<00><><EFBFBD><EFBFBD><EFBFBD>*<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>+@<00><00><00>,Q<00>j<00>-<00><00>*.<00><00>8/AssetMetaDataguiddata[0]data[1]data[2]data[3]pathNametimeCreatedoriginalChangesetoriginalNameoriginalParentHash128originalDigestbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]labelsassetStoreReflicenseType <00><>z{<0E>@<40><05><>5^(<28>H'<00>7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00> <00><00> <00><00>#.<00>,<00><00><><00> <00><00>#.<00>,H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>
Q<00>j<00> <00><00>5<00><><EFBFBD><EFBFBD> <00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> <00><00><00><00><00>j<00><><EFBFBD><EFBFBD><EFBFBD><00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>y<00>
<00> <00><00>#.<00>, <00>I@<00><00>X @<00><00>#.<00>,H<00>]<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>H<00>h<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>!Q<00>j<00>"H<00>z<00><><EFBFBD><EFBFBD>#<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>$@<00><00><00>%Q<00>j<00>&MonoImporterPPtr<EditorExtension>m_FileIDm_PathIDm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariants<00><><EFBFBD>8-l'<27><>愁h<E68481>ΐA,<00><00>7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00><00><00> <00><00>.<00><00><00><><00> <00><00>.<00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>
Q<00>j<00> H<00><><00><><EFBFBD><EFBFBD><EFBFBD> <01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>Q<00>j<00><00><00>(<00><><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD><01><00><00><00><00>j<00><><EFBFBD><EFBFBD><EFBFBD><01>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>y<00>
<00> <00><00>.<00>y<00>< <00><00>.<00><00><00>CH<00>T<00><><EFBFBD><EFBFBD><10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>!Q<00>j<00>"H<00>`<00><><EFBFBD><EFBFBD>#<10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>$@<00><00><00>%Q<00>j<00>&H<00>l<00><><EFBFBD><EFBFBD>'<10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>(@<00><00><00>)Q<00>j<00>*L<00>{+PPtr<EditorExtension>m_FileIDm_PathIDm_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespacem_AssemblyNamem_IsEditorScript<00><00>@<00>y<EFBFBD><00><00> B|}}<7D> -J<><1E>!<21>q<EFBFBD>>+Assets/SteamVR/Extras/SteamVR_Teleporter.cs<00>8AUSteamVR_Teleporter^ using UnityEngine;
using System.Collections;
public class SteamVR_Teleporter : MonoBehaviour
{
public enum TeleportType
{
TeleportTypeUseTerrain,
TeleportTypeUseCollider,
TeleportTypeUseZeroY
}
public bool teleportOnClick = false;
public TeleportType teleportType = TeleportType.TeleportTypeUseZeroY;
Transform reference
{
get
{
var top = SteamVR_Render.Top();
return (top != null) ? top.origin : null;
}
}
void Start()
{
var trackedController = GetComponent<SteamVR_TrackedController>();
if (trackedController == null)
{
trackedController = gameObject.AddComponent<SteamVR_TrackedController>();
}
trackedController.TriggerClicked += new ClickedEventHandler(DoClick);
if (teleportType == TeleportType.TeleportTypeUseTerrain)
{
// Start the player at the level of the terrain
var t = reference;
if (t != null)
t.position = new Vector3(t.position.x, Terrain.activeTerrain.SampleHeight(t.position), t.position.z);
}
}
void DoClick(object sender, ClickedEventArgs e)
{
if (teleportOnClick)
{
// First get the current Transform of the the reference space (i.e. the Play Area, e.g. CameraRig prefab)
var t = reference;
if (t == null)
return;
// Get the current Y position of the reference space
float refY = t.position.y;
// Create a plane at the Y position of the Play Area
// Then create a Ray from the origin of the controller in the direction that the controller is pointing
Plane plane = new Plane(Vector3.up, -refY);
Ray ray = new Ray(this.transform.position, transform.forward);
// Set defaults
bool hasGroundTarget = false;
float dist = 0f;
if (teleportType == TeleportType.TeleportTypeUseTerrain) // If we picked to use the terrain
{
RaycastHit hitInfo;
TerrainCollider tc = Terrain.activeTerrain.GetComponent<TerrainCollider>();
hasGroundTarget = tc.Raycast(ray, out hitInfo, 1000f);
dist = hitInfo.distance;
}
else if (teleportType == TeleportType.TeleportTypeUseCollider) // If we picked to use the collider
{
RaycastHit hitInfo;
hasGroundTarget = Physics.Raycast(ray, out hitInfo);
dist = hitInfo.distance;
}
else // If we're just staying flat on the current Y axis
{
// Intersect a ray with the plane that was created earlier
// and output the distance along the ray that it intersects
hasGroundTarget = plane.Raycast(ray, out dist);
}
if (hasGroundTarget)
{
// Get the current Camera (head) position on the ground relative to the world
Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.position.x, refY, SteamVR_Render.Top().head.position.z);
// We need to translate the reference space along the same vector
// that is between the head's position on the ground and the intersection point on the ground
// i.e. intersectionPoint - headPosOnGround = translateVector
// currentReferencePosition + translateVector = finalPosition
t.position = t.position + (ray.origin + (ray.direction * dist)) - headPosOnGround;
}
}
}
}
SteamVR_TeleporterAssembly-CSharp.dll