예제 #1
0
        /// <summary>
        /// 忽略名单
        /// </summary>
        /// <param name="properties"></param>
        /// <returns></returns>
        static void IgnoreList(out List <Object> properties, bool isSim)
        {
            properties = new List <Object>();
            ExcelTool            excelTool            = new ExcelTool(isSim);
            PropertyConstManager propertyConstManager = ScriptableObject.CreateInstance <PropertyConstManager>();

            properties.Add(propertyConstManager);
            propertyConstManager.PropertyConst = excelTool.CreatePropertyConstArrayWithExcel(ExcelConfig.PropertyConst, ref propertyConstManager.Search);

            PropertyPropertyManager propertyPropertyManager = ScriptableObject.CreateInstance <PropertyPropertyManager>();

            properties.Add(propertyPropertyManager);
            propertyPropertyManager.PropertyProperty = excelTool.CreatePropertyPropertyArrayWithExcel(ExcelConfig.PropertyCH2 + ExcelConfig.PropertyFight, propertyPropertyManager);
        }
예제 #2
0
        void CreateItemAssetBase()
        {
            DirectoryInfo root = new DirectoryInfo(_outputFile);

            foreach (var file in root.GetFiles())
            {
                if (!file.Name.Contains("meta") && file.Name[0] != 'I')
                {
                    string name       = file.Name.Replace(".cs", "");
                    Type   type       = GetTypyByName(name);
                    bool   ignoreType = false;
                    foreach (var ignore in _ignoreList)
                    {
                        if (ignore == type)
                        {
                            ignoreType = true;
                            break;
                        }
                    }
                    if (!ignoreType)
                    {
                        _properties.Add(ScriptableObject.CreateInstance(type));
                    }
                }
            }
            ExcelTool excelTool = new ExcelTool(_scn);

            for (int i = 0; i < _properties.Count; i++)
            {
                try
                {
                    var        manager = _properties[i].As <IProperty>();
                    var        name    = manager.GetType().Name.Replace("Manager", "");
                    var        type    = GetTypyByName(name);
                    MethodInfo mi      = excelTool.GetType().GetMethod("CreateProperty")
                                         .MakeGenericMethod(type);
                    var items = mi.Invoke(null, new object[] { manager });
                    manager.Split((Item[])items);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Debug.Log(_properties[i].GetType().Name);
                    throw;
                }
            }
            foreach (var property in _ignoreProperties)
            {
                _properties.Add(property);
            }
            string dir = "";

            dir = _scn ? ExcelConfig.assetPathSCN : ExcelConfig.assetPathTCN;
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            if (DeleteAllFile(dir))
            {
                ;
            }
            foreach (var property in _properties)
            {
                string assetPath = _scn?$"{dir}{property}SCN.asset": $"{dir}{property}TCN.asset";
                AssetDatabase.CreateAsset(property, assetPath);
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            Debug.Log("输出文件成功");
        }