Skip to content

Instantly share code, notes, and snippets.

View yangruihan's full-sized avatar
📖
Studying...

Ryan yangruihan

📖
Studying...
  • Tencent
  • Shen Zhen, China
View GitHub Profile
@yangruihan
yangruihan / EventDispatcher.cs
Last active May 6, 2022 16:15
C# Unity Event Dispatcher
using System;
using System.Collections.Generic;
using UnityEngine;
public delegate void EventHandler(short type);
public delegate void EventHandler<in T>(short type, T data);
public class EventDispatcher
{
@yangruihan
yangruihan / ScriptRefChecker.cs
Created July 25, 2018 03:24
Unity 根据脚本名,查找引用该脚本的Prefab
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using Object = UnityEngine.Object;
public class UIScriptRefChecker : EditorWindow
{
@yangruihan
yangruihan / global.h
Created December 30, 2020 01:42
md5 extension
/* GLOBAL.H - RSAREF types and constants
*/
/* PROTOTYPES should be set to one if and only if the compiler supports
function argument prototyping.
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags.
*/
#ifndef PROTOTYPES
#define PROTOTYPES 0
@yangruihan
yangruihan / NonDirectionalBooleanMatrix.cs
Created December 15, 2020 09:59 — forked from eral/NonDirectionalBooleanMatrix.cs
Property Drawer Like Layer Collision Matrix
// (C) 2018 ERAL
// Distributed under the Boost Software License, Version 1.0.
// (See copy at http://www.boost.org/LICENSE_1_0.txt)
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
@yangruihan
yangruihan / delete_git_submodule.md
Created November 11, 2020 03:09 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
using UnityEngine.UI;
public class NonDrawingGraphic : Graphic
{
public override void SetMaterialDirty() { return; }
public override void SetVerticesDirty() { return; }
protected override void OnPopulateMesh(VertexHelper vh)
{
vh.Clear();
@yangruihan
yangruihan / GameUtility_cs4.cs
Last active April 28, 2019 13:45
游戏工具类
using UnityEngine;
using System.IO;
using System.Linq;
using System;
public static class GameUtility
{
public const string AssetsFolderName = "Assets";
public static string FormatToUnityPath(string path)
@yangruihan
yangruihan / SingletonMono.cs
Last active February 15, 2019 08:15
MonoBehaviour 单例
using UnityEngine;
/// <summary>
/// extends this class to become singleton class.
/// </summary>
/// <typeparam name="T"> T is a SingletonMono class </typeparam>
public class SingletonMono<T> : MonoBehaviour where T : SingletonMono<T>
{
private static T _instance;
@yangruihan
yangruihan / Singleton.cs
Last active February 15, 2019 08:09
单例抽象类
public abstract class Singleton<T> where T : class, new()
{
private static readonly object LockObject = new object();
private static T _instance;
public static T Instance
{
get
{
if (_instance != null) return _instance;
@yangruihan
yangruihan / InstancePool.cs
Last active February 15, 2019 08:07
对象池
using System.Collections.Generic;
/// <summary>
/// 可入对象池接口
/// </summary>
public interface IPoolable
{
void OnAwakeFromPool();
void OnReturnToPool();