Skip to content

Instantly share code, notes, and snippets.

View HilariousCow's full-sized avatar

Aubrey Hesselgren HilariousCow

  • Seattle
View GitHub Profile
@HilariousCow
HilariousCow / Example use
Last active August 12, 2021 23:39
AnimParam TidyUp code - so that your controller scripts aren't dripping in hashed versions of Animator parameters.
class MyControllerComponent : MonoBehaviour{
Animator _anim;
AnimParam _myTrigger;
void Awake()
{
_anim = GetComponent<Animator>();
_playbackDurations = GetComponent<PlaybackDurationManager>();
_myTrigger = _anim.AnimParam("StartThings");
}
@HilariousCow
HilariousCow / InteractionRaycaster.cs
Last active October 15, 2023 23:29
If you are finding that PhysicsRaycaster isn't working when you use Cursor.lockstate (i.e. an FPS game), use this instead.
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
//I used ILSpy on the Unity UI dll to copy out the Physicsraycaster code and fix where the ray eminates from (in this case, always the center of the screen)
public class InteractionRaycaster : PhysicsRaycaster {
[Range(0.0f, 0.5f)]
@HilariousCow
HilariousCow / CopyAssetPathContextMenu.cs
Last active November 22, 2016 15:15
Unity3d utility thing. Right Click an asset-> Copy Asset Path. - ideal for use with AssetDatabase.LoadAssetAtPath<>
using UnityEngine;
using UnityEditor;
public static class CopyAssetPathContextMenu
{
[MenuItem("Assets/Copy Asset Path")]
public static void CopyAssetPath()
{
if (Selection.activeObject != null)
@HilariousCow
HilariousCow / AnimatorExtensions.cs
Last active January 30, 2017 17:05
Some Animator extensions I use to reduce the clutter involved in setting up a hashed call to an animator parameter
using System;
using UnityEngine;
using System.Collections;
[Serializable]
public class AnimParam
{
private readonly int _hashed;//a cached off version of the hashed string
private readonly string _paramName;//don't really need but good for debug?
private readonly Animator _anim;