Skip to content

Instantly share code, notes, and snippets.

View Adjuvant's full-sized avatar

Adjuvant

View GitHub Profile
@Adjuvant
Adjuvant / InputManager.asset
Created February 9, 2019 19:44
Basic cross platform XR Unity input manager asset file. Download and replace your asset.
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!13 &1
InputManager:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Axes:
- serializedVersion: 3
m_Name: VR_PrimaryButton_Left
descriptiveName:
@Adjuvant
Adjuvant / GetComponentsOnlyInChildren.cs
Created December 30, 2018 20:56
Unity component search, recursive and non-recursive
using System.Collections.Generic;
using UnityEngine;
public static class UtilityExtensions
{
/// <summary>
/// Gets the components only in immediate children of parent.
/// </summary>
/// <returns>The components only in children.</returns>
/// <param name="script">MonoBehaviour Script, e.g. "this".</param>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
// TODO: currently abit wrong.
// Update to configure points-path-segment issue.
// Enforce some rules?
[RequireComponent(typeof(LineRenderer))]
@Adjuvant
Adjuvant / TodoNotes.tex
Created December 3, 2018 12:23
Latex header stuff for todo notes across publications
% setup revision commands
\usepackage{xargs} % Use more than one optional parameter in a new commands
%\usepackage[dvipsnames]{xcolor} % Coloured text etc. now in acmart.cls
\usepackage[colorinlistoftodos,prependcaption,textsize=small]{todonotes}
\newcommandx{\unsure}[2][1=]{\todo[linecolor=red,backgroundcolor=red!25,bordercolor=red,#1]{#2}}
\newcommandx{\change}[2][1=]{\todo[linecolor=blue,backgroundcolor=blue!25,bordercolor=blue,#1]{#2}}
\newcommandx{\feedback}[2][1=]{\todo[linecolor=yellow,backgroundcolor=yellow!25,bordercolor=yellow,#1]{#2}}
\newcommandx{\improvement}[2][1=]{\todo[linecolor=Plum,backgroundcolor=Plum!25,bordercolor=Plum,#1]{#2}}
\newcommandx{\thiswillnotshow}[2][1=]{\todo[disable,#1]{#2}}
@Adjuvant
Adjuvant / CustomInputModule.cs
Created October 31, 2018 14:43
Workaround for using pointer event system with mouse locked controllers. Code from https://answers.unity.com/questions/1262549/cursorlockstate-and-onpointerenter-not-working-tog.html
using UnityEngine;
using UnityEngine.EventSystems;
public class CustomInputModule : StandaloneInputModule
{
// Current cursor lock state (memory cache)
private CursorLockMode _currentLockState = CursorLockMode.None;
/// <summary>
/// Process the current tick for the module.
list.of.packages <- c("ggplot2", "Rcpp")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
@Adjuvant
Adjuvant / pandasCheatSheet.py
Created September 3, 2018 23:04
Useful pandas snippets, borrowed from somewhere and extended, sorry can't remember attributions
# Sound alert for big jobs
from IPython.display import Audio, display
def allDone():
display(Audio(url='https://sound.peal.io/ps/audios/000/000/537/original/woo_vu_luvub_dub_dub.wav', autoplay=True))
## Insert whatever audio file you want above
# Deep Copy function
def very_deep_copy(self):
return pd.DataFrame(self.values.copy(), self.index.copy(), self.columns.copy())
@Adjuvant
Adjuvant / GyroInput
Created May 3, 2018 15:11
Simple gyro phone rotation in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GyroInput : MonoBehaviour {
Gyroscope m_Gyro;
public float speed = 0.1f;
float hRotation = 0.0f; //Horizontal angle
@Adjuvant
Adjuvant / ReadFromFile.cs
Created April 11, 2018 14:12
Stream lines of text from file, no fancy stuff like peek or select line; used here to fill a dictionary with quaternion data
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
public class ReadFromFile : MonoBehaviour
{