Skip to content

Instantly share code, notes, and snippets.

@Thaina
Thaina / keybindings.json
Last active January 3, 2020 08:26
my vscode
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "tab",
"command": "-acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible"
}
]
@Thaina
Thaina / ForwardLights.cs
Last active February 16, 2020 06:36
Fix ambient light not set in the com.unity.render-pipelines.universal@7.2.0
using UnityEngine.Experimental.GlobalIllumination;
using Unity.Collections;
namespace UnityEngine.Rendering.Universal.Internal
{
/// <summary>
/// Computes and submits lighting data to the GPU.
/// </summary>
public class ForwardLights
{
@Thaina
Thaina / Generic Regex Formatter.cs
Created March 16, 2020 11:48
C# style string formatter using regex to search for key and replace with IFormattable.Format
using System;
using System.Linq;
using System.Text.RegularExpressions;
public static class RegexFormatter
{
static readonly Regex FormatterPattern = new Regex(@"\{([^\{\}]+?)(?:\:([^\{\}]*))?\}",RegexOptions.Multiline);
public static string RegexFormat(this string input,Func<string,object> selector)
{
return FormatterPattern.Replace(input,(match) => {
// Modified from: http://wiki.unity3d.com/index.php/TextureScale#TextureScale.cs
// Only works on ARGB32, RGB24 and Alpha8 textures that are marked readable
using UnityEngine;
public class TextureScale {
private static Color[] texColors;
private static Color[] newColors;
private static int w;
@Thaina
Thaina / Assets\Editor\TransparentWindowSetting.cs
Last active March 18, 2022 05:42
Unity Setting for transparent background in StandAlone Windows
// origin : Transparent Unity App! : Code Monkey : https://www.youtube.com/watch?v=RqgsGaMPZTw
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
public class TransparentWindowSetting : IPreprocessBuildWithReport
{
public int callbackOrder => 0;
@Thaina
Thaina / gist:32cbd1e8e180e8e683148a35ef694fda
Created February 21, 2023 08:38
List all git changed files and convert line ending
npm i -g eol-converter-cli
for /F "usebackq delims=" %i in (`git ls-files -m`) do (eolconverter lf "%i")
@Thaina
Thaina / CursorLock.cs
Created March 26, 2023 13:51
Actual pointer lock value in unity webgl and windows editor
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR_WIN || UNITY_WEBGL
using System.Runtime.InteropServices;
#endif
using UnityEngine;
public static class CursorLock
@Thaina
Thaina / ConvertTextureToPng.cs
Created July 30, 2023 12:26 — forked from krzys-h/SaveRenderTextureToFile.cs
[Unity] Save RenderTexture to image file
using UnityEngine;
using UnityEditor;
public class ConvertTextureToPng
{
const string MenuName = "Assets/Save Texture to png";
[MenuItem(MenuName)]
public static void SaveRTToFile()
{
@Thaina
Thaina / backupdiskimages.bash
Created August 10, 2023 13:05
gcloud backup all disk to images
for data in $(gcloud compute disks list --format="csv[no-heading](NAME,LOCATION)"); do $(gcloud compute images create ${data%%,*} --source-disk="${data%%,*}" --source-disk-zone="${data#*,}" --storage-location=asia-southeast1); done;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;