void Createprefab() { var itemObject = PrefabCreator.CreatePlacement(_currPlacementConfig, _prefabPath, _scalefloat); DestroyImmediate(itemObject); }
void SaveRole() { List <tian.PlacementData> listpl = new List <tian.PlacementData>(); _placementConfigDic = _placementConfigList.ToDictionary(item => item.id, item => item); //string jsonString = Tools.Obj2Json(_placementConfigDic, true); //Debug.Log("jsonString = " + jsonString); //Tools.WriteStringFromFile(Application.dataPath + "/" + _roleDataFile, jsonString); Tools.SaveOneData <PlacementConfig>(_placementConfigDic, Application.dataPath + "/" + "Resources_moved/Scripts/box/InteractionComponentsList"); string scalejson = Tools.Obj2Json(_scalefloat, true); Tools.WriteStringFromFile(Application.dataPath + "/Resources_moved/Scripts/box/scale.json", scalejson); string tagjsonstring = Tools.Obj2Json(taglist, true); Tools.WriteStringFromFile(Application.dataPath + "/Resources_moved/Scripts/box/Taglist.json", tagjsonstring); // 生成预制体 add by TangJian 2017/11/16 17:42:05 // 创建目录 add by TangJian 2018/06/12 17:12:19 Tools.CreateFolder(Application.dataPath.Substring(0, Application.dataPath.IndexOf("/Assets")) + "/" + _prefabPath); Tools.CreateFolder(Application.dataPath.Substring(0, Application.dataPath.IndexOf("/Assets")) + "/" + _prefabPath + "/Mats"); Tools.CreateFolder(Application.dataPath.Substring(0, Application.dataPath.IndexOf("/Assets")) + "/" + _prefabPath + "/Render"); Tools.CreateFolder(Application.dataPath.Substring(0, Application.dataPath.IndexOf("/Assets")) + "/" + _prefabPath + "/Render/Anim"); Tools.CreateFolder(Application.dataPath.Substring(0, Application.dataPath.IndexOf("/Assets")) + "/" + _prefabPath + "/Render/Image"); //try //{ int currIndex = 0; //// 移除老的预制体 add by TangJian 2018/11/20 22:46 //var files = Tools.GetFilesInFolder(Application.dataPath.Substring(0, Application.dataPath.IndexOf("/Assets")) + "/" + prefabPath + "/Render"); //foreach (var item in files) //{ // EditorUtility.DisplayProgressBar("移除老的预制体", item, (float)currIndex++ / files.Count); // Debug.Log("删除文件: " + item); // AssetDatabase.DeleteAsset(item.Substring(item.IndexOf("Assets/"))); //} // 生成新的预制体 add by TangJian 2018/11/20 22:46 currIndex = 0; foreach (var item in _placementConfigDic) { EditorUtility.DisplayProgressBar("生成新的预制体", item.Value.id, (float)currIndex++ / _placementConfigDic.Count); listpl.Add(item.Value.placementData); // dataConfigDic.Add(item.Value.placementData.id,item.Value.placementData); var itemObject = PrefabCreator.CreatePlacement(item.Value, _prefabPath, _scalefloat); DestroyImmediate(itemObject); } //} //catch (System.Exception e) //{ // Debug.LogError(e); //} //finally //{ EditorUtility.ClearProgressBar(); //} // _dataConfigDic = listpl.ToDictionary(item => item.id, item => item); // string tostr = Tools.Obj2Json(_dataConfigDic, true); // Tools.WriteStringFromFile(Application.dataPath + "/" + _dataFile, tostr); }