Skip to content

Instantly share code, notes, and snippets.

@Voresh
Voresh / ResoScaler.cs
Created July 2, 2022 19:12 — forked from snlehton/ResoScaler.cs
A simple Unity component to render the screen in lower resolution
using UnityEngine;
// Render the screen in lower resolution
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public class ResoScaler : MonoBehaviour
{
[Range(1, 8)]
public float scale = 1;
@Voresh
Voresh / gist:5ee00ca9dcd9848e5261650e8acbf74c
Created December 4, 2018 20:11
Unity conditional debug
using System.Diagnostics;
using Debug = UnityEngine.Debug;
public static class ConditionalDebug
{
[Conditional("ENABLE_CONDITIONAL_DEBUG")]
public static void Log(object message)
{
Debug.Log(message);
}
@Voresh
Voresh / gist:d68170d5b9658aef4779b546864d298c
Created December 4, 2018 20:05
Spine skeleton animation complete subscription
public class AnimationCompleteSubscription: IDisposable
{
private readonly SkeletonAnimation _skeletonAnimation;
private readonly Action _eventCallback;
public AnimationCompleteSubscription(SkeletonAnimation skeletonAnimation, Action eventCallback)
{
_skeletonAnimation = skeletonAnimation;
_eventCallback = eventCallback;
_skeletonAnimation.AnimationState.Complete += AnimationEventHappened;
@Voresh
Voresh / gist:b567a5b2614264ee4a3b2cb0928f592b
Created December 4, 2018 20:01
Spine skeleton animation event subscription
public class AnimationEventSubscription: IDisposable
{
private readonly SkeletonAnimation _skeletonAnimation;
private readonly Action _eventCallback;
private readonly string _eventName;
public AnimationEventSubscription(SkeletonAnimation skeletonAnimation, Action eventCallback, string eventName)
{
_skeletonAnimation = skeletonAnimation;
_eventCallback = eventCallback;
@Voresh
Voresh / gist:e5ed0d177e3579fb6076b619bb85a933
Created December 4, 2018 19:55
Getting unity component under coursor by raycast
public static T GetComponentUnderCoursor<T>(this Camera inputCamera) where T : MonoBehaviour
{
RaycastHit hit;
return Physics.Raycast(inputCamera.ScreenPointToRay(Input.mousePosition), out hit)
? hit.transform.GetComponent<T>()
: null;
}
@Voresh
Voresh / gist:381e2a895ec0c7008b8ec36af51797ed
Created July 9, 2018 19:55 — forked from daaain/gist:3932602
Google App Script - Spreadsheet JSON export
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the exportJSON() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();