Skip to content

Instantly share code, notes, and snippets.

@radiatoryang
radiatoryang / FileManager.cs
Last active July 31, 2018 00:39
a bare bones data loading / saving (for game levels, savegames, etc.) example using the built-in binary serialization in Unity... I'd suggest hooking it up to the file browser OnGUI thing here: http://forum.unity3d.com/attachment.php?attachmentid=87628&d=1392756207 (from http://forum.unity3d.com/threads/84601-File-Browser/page2)
using System;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Reflection;
using System.Text;
using System.IO;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
// To prepare a Google Spreadsheet for this:
// make sure the spreadsheet has been published to web (FILE >> PUBLISH TO WEB), which is NOT the same as sharing to web
// To use in a different script:
// 1) include "using Google.GData.Client;"
// 2) include "using Google.GData.Spreadsheets;"
// 3) call "GDocService.GetSpreadsheet( string spreadsheetKey );", see DebugTest section for sample usage
// uncomment to enable debug output
// #define debugTest
@radiatoryang
radiatoryang / GDocService.cs
Created November 27, 2013 22:18
Fetches a public Google Spreadsheet in Unity. (Doesn't work in Webplayer due to the security sandbox.)
// To prepare a Google Spreadsheet for this:
// make sure the spreadsheet has been published to web (FILE >> PUBLISH TO WEB), which is NOT the same as sharing to web
// To use in a different script:
// 1) include "using Google.GData.Client;"
// 2) include "using Google.GData.Spreadsheets;"
// 3) call "GDocService.GetSpreadsheet( string spreadsheetKey );", see DebugTest section for sample usage
using UnityEngine;
using System.Collections;
@radiatoryang
radiatoryang / Terrain_FirstPass.shader
Last active June 17, 2018 22:57
A masked-blend terrain shader hack for Unity.
Shader "Nature/Terrain/Diffuse" {
Properties {
[HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
[HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}
[HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}
[HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}
[HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}
// used in fallback on old cards & base map
[HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
[HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
@Petethegoat
Petethegoat / VertexBlendMasked
Created April 22, 2013 22:59
Shader for Unity that vertex blends two textures with a mask. Imperfect.
Shader "Custom/VertexBlendMaskedCleanEdges" {
Properties
{
_Over ("Over", 2D) = "white" {}
_Under ("Under", 2D) = "white" {}
_Mask ("Mask", 2D) = "white" {}
_Bias ("Edge Bias", Range(0.5, 30.0)) = 4.0
_Edge ("Edge Sharpness", Float) = 10.0
_Fall ("Blend Falloff", Float) = 1.0
}
@radiatoryang
radiatoryang / TriplanarWorld.shader
Created February 6, 2013 19:24
a triplanar / procedural UV / world space UV shader for Unity, cobbled together bits from @quickfingerz and @Farfarer
Shader "Tri-Planar World" {
Properties {
_Side("Side", 2D) = "white" {}
_Top("Top", 2D) = "white" {}
_Bottom("Bottom", 2D) = "white" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
_BottomScale ("Bottom Scale", Float) = 2
}
@SeventySevian
SeventySevian / gist:3977847
Created October 30, 2012 01:49
Unity Pixelated shader
Shader "Seventy Sevian/Pixelated"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Color", Color) = (1, 1, 1, 1)
_PixelCountU ("Pixel Count U", float) = 100
_PixelCountV ("Pixel Count V", float) = 100
}
@jkrup
jkrup / bitmask.shader
Created October 15, 2012 16:45
Mask shader for Unity3d
Shader "Custom/bitmask"
{
Properties
{
//_MainTex ("Base", 2D) = "black" {}
_Mask ("Culling Mask", 2D) = "" {}
_Cutoff ("Alpha Cutoff", Range(0,1)) = 0