Skip to content

Instantly share code, notes, and snippets.

View JT5D's full-sized avatar
💭
Multiversing...

JT5D JT5D

💭
Multiversing...
View GitHub Profile
@nemotoo
nemotoo / .gitattributes
Last active June 29, 2025 10:50
.gitattributes for Unity3D with git-lfs
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
@mstevenson
mstevenson / IEnumeratorExtension.cs
Created April 10, 2016 00:31
Execute a Unity Coroutine in one frame without yielding
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class IEnumeratorExtensions
{
/// <summary>
/// Execute an entire Unity Coroutine in one frame.
/// This is useful for testing coroutines with NUnit.
///
@michidk
michidk / TreeRandomizerWindow.cs
Created April 6, 2016 20:21
Unity3D Tree Randomizer
using System;
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using Random = UnityEngine.Random;
@michidk
michidk / TagManager.cs
Created March 21, 2016 13:41
Unity3D: a class which checks if a tag is defined. also could create new ones or remove them.
public static class TagManager
{
private const string TAG_MANAGER_PATH = "ProjectSettings/TagManager.asset";
public static bool ContainsTag(string tag)
{
SerializedProperty prop;
if (GetAssetDatabase(out prop))
{
for (int i = 0; i < prop.arraySize; i++)
@radiatoryang
radiatoryang / VRUtility.cs
Created March 4, 2016 19:30
a script I give to my Unity VR students that demonstrates a few useful "quality of VR" features for their games -- lowering visual quality for higher framerate, and HMD recentering
using UnityEngine;
using System.Collections;
using UnityEngine.VR; // you always need this to use special VR functions
public class VRUtility : MonoBehaviour {
// Use this for initialization
public void Start () {
// set render quality to 50%, sacrificing visual quality for higher FPS
@radiatoryang
radiatoryang / RaycastTargetTrigger.cs
Last active August 2, 2022 05:14
a script I give to my Unity VR classes to detect when the player is looking at something... put it on anything with a collider, and it'll know if it's being looked at or not
using UnityEngine;
using System.Collections;
using UnityEngine.VR; // we need this line here for InputTracking and VRSettings functions
// USAGE: put this on a thing you want the player to look at!
// this code will enable that thing to know if it is being looked at!
[RequireComponent (typeof(Collider)) ] // this thing needs a collider if we should look at it
public class RaycastTargetTrigger : MonoBehaviour {
@michidk
michidk / gist:6f076258f38f29be77cb
Created January 28, 2016 22:44
C# is awesome
These 3 pieces of codes, are all returning wether a list/dictionary has elements or not.
Normal:
int count = 0;
foreach (var ep in IPEndPoints)
{
if (ep.Value == null)
{
count++;
}
@treefortress
treefortress / ParticleScaler.cs
Last active October 7, 2019 04:29
Scale Unity ParticleSystem at Runtime
using UnityEngine;
public static class ParticleExtensions
{
/// Add Extension to the native ParticleSystem class.
/// eg: myParticleSystem.Scale(2);
public static void Scale(this ParticleSystem particles, float scale, bool includeChildren = true) {
ParticleScaler.Scale(particles, scale, includeChildren);
}
@mstevenson
mstevenson / DoForSeconds.cs
Created January 23, 2016 08:56
An alternative to Unity's WaitForSeconds yield instruction that invokes a callback during each Update.
/// <summary>
/// Yield on a DoForSeconds object within a coroutine and the supplied callback method
/// will be invoked during each Unity Update cycle.
///
/// Example: yield return DoForSeconds (1, (elapsed, duration) => { Debug.Log (elapsed/duration); });
/// </summary>
public class DoForSeconds : CustomYieldInstruction
{
public delegate void UpdateCallback (float elapsed, float duration);
@jaydenseric
jaydenseric / gource.sh
Last active October 14, 2021 14:33
Gource repo visualization
#!/bin/bash
# Uses Gource (http://gource.io) to generate a lossless PPM and a high quality MP4 visualizing the history of a Git repo.
# By Jayden Seric: https://gist.github.com/jaydenseric/df3263eb3c33856c11ce
# Install Gource and FFmpeg with Homebrew:
# brew install gource
# brew install ffmpeg