Skip to content

Instantly share code, notes, and snippets.

View ciro-unity's full-sized avatar
💭
I may be slow to respond.

Ciro Continisio ciro-unity

💭
I may be slow to respond.
View GitHub Profile
@ciro-unity
ciro-unity / CursorLocker.cs
Created February 21, 2022 20:19
Simple script to lock/unlock the cursor in Unity using an input. Requires the "new" Input System package to work.
using UnityEngine;
using UnityEngine.InputSystem;
public class CursorLocker : MonoBehaviour
{
public InputAction lockCursorAction;
private bool _cursorLocked;
private void Start()
@ciro-unity
ciro-unity / TimelineBinder.cs
Last active January 22, 2023 20:57
A script that provides a simple example of how to dynamically assign the bound object of a track in Unity's Timeline. In this case, an Animator is assigned to an Animation track as soon as the execution starts.
using System.Collections;
using UnityEngine;
using UnityEngine.Playables;
public class TimelineBinder : MonoBehaviour
{
public PlayableDirector playableDirector; //the component which references the Timeline we want to target
public Animator objectToBind; //bound object is an Animator because we are targeting an Animation track
public string trackName;
@ciro-unity
ciro-unity / MainLightNode.cs
Last active October 24, 2020 06:47
A custom node for Unity's ShaderGraph to capture lighting and use it into the shader. Works as of July 2018, but the APIs might change!
//This API to create new nodes has been deprecated in early 2019.
//This means that if you are on a more recent version of Shader Graph and Universal Render Pipeline, you should use instead a pre-made node, which acts like a container that allows you to inject custom HLSL code into Shader Graph without the need to create a node from scratch.
//Please use the new node, not the C# API described here.
//
//You can find more details about that node in the Docs: https://docs.unity3d.com/Packages/com.unity.shadergraph@6.7/manual/Custom-Function-Node.html
//I also blogged about it here: https://connect.unity.com/p/adding-your-own-hlsl-code-to-shader-graph-the-custom-function-node
//
//If you are still on a very old version of Lightweight Render Pipeline (you shouldn't!!), you can still see the C# code for this custom node by rolling back to a previous version.
@ciro-unity
ciro-unity / MainLightNode.cs
Created July 26, 2018 18:20
A custom node for Unity's ShaderGraph to capture lighting and use it into the shader.Works as of July 2018, but the APIs might change!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.ShaderGraph;
using System.Reflection;
[Title("Custom", "Main Light")]
public class MainLightNode : CodeFunctionNode
{
public override bool hasPreview {get {return false;}}
@ciro-unity
ciro-unity / InjectionTool.cs
Last active December 1, 2016 16:45
An Editor script that speeds up delivery of code-heavy workshops. It that allows to pull different versions of the code directly inside the Unity Project, by selecting a step from the top bar menu.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEditor;
using UnityEditor.SceneManagement;
using System;
using System.IO;
public class InjectionTool : MonoBehaviour
{