Пример #1
0
    public void ExportData()
    {
        if (string.IsNullOrEmpty(this.ExportFolderPath))
        {
            EditorUtility.DisplayDialog("导出出错", "请选择导出文件目录", "确定");
            return;
        }
        var path = AssetDatabase.GetAssetPath(this.SourceData);

        if (path.EndsWith(DataToDataOperator.ExcelExtension1) ||
            path.EndsWith(DataToDataOperator.ExcelExtension2))
        {
            //说明是excel文件
            var excel = CaomaoEditorHelper.ReadExcel(path);
            if (excel == null)
            {
                Debug.LogError("No Excel:" + path);
                return;
            }
            var conveter = new ExcelToClassTypeConveter(excel.Tables[0], this.LoadTemplate(), this.nameSpace, this.ExportFolderPath);
            conveter.Parse();
            AssetDatabase.Refresh();
        }
        else
        {
            EditorUtility.DisplayDialog("文件格式不支持", "请选择Excel文件作为配置文件", "确定");
            return;
        }
    }
Пример #2
0
        public void UpdateLocalizationToSB()
        {
            int col   = 0;
            int row   = 0;
            var excel = CaomaoEditorHelper.ReadExcelRow(this.ExcelFilePath, ref col, ref row);

            if (excel == null)
            {
                Debug.LogError("No Excel:" + this.ExcelFilePath);
                return;
            }
            DataRow firstRow = excel[0];

            for (int c = 2; c < col; c++)
            {
                var lang = firstRow[c] as string;
                if (string.IsNullOrEmpty(lang))
                {
                    continue;
                }
                Debug.Log(lang);
                this.AddConfigName(lang);
            }
            this.InitSbData();
            if (this.allSbData.Count > 0)
            {
                //第一行,第一列是id,接下来是各国语言
                for (int r = 1; r < row; r++)
                {
                    var nextRow = excel[r];
                    var id      = nextRow[1].ToString();
                    if (string.IsNullOrEmpty(id))
                    {
                        continue;
                    }
                    for (int c = 2; c < col; c++)
                    {
                        var index = c - 2;
                        if (index < this.Config.Count)
                        {
                            var content = excel[r][c].ToString();
                            if (string.IsNullOrEmpty(content))
                            {
                                continue;
                            }
                            Debug.Log(content);
                            var lang = this.Config[index].Language;
                            LocalizationData data = null;
                            this.allSbData.TryGetValue(lang, out data);
                            if (data != null)
                            {
                                data.AddData(id.ToString(), content);
                            }
                        }
                    }
                }
                this.SaveLocalizationData();
            }
        }
Пример #3
0
        public override void Action(int instanceId, string pathName, string resourceFile)
        {
            var graph = new NewbieGraphData();

            Debug.Log("r3r");
            //设置数据
            CaomaoEditorHelper.WriteGraphDataToDisk(pathName, graph);
            //刷新项目数据
            AssetDatabase.Refresh();
            //选择搞物体
            UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath <Object>(pathName);
            Selection.activeObject = obj;
        }
Пример #4
0
        public void GenLocalizationConst()
        {
            //var templatePath = $"Assets/{this.TemplateFilePath}";
            var templateText = AssetDatabase.LoadAssetAtPath <TextAsset>(this.TemplateFilePath);

            if (templateText == null)
            {
                Debug.LogError("Template文件不存在:" + this.TemplateFilePath);
                return;
            }
            CaomaoScriptGenerateModule.Instance.Restart(templateText.text);
            int col = 0; int row = 0;
            var excel = CaomaoEditorHelper.ReadExcelRow(this.ExcelFilePath, ref col, ref row);

            if (excel == null)
            {
                Debug.LogError("No Excel:" + this.ExcelFilePath);
                return;
            }
            List <object[]> allV = new List <object[]>();

            for (int r = 1; r < row; r++)
            {
                var nextRow    = excel[r];
                var constValue = nextRow[0].ToString();
                if (string.IsNullOrEmpty(constValue))
                {
                    //Debug.LogError("Const常量为null:"+r);
                    continue;
                }
                Debug.Log(constValue);
                var id = nextRow[1].ToString();
                if (string.IsNullOrEmpty(id))
                {
                    //Debug.LogError("Id为null:" + r);
                    continue;
                }
                Debug.Log(id);
                var objects = new object[]
                {
                    constValue,
                    id
                };
                allV.Add(objects);
            }
            CaomaoScriptGenerateModule.Instance.AddVariable("variables", allV.ToArray());
            var script = CaomaoScriptGenerateModule.Instance.Parse();

            File.WriteAllText(Application.dataPath + "/CaomaoFramework/LocalizationModule/LocalizationConst.cs", script);
            AssetDatabase.Refresh();
        }
Пример #5
0
    /// <summary>
    /// 读取excel文件转成类的实例
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns></returns>
    private object[] GetExcelDataToClassObject()
    {
        if (this.CheckAssembly() == false)
        {
            return(null);
        }
        var path  = AssetDatabase.GetAssetPath(this.SourceData);
        var excel = CaomaoEditorHelper.ReadExcel(path);

        if (excel == null)
        {
            Debug.LogError("No Excel:" + path);
            return(null);
        }
        var convert = new ExcelToClassInstanceConveter(this.assembly);

        convert.Parse(excel.Tables[0]);
        return(convert.Instances);
    }
Пример #6
0
        public void LoadPlayerPrefs()
        {
            this.m_bRefresh = false;
            var platform = CaomaoEditorHelper.GetDevelopPlatform();

            if (platform == EDevPlatformType.Windows)
            {
                RegistryKey unityKey = Registry.CurrentUser.CreateSubKey(
                    "Software\\Unity\\UnityEditor\\" + PlayerSettings.companyName + "\\" + PlayerSettings.productName);
                this.m_arraykey = unityKey.GetValueNames();
            }
            else if (platform == EDevPlatformType.Mac)
            {
                string plistPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/Library/Preferences/unity." + PlayerSettings.companyName + "." + PlayerSettings.productName + ".plist";
                if (File.Exists(plistPath))
                {
                    FileInfo fi = new FileInfo(plistPath);
                    Dictionary <string, object> plist = (Dictionary <string, object>)Plist.readPlist(fi.FullName);
                    this.m_arraykey = new string[plist.Count];
                    plist.Keys.CopyTo(this.m_arraykey, 0);
                }
            }
            if (this.m_arraykey != null && this.m_arraykey.Length > 0)
            {
                this.m_bRefresh = true;
                this.AllPlayerPrefsData.Clear();
                int index = 0;
                for (int i = 0; i < this.m_arraykey.Length; i++)
                {
                    var keyContent = this.m_arraykey[i];
                    var keyName    = keyContent.Substring(0, keyContent.LastIndexOf("_"));
                    if (keyName == Unity_Graphics_Quality || keyName == Unity_Player_SessionId ||
                        keyName == Unity_Player_SessionCount || keyName == Unity_Cloud_UserId)
                    {
                        continue;
                    }
                    var data = CaomaoPlayerPrefsDataFactory.CreateCaomaoPlayerPrefsData(keyName, index++);
                    this.AllPlayerPrefsData.Add(data);
                }
            }
            CaomaoPlayerPrefsDataBase.ModifyCallback = this.SelectCallback;
        }