Skip to content

Instantly share code, notes, and snippets.

@ruzrobert
ruzrobert / Vibration.cs
Last active April 2, 2024 08:16
Android Vibration for Unity 3D. Supports all API: 1 - 29 (auto detect), Amplitudes, Predefined Effects, both Legacy and >=26 APIs.
using System.Diagnostics.CodeAnalysis;
using UnityEngine;
// Dont forget to add "using RDG;" to the top of your script!
namespace RDG
{
/// <summary>
/// Class for controlling Vibration. Automatically initializes before scene is loaded.
/// </summary>
public static class Vibration
@rubenhorn
rubenhorn / YTranslate.cs
Created October 16, 2019 09:08
Unity script for machine translation using the Yandex Translate API
using System.Collections;
using System;
using System.Xml;
using UnityEngine.Networking;
/*
Requirement:
Yandex Translate API key (https://tech.yandex.com/translate/)
Usage:
@JohannesMP
JohannesMP / LICENSE
Last active March 9, 2024 11:26
[Unity3D] A Reliable, user-friendly way to reference SceneAssets by script.
/*******************************************************************************
* Don't Be a Jerk: The Open Source Software License.
* Adapted from: https://github.com/evantahler/Dont-be-a-Jerk
*******************************************************************************
* _I_ am the software author - JohannesMP on Github.
* _You_ are the user of this software. You might be a _we_, and that's OK!
*
* This is free, open source software. I will never charge you to use,
* license, or obtain this software. Doing so would make me a jerk.
*
@tomkail
tomkail / DefaultAssetEditor.cs
Last active September 16, 2022 15:02
Draws inspectors for any file type Unity doesn't draw by default
/// Used to draw custom inspectors for unrecognised file types, which Unity imports as "DefaultAsset"
/// To do this, create a new editor class extending DefaultAssetInspector
/// Return true in the IsValid function if the file extension of the file matches the type you'd like to draw.
/// The DefaultAssetEditor class will then hold a reference to the new instance of your editor class and call the appropriate methods for drawing.
/// An example can be found at the bottom of the file.
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
@TiliSleepStealer
TiliSleepStealer / DoomGlow.cs
Created June 13, 2017 21:45
Doom glow - fake volumetric light glow effect in Unity by Tili_us
// This file is in the public domain. Where
// a public domain declaration is not recognized, you are granted
// a license to freely use, modify, and redistribute this file in
// any way you choose.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unity remake of a fake volumetric light glow effect
@Davidblkx
Davidblkx / LevenshteinDistance.cs
Created November 10, 2016 17:45
Levenshtein Distance in c#
using System;
namespace Algorithms
{
public static class LevenshteinDistance
{
/// <summary>
/// Calculate the difference between 2 strings using the Levenshtein distance algorithm
/// </summary>
/// <param name="source1">First string</param>
@aras-p
aras-p / ComputeOcclusionFromDepth.shader
Last active April 15, 2022 17:50
Unity command buffer that modifies screenspace shadow mask
Shader "Hidden/ComputeOcclusion"
{
Properties
{
_MainTex ("", 2D) = "white" {}
}
SubShader
{
Pass
{
@gbaman
gbaman / HowToOTG.md
Last active May 2, 2024 01:27
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@JakubNei
JakubNei / DeferredSynchronizeInvoke.cs
Last active January 11, 2023 11:06
Implementation of ISynchronizeInvoke for Unity3D game engine. Can be used to invoke anything on main Unity thread. ISynchronizeInvoke is used extensively in .NET forms, it's is elegant and quite useful in Unity as well. I implemented it so i can use it with System.IO.FileSystemWatcher.SynchronizingObject.
/*
Implementation of ISynchronizeInvoke for Unity3D game engine.
Can be used to invoke anything on main Unity thread.
ISynchronizeInvoke is used extensively in .NET forms, it's is elegant and quite useful in Unity as well.
I implemented it so i can use it with System.IO.FileSystemWatcher.SynchronizingObject.
help from: http://www.codeproject.com/Articles/12082/A-DelegateQueue-Class
example usage: https://gist.github.com/aeroson/90bf21be3fdc4829e631
version: aeroson 2017-07-13 (author yyyy-MM-dd)
@lkorth
lkorth / AndroidManifest.xml
Last active December 12, 2023 15:52
Simple Android service that will turn the screen on when the proximity sensor reports a object is close to the device.
<uses-permission android:name="android.permission.WAKE_LOCK" />
<service android:name=".ProxService" />