Esempio n. 1
0
        public void WriteDataFile(string filePath)
        {
            string fileName   = PathHelper.Path2Name(filePath);
            string samePath   = PathHelper.GetSamePart(filePath, ProjectPathConfig.externalTablePath);
            string externPath = "";// PathHelper.GetParentDir(filePath.Substring(samePath.Length)); ;

            if (!string.Equals(samePath, ProjectPathConfig.externalTablePath))
            {
                externPath = PathHelper.GetParentDir(filePath.Substring(samePath.Length));
            }

            fileName = fileName.Substring(0, 1).ToUpper() + fileName.Substring(1);
            DataTable mSheet   = mResultSet.Tables[0];
            int       rowCount = mSheet.Rows.Count;
            int       colCount = mSheet.Columns.Count;

            if (mSheet.Rows.Count <= 4)
            {
                return;
            }
            CreateTDData(fileName, externPath, mSheet, rowCount, colCount);
            CreateTDDataTable(fileName, externPath, mSheet, rowCount, colCount);
            CreateTDDataExtend(fileName, externPath, mSheet, rowCount, colCount);
            CreateTDDataTableExtend(fileName, externPath, mSheet, rowCount, colCount);
        }
Esempio n. 2
0
        static public void AutoCreateAttribute()
        {
            //子物体以这种名字开头的话,则会被构建属性
            //如Img_Title Btn_Close

            //可能和已有的类重复
            if (Selection.gameObjects.Length == 0)
            {
                return;
            }
            GameObject selectobj = Selection.gameObjects[0];
            string     name      = selectobj.name;

            List <AttrInfo> attrInfos = GetAttrInfosInGameObject(selectobj);

            if (attrInfos.Count == 0)
            {
                return;
            }

            var    script = selectobj.GetComponent(name);
            string path   = Application.dataPath + "/";

            if (script != null)
            {
                var monoScript = MonoScript.FromMonoBehaviour((MonoBehaviour)script);
                path = AssetDatabase.GetAssetPath(monoScript.GetInstanceID());
                path = PathHelper.GetParentDir(path) + "/";
            }
            Debug.LogError(path);
            //string path = Application.dataPath + "/";
            string filePath     = path + name + "_AutoBind.cs";
            string fileMonoPath = path + name + ".cs";

            if (!IO.IsFileExist(fileMonoPath))
            {
                IO.WriteFile(fileMonoPath, WriteEmptyMono(name), true);
            }
            IO.DelFile(filePath);
            IO.WriteFile(filePath, WriteNewFile(name, attrInfos), true);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorPrefs.SetString(EDITKEY, name);
        }