0%

Type类,是一个用来存储类型的特性和信息的类。对于程序中的每一个类型,都会有他自己的类信息,而根据Type提供的书信和方法获得这个类型的一切信息,包括字段,属性,事件,参数,构造函数等。

生成Type对象

阅读全文 »

前言

UnityConsoleWindow双击定位Debug.Log输出日志。

但是一般封装Debug.Log日志定位就不是自己想要的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEditor;
public class LogEditor
{
private static LogEditor m_Instance;
public static LogEditor GetInstacne()
{
if (m_Instance == null)
{
m_Instance = new LogEditor();
} return m_Instance;
}
private const string DEBUGERFILEPATH = "Assets/Script/Util/HHLogger.cs";//替换成你自己的封装类地址
private int m_DebugerFileInstanceId;
private Type m_ConsoleWindowType = null;
private FieldInfo m_ActiveTextInfo;
private FieldInfo m_ConsoleWindowFileInfo;

private LogEditor()
{
UnityEngine. Object debuggerFile = AssetDatabase.LoadAssetAtPath(DEBUGERFILEPATH,typeof(UnityEngine.Object));
m_DebugerFileInstanceId = debuggerFile.GetInstanceID();
m_ConsoleWindowType = Type.GetType("UnityEditor.ConsoleWindow,UnityEditor");
m_ActiveTextInfo = m_ConsoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic);
m_ConsoleWindowFileInfo = m_ConsoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic);
}

[UnityEditor.Callbacks.OnOpenAssetAttribute(-1)]
private static bool OnOpenAsset(int instanceID, int line)
{
if (instanceID == LogEditor.GetInstacne().m_DebugerFileInstanceId && line != -1)
{
return LogEditor.GetInstacne().FindCode();
}
return false;
}

public bool FindCode()
{
var windowInstance = m_ConsoleWindowFileInfo.GetValue(null);
var activeText = m_ActiveTextInfo.GetValue(windowInstance);
string[] contentStrings = activeText.ToString().Split('\n');
List<string> filePath = new List<string>();
for (int index = 0; index < contentStrings.Length; index++)
{
if (contentStrings[index].Contains("at"))
{
filePath.Add(contentStrings[index]);
}
} bool success = PingAndOpen(filePath[1]);
return success;
}

public bool PingAndOpen(string fileContext)
{
string regexRule = @"at ([\w\W]*):(\d+)\)";
Match match = Regex.Match(fileContext, regexRule);
if (match.Groups.Count > 1)
{
string path = match.Groups[1].Value;
string line = match.Groups[2].Value;
UnityEngine.Object codeObject = AssetDatabase.LoadAssetAtPath(path, typeof(UnityEngine.Object));
if (codeObject == null)
{
return false;
}
EditorGUIUtility.PingObject(codeObject);
AssetDatabase.OpenAsset(codeObject, int.Parse(line));
return true;
}
return false;
}
}
阅读全文 »

themes下配置

Schemes

Muse:默认 Scheme,这是 NexT 最初的版本,黑白主调,大量留白

Mist:Muse 的紧凑版本,整洁有序的单栏外观

Pisces:双栏 Scheme,小家碧玉似的清新

阅读全文 »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class ShowFPS : MonoBehaviour
{
public int fpsTarget;

public float updateInterval = 0.5f;
private float lastInterval;
private int frames = 0;
private float fps;


void Start()
{
//设置帧率
Application.targetFrameRate = 60;


lastInterval = Time.realtimeSinceStartup;
frames = 0;
}

// Update is called once per frame
void Update()
{
++frames;
float timeNow = Time.realtimeSinceStartup;
if (timeNow >= lastInterval + updateInterval)
{
fps = frames / (timeNow - lastInterval);
frames = 0;
lastInterval = timeNow;
}
}

void OnGUI()
{
GUI.Label(new Rect(200, 40, 100, 30), fps.ToString());
}
}

在写文章时,常常有配图说明的需求。Hexo有多种图片插入方式,可以将图片存放在本地引用或者将图片放在CDN上引用。

绝对路径

当Hexo项目中只用到少量图片时,可以将图片统一放在source/images文件夹中,通过markdown语法访问它们。

阅读全文 »

编程语言

汇编语言

提到汇编语言不得不提机器语言

  • 机器语言

机器语言:机器指令的集合(二进制数字0,1)
计算机转变为一列高低电平,以使计算机的电子器受到驱动,进行运算。

  • 汇编语言

实质与机器语言相同,直接对硬件操作。将源程序汇编生成的可执行文件
组成:指令、伪指令和宏指令

阅读全文 »