Skip to content

Instantly share code, notes, and snippets.

@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()
{
// 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 / MiniJSON.cs
Created June 29, 2016 07:42 — forked from darktable/MiniJSON.cs
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@Thaina
Thaina / dom-to-json.js
Last active June 11, 2016 08:14 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
/** @param {Node|HTMLElement} node */
function toJSON(node) {
if(!node)
node = this;
var obj = { nodeType: node.nodeType };
if(node.tagName)
obj.tagName = node.tagName.toLowerCase();
else if(node.nodeName)