Skip to content

Instantly share code, notes, and snippets.

View zcyemi's full-sized avatar
⚗️
Transform code into magic

Zheng Chu zcyemi

⚗️
Transform code into magic
View GitHub Profile
@zcyemi
zcyemi / chaining.cs
Created September 27, 2018 03:31
Method chaining Pattern with generic derivation.C# and Typescript
public class A<T> where T :A<T>{
protected T t;
public T funcA(){
return t;
}
}
public class A:A<A>{
private A(){
@zcyemi
zcyemi / float16.ts
Last active September 29, 2018 06:00
Float16 implement Javascript
export class Float16{
public static ByteToFloat16(uint16:number){
let d = uint16;
let negative = ((d>>15) & 1) !=0;
let mask = 0b11111;
let exponent = (d >>10) & mask;
let significand = d & 0b1111111111;
if(exponent == 0 && significand == 0){
return negative ? -0:0;
}
@zcyemi
zcyemi / binding.ts
Created September 12, 2018 09:40
Typescript Object property binding.
function BindFunc(tar:object,property:string,f:(v:any)=>void){
var property_emit = BIND_EMITTER(property);
if(tar.hasOwnProperty(property_emit)){
tar[property_emit].push(f);
}
else{
BindSetup(tar,property);
tar[property_emit].push(f);
}
}
@zcyemi
zcyemi / MeshSerialization.cs
Created June 12, 2018 13:17
Unity mesh binary serialzation.
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
[ExecuteInEditMode]
public class MeshSerialization : MonoBehaviour {
@zcyemi
zcyemi / config.json
Created June 12, 2018 07:11
使用Gulp构建Egret微信小游戏
{
"projectfolder": "TestMap",
"wxappid": "wx6ac********",
"projectname":"testproj",
"res":{
"compressFolders": [
"spriteatlas",
"UIAtlas"
]
},
@zcyemi
zcyemi / SpriteMeshMerger.cs
Created May 17, 2018 10:50
Unity editor script for merging sprite render sprites into a single large mesh.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
public class SpriteMeshMerger
{
@zcyemi
zcyemi / SpriteAtlasExporter.cs
Created May 17, 2018 10:48
Script for exporting Unity sprite packer atlas texture.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class SpriteAtlasExporter : MonoBehaviour {
public Sprite sprite;
RenderTexture tex;
@zcyemi
zcyemi / JsonHelper.cs
Created March 14, 2018 13:51
Json.Net.JsonConverter for Unity Vector struct.
using UnityEngine;
using Newtonsoft.Json;
using System;
public class Vec4Conv : JsonConverter
{
public override bool CanConvert(Type objectType)
{
if (objectType == typeof(Vector4))
@zcyemi
zcyemi / GradleConfig.cs
Created March 5, 2018 04:55
Single file C# gradle file parser
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Text;
using System;
using Newtonsoft.Json;
namespace CIS
{
public class GradleConfig
@zcyemi
zcyemi / DomainDX.cs
Created January 31, 2018 13:45
Cross AppDomain DirectX11(SharpDX) Drawing Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharpDX;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using System.Threading;
using Device = SharpDX.Direct3D11.Device;