This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void LookAtY(this Transform transform, Vector3 point) | |
{ | |
var lookPos = point - transform.position; | |
lookPos.y = 0; | |
var rotation = Quaternion.LookRotation(lookPos); | |
transform.rotation = rotation; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void LookAtY(this Transform transform, Vector3 point) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class TransformExtensions | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class Vector3Extensions | |
{ | |
public static Vector3 Flattened(this Vector3 vector) | |
{ | |
return new Vector3(vector.x, 0f, vector.z); | |
} | |
public static float DistanceFlat(this Vector3 origin, Vector3 destination) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void LookAtY(this Transform transform, Vector3 point) | |
{ | |
var lookPos = point - transform.position; | |
lookPos.y = 0; | |
var rotation = Quaternion.LookRotation(lookPos); | |
transform.rotation = rotation; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public static class ParticleSystemExtension | |
{ | |
public static void EnableEmission(this ParticleSystem particleSystem, bool enabled) | |
{ | |
var emission = particleSystem.emission; | |
emission.enabled = enabled; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void HandlePadClicked(object sender, ClickedEventArgs e) | |
{ | |
if (e.padY < 0) | |
SelectPreviousPrimitive(); | |
else | |
SelectNextPrimitive(); | |
} | |
private void SelectNextPrimitive() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Primitive Spawning | |
private void HandleTriggerClicked(object sender, ClickedEventArgs e) | |
{ | |
SpawnCurrentPrimitiveAtController(); | |
} | |
private void SpawnCurrentPrimitiveAtController() | |
{ | |
var spawnedPrimitive = GameObject.CreatePrimitive(_currentPrimitiveType); | |
spawnedPrimitive.transform.position = transform.position; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private SteamVR_TrackedController _controller; | |
private PrimitiveType _currentPrimitiveType = PrimitiveType.Sphere; | |
private void OnEnable() | |
{ | |
_controller = GetComponent<SteamVR_TrackedController>(); | |
_controller.TriggerClicked += HandleTriggerClicked; | |
_controller.PadClicked += HandlePadClicked; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public event ClickedEventHandler MenuButtonClicked; | |
public event ClickedEventHandler MenuButtonUnclicked; | |
public event ClickedEventHandler TriggerClicked; | |
public event ClickedEventHandler TriggerUnclicked; | |
public event ClickedEventHandler SteamClicked; | |
public event ClickedEventHandler PadClicked; | |
public event ClickedEventHandler PadUnclicked; | |
public event ClickedEventHandler PadTouched; | |
public event ClickedEventHandler PadUntouched; | |
public event ClickedEventHandler Gripped; |