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 / LoadDirectoryPrefab.cs
Created July 25, 2018 03:26
Unity Editor 获得某一目录下所有Prefab
public static List<GameObject> LoadDirectoryPrefab(string rootPath)
{
var dictoryInfo = new DirectoryInfo(rootPath);
if (!dictoryInfo.Exists) return null;
var ret = new List<GameObject>();
FileInfo[] fileInfos = dictoryInfo.GetFiles("*.prefab", SearchOption.AllDirectories);
EditorUtility.DisplayProgressBar("加载Prefab中...", "开始加载", 0f);
@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 / ReferenceFinder.cs
Created July 25, 2018 03:24
查找prefab引用到的所有资源
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class ReferenceFinder : EditorWindow
{
public static ReferenceFinder Instance;
public Dictionary<string, BetterList<string>> dict;
private Vector2 _scroll = Vector2.zero;
@yangruihan
yangruihan / PrefabTextScanner.cs
Created July 25, 2018 03:22
Prefab 文本内容查找及替换(用于查找和替换指定目录下 Prefab 内 Text 组件包含的文本)
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Prefab 中文本扫描替换
/// </summary>
@yangruihan
yangruihan / CellularAutomataGenMap.py
Created July 11, 2018 06:35
细胞自动机生成随机地图
#!/usr/bin/env python3
from random import *
DIR = [(-1, 0), (0, -1), (1, 0), (0, 1)]
def R(arr, x, y, n = 1):
global DIR
ret = 0
for t in range(1, n + 1):
@yangruihan
yangruihan / file_util.hpp
Created April 19, 2018 15:07
FileHelper for cpp
#pragma once
#include <string>
namespace util
{
class FileUtil
{
public:
static bool read_file(const char* file_path, std::string &result)
@yangruihan
yangruihan / GameObjectUtil.cs
Created April 19, 2018 15:05
Auto Bind Component
public static class GameObjectUtil
{
#if UNITY_EDITOR
public static GameObject FindGameObject(this GameObject obj, string name, bool includeInactive = true, bool showError = true)
{
Transform[] trs = obj.GetComponentsInChildren<Transform>(true);
foreach (Transform t in trs)
{
@yangruihan
yangruihan / launch.json
Created April 1, 2018 14:46
VSCode Unity Debugger setting
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
@yangruihan
yangruihan / TextContentMatchUtil.cs
Created November 7, 2017 16:02
uGUI Text组件文本匹配
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
public class TextContentMatchUtil : EditorWindow
{
[MenuItem("Tools/Text组件内容匹配")]
@yangruihan
yangruihan / DebugUtil.cs
Last active February 15, 2019 07:56
Debug util for unity
using UnityEngine;
using System;
public class DebugUtil
{
public enum Level
{
Log = 0,
Warning,
Error,