Skip to content

Instantly share code, notes, and snippets.

@sfszh
sfszh / test_shader_0.shader
Created December 12, 2012 10:23
First shader I made
Shader "Custom/NewShader" {
Properties {
_Color("Color",Color) = (1,0,0)
_MainTex("Texture Main", 2D) = ""{ TexGen sphereMap }
_AltTex("Texture Alt", 2D) = "" { }
_Number("nameNumber", Range(0,1)) = 1
}
SubShader {
@sfszh
sfszh / test_shader_2.shader
Created December 12, 2012 10:24
second shader
Shader "Custom/testShader2" {
Properties {
_Color("Main Color",Color) = (1,1,1,1)
_SpecColor("Spec Color", Color) = (1,1,1,1)
_Emission("Emmisive Color", Color) = (0,0,0,0)
_Shininess("Shininess", Range(0.01, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
//Tags { "RenderType"="Opaque" }
@sfszh
sfszh / UIToolExtension.cs
Last active December 17, 2015 12:29
make refresh the collider in NGUI widgets a little bit easier
using UnityEngine;
using UnityEditor;
using System.Collections;
static public class UIToolExtension{
//add this to NGUImenu.cs
[MenuItem("NGUI/Refresh a Collider #&r")]
static public void RefreshCollider() {
GameObject go = Selection.activeGameObject;
@sfszh
sfszh / TabController.cs
Last active December 19, 2015 06:08
a simple TabView controller in unity3D, require NGUI
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TabController : IgnoreTimeScale {
public List<UICheckbox> tabs;
public bool canStartUncalled = true;
public int StartedTabNumber = 0; // there should be one tab started as checked
public delegate void OnTabSelected(int tabNumber);
@sfszh
sfszh / TabListener.cs
Created July 2, 2013 12:42
if listened tab number is active the gameobject was enabled other wise disabled, use with tabController https://gist.github.com/sfszh/5908899
using UnityEngine;
using System.Collections;
// this is a general tab listener
public class TabListener : MonoBehaviour {
public TabController tabController;
public int listenedTabNumber; // listenedTabNumber tabnumber
void TabHandler(int tabNumber) {
Debug.Log("number is " +tabNumber);
@sfszh
sfszh / WeiboShare.h
Last active December 20, 2015 17:39
simple demo sharing to sina weibo using ShareSDK and Untiy3D in iOS. we share a sentence and a captured image.
//
// WeiboShare.h
// Unity-iPhone
//
// Created by Sophos Zhang on 6/25/13.
//
//
#import <Foundation/Foundation.h>
#import <ShareSDK/ShareSDK.h>
using UnityEngine;
using UnityEditor;
/*
* orignially posted
http://answers.unity3d.com/questions/179775/game-window-size-from-editor-window-in-editor-mode.html
*/
public class SetGameViewSize : EditorWindow {
private Vector2 _size = new Vector2(800, 600);
using UnityEngine;
using UnityEditor;
/**
* originally by buffonomics
* originally posted on: http://forum.unity3d.com/threads/77444-How-to-create-new-GameObject-as-child-in-hierarchy
*/
public class SmartCreate : MonoBehaviour {
[MenuItem("GameObject/Create Empty Parent #&e")]
static void createEmptyParent() {
@sfszh
sfszh / Loom.cs
Created August 12, 2013 01:49
a simple thread generator using in unity
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Threading;
using System.Linq;
public class Loom : MonoBehaviour
{
public static int maxThreads = 8;
#define DEBUG_CONSOLE
#define DEBUG_LEVEL_LOG
#define DEBUG_LEVEL_WARN
#define DEBUG_LEVEL_ERROR
#if (UNITY_EDITOR || DEVELOPMENT_BUILD)
#define DEBUG
#endif
#if (UNITY_IOS || UNITY_ANDROID)