Skip to content

Instantly share code, notes, and snippets.

View onevcat's full-sized avatar
🐭

Wei Wang onevcat

🐭
View GitHub Profile
@onevcat
onevcat / D.cs
Created November 8, 2012 05:02
Unity Better Debug script
#define DEBUG_LEVEL_LOG
#define DEBUG_LEVEL_WARN
#define DEBUG_LEVEL_ERROR
using UnityEngine;
using System.Collections;
// setting the conditional to the platform of choice will only compile the method for that platform
@onevcat
onevcat / PostBuildLog.cs
Created December 5, 2012 05:15 — forked from darktable/PostBuildLog.cs
Unity3D: Post-process script that includes a build.log file containing the build summary in the output directory. Based on a method in BuildManager.
/* **************************************************************************
Copyright 2012 Calvin Rien
(http://the.darktable.com)
Derived from a method in BuildManager, part of
VoxelBoy's Unite 2012 Advanced Editor Scripting Talk.
(http://bit.ly/EditorScripting)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@onevcat
onevcat / KKKeychain.projmods
Created December 17, 2012 23:21
.projmods file example of XUPorter
{
"group": "KKKeychain",
"libs": [],
"frameworks": ["Security.framework"],
"headerpaths": [],
"files": [],
"folders": ["iOS/KKKeychain/"],
"excludes": ["^.*.meta$", "^.*.mdown$", "^.*.pdf$"]
}
@onevcat
onevcat / XCodePostProcess.cs
Created December 17, 2012 23:40
XUPorter Processer
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.XCodeEditor;
using System.IO;
public static class XCodePostProcess
{
[PostProcessBuild]
public static void OnPostProcessBuild( BuildTarget target, string path )
@onevcat
onevcat / CompleteSharp.sublime-settings
Created December 20, 2012 23:58
Sublime CompleteSharp
{
// You probably want to configure this to something of your own.
// ${home}, ${env:<variable>}, ${project_path:} and ${folder:} tokens can be used in the completesharp_assemblies option.
//
// ${home} is replaced with the value of the HOME environment variable.
//
// ${env:<variable>} is replaced with the "variable" environment variable.
//
// ${project_path:} tries to find a file with the given name in all the registered project folders and
// returns the first file found, or the original file name if none is found.
/*
* MethodSwizzle.h
*
* Copyright (c) 2007-2011 Kent Sutherland
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
@onevcat
onevcat / ObjectPrivate.cs
Created March 27, 2013 11:47
Get/Set/Call private things.
//
//
// Created by Wang Wei(@onevcat) on 2013-3-27.
// Copyright (c) 2013 Kayac. All rights reserved.
//
using System;
using System.Reflection;
public static class ObjectPrivate {
public static T GetPrivateField<T>(this object obj, string name)
@onevcat
onevcat / RandomClickTest.cs
Created March 28, 2013 00:15
Random click a NGUI's UIButton with some rules.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
/// <summary>
/// Random click test. Drag this script to any gameObject in the scene and it will "click" NGUI's UIButton automaticlly for you. (In fact it send messages to UIButtonMessage)
/// </summary>
public class RandomClickTest : MonoBehaviour {
@onevcat
onevcat / TaskManager.cs
Created March 28, 2013 08:49
New coroutine interface for Unity.
/// TaskManager.cs
/// Copyright (c) 2011, Ken Rockot <[email protected]>. All rights reserved.
/// Added a inline delegate to it. @onevcat
/// Everyone is granted non-exclusive license to do anything at all with this code.
///
/// This is a new coroutine interface for Unity.
///
/// The motivation for this is twofold:
///
/// 1. The existing coroutine API provides no means of stopping specific
@onevcat
onevcat / WaitUntil
Created April 30, 2013 14:21
A Replacement for Coroutines in Unity + C#. http://theinstructionlimit.com/a-replacement-for-coroutines
using System;
using UnityEngine;
using Debug = UnityEngine.Debug;
using Object = UnityEngine.Object;
class ConditionalBehaviour : MonoBehaviour
{
public float SinceAlive;
public Action Action;