Skip to content

Instantly share code, notes, and snippets.

View AdamCarballo's full-sized avatar
🦔

Àdam Carballo AdamCarballo

🦔
View GitHub Profile
@AdamCarballo
AdamCarballo / WorldToScreen.cs
Created February 11, 2017 11:50
Unity - Get the WorldToScreenPosition() translated to be used with UI elements inside a Canvas.
using UnityEngine;
public class WorldToScreen : MonoBehaviour {
/// <summary>
/// Get the WorldToScreenPosition translated to be used with UI elements inside a Canvas.
/// </summary>
/// <param name="worldObj">Object in the world to follow.</param>
/// <param name="canvas">Canvas transform that holds the UI object we want to move.</param>
/// <param name="cam">Camera to calculate the screen position. If null will use Camera.main (optional).</param>
@AdamCarballo
AdamCarballo / CursorMode.cs
Last active February 23, 2018 08:35
Unity - Switch the current cursor mode, including Cursor.visible() and Cursor.lockState() in one function.
using UnityEngine;
public class CursorMode {
/// <summary>
/// Switch the current cursor mode to enabled, including Cursor.visible(true) and Cursor.lockState(None).
/// </summary>
public static void Enable() {
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;