Skip to content

Instantly share code, notes, and snippets.

View sunny352's full-sized avatar

MingSailor sunny352

View GitHub Profile
@sunny352
sunny352 / CDManager.cs
Created August 12, 2015 02:28
CD功能管理
//#define _CD_Use_MonoBehaviour_
#define _CD_Use_Singlton_
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class CDManager
#if _CD_Use_MonoBehaviour_
: MonoBehaviour
@sunny352
sunny352 / StorageEnergy.cs
Created August 12, 2015 02:29
蓄力功能计时器
using UnityEngine;
using System.Collections;
using System;
public class StorageEnergy
{
public static float CurrentTime { get { return Time.fixedTime; } }
public float Persent { get; private set; }
public Action onStart;
public Action onFinished;
@sunny352
sunny352 / ResourcesManager.cs
Created August 12, 2015 02:29
简单的资源加载功能
using UnityEngine;
//资源管理
public class ResourcesManager
{
public static T Load<T>(string folder, string fileName) where T : UnityEngine.Object
{
#if UNITY_EDITOR
T obj = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(string.Format("Assets/{0}/{1}", folder, fileName));
if (null != obj)
{
@sunny352
sunny352 / ShowProfile.cs
Created August 12, 2015 02:30
游戏帧率及内存占用统计显示工具
using UnityEngine;
using System.Collections;
public class ShowProfile : MonoBehaviour
{
public float SampleTime = 0.5f;
private float m_lastUpdateTime = 0.0f;
private float m_fps = 0.0f;
private int m_frame = 0;
void Update()
@sunny352
sunny352 / ComboCounter.cs
Created August 17, 2015 07:15
Combo计数器
using UnityEngine;
public class ComboCounter
{
public static float CurrentTime { get { return Time.fixedTime; } }
public System.Action onBegin;
public System.Action<int> onIncrease;
public System.Action<int> onEnd;
@sunny352
sunny352 / ImageManager.cs
Last active February 29, 2016 11:08
Unity的web图片管理,自动回收
//#define _Debug_Tools
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class ImageManager : MonoBehaviour
{
public static void Request(string url, System.Action<Texture2D> callback)
{
@sunny352
sunny352 / EditorTools_GetAll.cs
Created February 25, 2016 09:28
Unity编辑器环境下获取当前场景所有对象(无论是否Active)
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class EditorTools
{
//获取场景内所有对象,无论是否Active
//http://wonderm.coding.io/2015/08/31/Unity-Editor-SelectAll/
//感谢 白昼
@sunny352
sunny352 / HashTools.cs
Created February 29, 2016 10:23
方便自己使用的MD5,可用在Unity
using System;
using System.Security.Cryptography;
using System.Text;
public class HashTools
{
public static byte[] GenMD5(byte[] source)
{
MD5 md5 = new MD5CryptoServiceProvider();
return md5.ComputeHash(source);
@sunny352
sunny352 / Sphere.java
Created June 12, 2016 10:06
就是个球啊,可以从内部看的球,用来做VR播放器的幕布
/**
* Created by Ming on 2016/6/12.
*/
public class Sphere {
private static final float[] Vertices = {
0f, 0f, 1.164415f,
9.929748E-09f, 0.2271661f, 1.142041f,
0.04431792f, 0.2228012f, 1.142041f,
0.08693273f, 0.4370403f, 1.075779f,
1.94779E-08f, 0.4456024f, 1.075779f,
@sunny352
sunny352 / ZipUtil.cs
Created March 17, 2017 09:01
Zip压缩,需要UniRx和SharpZipLib支持
using ICSharpCode.SharpZipLib.Zip;
using System.Collections;
using UniRx;
using UnityEngine;
public static class ZipUtil
{
public static IEnumerator Create(string name)
{
string pakPath = string.Format("{0}/{1}.pak", Application.temporaryCachePath, name);