Skip to content

Instantly share code, notes, and snippets.

View zhenlinyang's full-sized avatar

Zhenlin Yang zhenlinyang

View GitHub Profile
@zhenlinyang
zhenlinyang / CopyAndReplaceDirectory.cs
Created November 5, 2016 12:15
CopyAndReplaceDirectory
private static void CopyAndReplaceDirectory(string srcPath, string dstPath)
{
if (Directory.Exists(dstPath))
{
Directory.Delete(dstPath);
}
if (File.Exists(dstPath))
{
File.Delete(dstPath);
@zhenlinyang
zhenlinyang / AndroidSignCheck.cs
Created December 6, 2016 02:48
AndroidSignCheck
using UnityEngine;
public static class AndroidSignCheck
{
private const string c_PackageName = "com.yangzhenlin.unitydemo";
public static byte[] GetSignature()
{
//Player = new UnityPlayer();
AndroidJavaClass Player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
@zhenlinyang
zhenlinyang / ZipMng.cs
Created December 6, 2016 13:22
CSharp GZip
public static class ZipMng
{
public static byte[] Compress(byte[] originalData)
{
using (MemoryStream outms = new MemoryStream())
{
using (MemoryStream inms = new MemoryStream(originalData))
{
using (GZipStream gzs = new GZipStream(outms, CompressionMode.Compress))
{
@zhenlinyang
zhenlinyang / Bit.cs
Created December 13, 2016 07:38
Bit Operation
public static class Bit
{
private const int INT_MAX_LENGTH = 32;
private const byte BYTE_MAX_LENGTH = 8;
public static bool Read(int source, int index)
{
Debug.Assert(index >= 0 && index < INT_MAX_LENGTH);
return 0 != (source & (1 << index));
}
@zhenlinyang
zhenlinyang / PathCombine.cs
Last active April 1, 2017 06:37
PathCombine
using System;
using System.Collections.Generic;
using System.IO;
public static class PathCombine
{
public static string Combine(params string[] subPath)
{
if (null == subPath || 0 == subPath.Length)
{
@zhenlinyang
zhenlinyang / UnityEngine.Simulation.Object.cs
Created April 4, 2017 12:31
UnityEngine Simulation Object
namespace UnityEngine.Simulation
{
public class Object
{
private static int s_IdCount = 0;
private int m_InstanceID;
private bool m_Alive = true;
@zhenlinyang
zhenlinyang / StatusHandler.cs
Last active July 15, 2017 10:05
Object Status
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
public static class StatusHandler
{
private static readonly Dictionary<string, BindingFlags> m_BindingFlagsDic =
new Dictionary<string, BindingFlags>
{