提交 a3988d07 编写于 作者: 林新发's avatar 林新发

优化PrefabBinder

上级 fda96fc9
此差异已折叠。
此差异已折叠。

using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
using System;
using UObject = UnityEngine.Object;
......@@ -14,24 +16,27 @@ public class PrefabBinder : MonoBehaviour
public class Item
{
public string name;
public UnityEngine.Object obj;
public UObject obj;
}
private Dictionary<string, UObject> _itemDic =new Dictionary<string, UObject>();
public Item[] items = new Item[0];
public UObject GetObj(string name)
{
if (string.IsNullOrEmpty(name)) return null;
private void Awake() {
for (int i = 0, cnt = items.Length; i < cnt; i++)
{
Item item = items[i];
if (item.name.Equals(name))
{
return item.obj;
}
_itemDic.Add(items[i].name, items[i].obj);
}
items = null;
}
public UObject GetObj(string name)
{
if (string.IsNullOrEmpty(name)) return null;
if(_itemDic.ContainsKey(name))
return _itemDic[name];
return null;
}
......
m_EditorVersion: 2021.1.9f1c1
m_EditorVersionWithRevision: 2021.1.9f1c1 (a9c352b271d7)
m_EditorVersion: 2021.1.7f1c1
m_EditorVersionWithRevision: 2021.1.7f1c1 (4e944ebb9621)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册