使用NGUI做游戏,首先要封装一个简单的底层,该底层需要确定以下方面的做法:
(1)分辨率策略;
(2)层级管理方案;
(3)国际化支持;
(4)模态、非模态的实现;
(5)通用对话框。
ScriptableObject数据存储及序列化:
(1)创建一个类,用于记录数据逻辑:
using UnityEngine;using System.Collections;public class DataHolder : ScriptableObject{ public int IntValue = 1; public string StrValue = "str"; public float FValue = 0f;}
数据类必须继承自ScriptableObject,才能用于序列化。
(2)根据数据类创建本地asset,用于数据存储:
using UnityEngine;using UnityEditor;using System.Collections;public class CreateScripteObject{ [MenuItem("MyEditor/CreateScripteObject")] public static void Execute() { DataHolder data = ScriptableObject.CreateInstance(); data.IntValue = 100; // 此函代码可以保证asset创建的唯一性,如果连续两次调用会生成test.asset和test 1.asset,如果没有此行代码,则每次都会直接覆盖 string SavePath = AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/test.asset"); AssetDatabase.CreateAsset(data, SavePath); AssetDatabase.Refresh(); }}
(3)运行时读取数据的方法:
using UnityEngine;using System.Collections;public class TestScripteObject : MonoBehaviour { private void OnGUI() { if(GUILayout.Button("ReadData", GUILayout.Width(300))) { DataHolder data = Resources.Load("test"); Debug.Log(data.IntValue); } }}
删除所有不可见字符:
s = Regex.Replace(line, @"[^\x21-\x7E]", "")
Unity编辑器crash日志查询:
OS X
~/Library/Logs/Unity/Windows XP C:\Documents and Settings\(current user)\Local Settings\temp\UnityWebPlayer\logVista/Windows 7 C:\Users\(current user)\AppData\Local\Temp\Low\UnityWebPlayer\log