
本文共 4370 字,大约阅读时间需要 14 分钟。
������������������
���������C#���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������C#���������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������
���������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������UI Prefab������������
���������������
���������������UI������������������������������������������������������������Prefab���������������������������������UI���������������������������������������������������������������������������Prefab���������������������������������������
���������������
������������������������Attribute
������������[AttributeUsage(...)]
attribute ���������������������������������������������������������[AttributeUsage(AttributeTargets.Class)] public class BindPrefab : Attribute { public string Path { get; private set; } public BindPrefab(string path) { Path = path; } }
���������������������Path
������������������������������������������������
������������
���������������Prefab������������������������������������������������������[BindPrefab("Prefab/StartViewUI")] public class StartView { // ���������������������������������Path������ // ������������������Prefab��������� }
���������������
���������������������������������������������������������������������������������������������������������������������Dictionary
���������Prefab���������������������public class BindAttribute { private static readonly DictionarymPrefabAndScriptMap = new Dictionary (); public class Binder { public void Process(Assembly assembly) { var types = assembly.GetExportedTypes(); foreach (var type in types) { var attributes = Attribute.GetCustomAttributes(type); foreach (var attr in attributes) { if (attr is BindPrefab) { var path = ((BindPrefab)attr).Path; if (!mPrefabAndScriptMap.ContainsKey(path)) { mPrefabAndScriptMap.Add(path, type); } else { Logger.LogWarning("Duplicate prefab path '" + path + "'"); } } } } } } }
������������������������������������������������������������������������������������������������������������������������WWML���UI���������������������������������������������������������
������������������������
������������������������������������������������������������������������������������������������
������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������
���������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
