Skip to content

Instantly share code, notes, and snippets.

@Arakade
Arakade / AbstractGenericProtected.cs
Last active September 24, 2016 16:22
Class compiles in MonoDevelop Unity 3.5 full profile and VisualStudio but not Unity 5.4.0 - Unity bug 834988
using System;
namespace MiscCSharp {
public static class AbstractGenericProtected {
public static void Main(string[] args) {
var debugGraph = new DebugGraph { start = 5, end = 4, numRecords = 10 };
var floatSeries = new FloatSeries(debugGraph, "series1");
floatSeries.doStuff();
System.Console.WriteLine("All done");
@Arakade
Arakade / WIPController.cs.scaleAndSphere.patch
Created November 23, 2016 00:37
Patch to WIPController to account for scaling and allow SphereCast for grounded check
.../VR-Step/Scripts/WIPController.cs | 28 ++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/Assets/VR-Step/Scripts/WIPController.cs b/Assets/VR-Step/Scripts/WIPController.cs
index 2138c61..fa6e828 100644
--- a/Assets/VR-Step/Scripts/WIPController.cs
+++ b/Assets/VR-Step/Scripts/WIPController.cs
@@ -60,6 +60,12 @@ namespace VRStep
[Tooltip("Threshold on the accelerometer in the up direction of when to detect a jump")]
public float jumpDetectionThreshold = 1;
@Arakade
Arakade / SaveWithJsonDotNet.cs
Created March 19, 2017 15:57
Save something with JsonDotNet (Json.Net) using Serializable attribute
static void save(string filePath) {
// ...
using (TextWriter writer = File.CreateText(filePath)) {var serializer = getSerializer(errors);
var errors = new List<string>();
var serializer = getSerializer(errors);
serializer.Serialize(writer, snapshot);
logErrors(errors);
}
// ...
@Arakade
Arakade / SizeTesting.cs
Last active March 31, 2017 21:11
Unity3D / C# coder? Can you guess the answers? What's your score?
using System;
using UnityEngine;
namespace UGS {
class SizeTesting : MonoBehaviour {
private const string msgFmt = "{0}:\t\t{1:0.000} bytes";
public void Awake() {
v<byte>();
v<int>();
@Arakade
Arakade / Example output
Created April 22, 2017 18:32
BASH script to port a Git commit from one Git repo to another unrelated Git repo (can run with BASH on Windows)
$ GitPortPatch.sh 22b7f80c22ac1861e945ddf30e30671c46b53d6e
Getting commit message
Getting patch
Getting affected filenames
Getting current status of those files...
Checking them...
Ensuring affected files are ready for patching...
Preparing Assets/TerraVolPack/TerraVol/Scripts/Data/MeshData.cs
Preparing Assets/TerraVolPack/TerraVol/Scripts/Map/Chunk.cs
Apply patch? y/n : y
@Arakade
Arakade / dropbox-restore.py
Created November 9, 2017 11:18
Tweaked version of https://github.com/clark800/dropbox-restore with updated DropBox API, list revision error fix included and option to disable recursion (enabled here) (for Python 2). Good as of 2017/11/08
#!/usr/bin/env python
import sys, os, dropbox, time
from datetime import datetime
APP_KEY = 'API_KEY' # INSERT APP_KEY HERE
APP_SECRET = 'APP_SECRET' # INSERT APP_SECRET HERE
DELAY = 0.2 # delay between each file (try to stay under API rate limits)
HELP_MESSAGE = \
"""Note: You must specify the path starting with "/", where "/" is the root
@Arakade
Arakade / NonNullAttribute.cs
Last active January 24, 2018 12:28
Unity3D NonNull attribute + colouring PropertyDrawer
using UnityEngine;
namespace UGS.unityutil.attributes {
/// <summary>
/// Checks non-null (and non-empty if applied to a string, non-zero if a scalar or Vector, etc) in a custom inspector.
/// Colours red if any problems.
/// </summary>
public sealed class NonNullAttribute : PropertyAttribute {
}
@Arakade
Arakade / ScreenCaptureUtil.cs
Last active January 24, 2018 13:00
Utility to capture screenshots at crazily large sizes required by printers for floor standing banners, etc prior to 2017.03.0p1
using System;
using UnityEngine;
namespace UGS {
/// <summary>
/// See <seealso cref="http://docs.unity3d.com/ScriptReference/Application.CaptureScreenshot.html"/>.
/// N.b. docs now say "Removed in version 2017.3.0p1"
/// Now API call includes super-size facility https://docs.unity3d.com/ScriptReference/ScreenCapture.CaptureScreenshot.html
/// </summary>
@Arakade
Arakade / SkyBoxRotation.cs
Last active March 22, 2018 22:24
Unity3D script to rotate the skybox
using System.Collections;
using UnityEngine;
namespace UGS.environ {
/// <summary>
/// Rotates the skybox of the scene or camera.
/// Requires a special shader.
/// </summary>
internal sealed class SkyBoxRotation : MonoBehaviour {
@Arakade
Arakade / StickCauseMB.cs
Created June 5, 2019 13:55
ECS/DOTS Unity.Physics preview-0.1.0 collision system that creates joints on collisions when a StickCause is present.
using Unity.Burst;
using Unity.Entities;
using Unity.Physics.Authoring;
using UnityEngine;
using UnityEngine.Assertions;
namespace UGS {
/// <summary>
/// Tag component for causing things to stick.
/// Could I also do this with a Physics.Material "Custom Flags" or "Collision Filter" ?