Skip to content

Instantly share code, notes, and snippets.

@shanecelis
shanecelis / DragManipulator.cs
Last active May 17, 2025 14:16
This manipulator makes a visual element draggable at runtime in Unity's UIToolkit.
/* Original code[1] Copyright (c) 2022 Shane Celis[2]
Licensed under the MIT License[3]
[1]: https://gist.github.com/shanecelis/b6fb3fe8ed5356be1a3aeeb9e7d2c145
[2]: https://twitter.com/shanecelis
[3]: https://opensource.org/licenses/MIT
*/
using UnityEngine;
using UnityEngine.UIElements;
@unitycoder
unitycoder / LineDrawer.cs
Created November 5, 2021 20:09
Drawing a line with Unity UI Toolkit
// Drawing a line with UITK https://forum.unity.com/threads/drawing-a-line-with-uitk.1193470/
public class LineDrawer : VisualElement
{
private Vector3 startPos, endPos;
private float thickness;
public LineDrawer(Vector3 pos1, Vector3 pos2, float width)
{
startPos = pos1;
endPos = pos2;
@corycorvus
corycorvus / DetectVR.cs
Last active May 14, 2023 08:29
Detect VR HMD and controller
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using Valve.VR;
/// <summary>
/// These are a few different ways to detect the current VR HMD and controller type.
/// - Unity XR api
/// - Unity Input api
/// - SteamVR plugin
@yasirkula
yasirkula / FileDownloader.cs
Last active April 21, 2025 13:34
C# Download Public File From Google Drive™ (works for large files as well)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Text;
/* EXAMPLE USAGE
FileDownloader fileDownloader = new FileDownloader();
@kennir
kennir / CSVReader.cs
Created July 13, 2016 05:57
CSV Reader for unity
/*
CSVReader by Dock. (24/8/11)
http://starfruitgames.com
usage:
CSVReader.SplitCsvGrid(textString)
returns a 2D string array.
Drag onto a gameobject for a demo of CSV parsing.
@hecomi
hecomi / UnityCG.cginc
Created March 16, 2014 09:23
UnityCG.cginc@Unity 4.3.2f1
#ifndef UNITY_CG_INCLUDED
#define UNITY_CG_INCLUDED
#include "UnityShaderVariables.cginc"
#if SHADER_API_FLASH
uniform float4 unity_NPOTScale;