void TestAttributeWithPathToAddPrefabScript()
        {
            InitAttribute();

            GameObject prefab = Resources.Load <GameObject>(path);
            GameObject tmp    = GameObject.Instantiate(prefab, parent);
            Type       type   = BindPrefabPathAndScriptUtil.GetType(path);

            tmp.AddComponent(type);
        }
Esempio n. 2
0
        public void Init()
        {
            Assembly assembly = Assembly.GetAssembly(typeof(BindPrefab));

            Type[] types = assembly.GetExportedTypes();

            foreach (Type type in types)
            {
                foreach (Attribute attribute in Attribute.GetCustomAttributes(type, true))
                {
                    if (attribute is BindPrefab)
                    {
                        BindPrefab data = attribute as BindPrefab;
                        BindPrefabPathAndScriptUtil.Bind(data.Path, type);
                    }
                }
            }
        }