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 / ConfigHelper.cs
Last active July 16, 2016 12:31
Unity3D 读取文本文件中的配置信息
using UnityEngine;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace ruihanyang.ConfigHelper
{
/// <summary>
/// <para>配置助手</para>
@yangruihan
yangruihan / SmoothCameraFollow.cs
Last active July 25, 2016 08:39
Unity3D 摄像机平滑跟踪某个游戏对象
using UnityEngine;
using System.Collections;
public class SmoothCameraFollow : MonoBehaviour {
static public Transform target;
public float distance = 4.0f;
public float height = 1.0f;
public float smoothLag = 0.2f;
public float maxSpeed = 10.0f;
@yangruihan
yangruihan / TouchIgnore.cs
Created August 10, 2016 03:35
Unity 使UI组件忽略点击事件响应
using UnityEngine;
using System.Collections;
public class TouchIgnore : MonoBehaviour, ICanvasRaycastFilter
{
public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)
{
return false;
}
}
@yangruihan
yangruihan / ReadFile.java
Created November 6, 2016 10:06
Java 从文件中读取内容
public class ReadFromFile {
/**
* 以字节为单位读取文件,常用于读二进制文件,如图片、声音、影像等文件。
*/
public static void readFileByBytes(String fileName) {
File file = new File(fileName);
InputStream in = null;
try {
System.out.println("以字节为单位读取文件内容,一次读一个字节:");
// 一次读一个字节
@yangruihan
yangruihan / WriteFile.java
Created November 6, 2016 10:07
Java 写内容到文件中
public class AppendToFile {
/**
* A方法追加文件:使用RandomAccessFile
*/
public static void appendMethodA(String fileName, String content) {
try {
// 打开一个随机访问文件流,按读写方式
RandomAccessFile randomFile = new RandomAccessFile(fileName, "rw");
// 文件长度,字节数
long fileLength = randomFile.length();
@yangruihan
yangruihan / ForeachCharUtil.cs
Created July 28, 2017 08:56
Unity弹字脚本
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
public class ForeachCharUtil : MonoBehaviour
{
public enum ShowContentStatus
{
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public class SerializeHelper
{
/// <summary>
/// 序列化
/// </summary>
/// <returns>The message queue.</returns>
@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 / 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 / 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)
{