public static void OpenDiagle() { //if (SceneFileCopy.OpenUf3dFile()) //{ // Uf3dLoader loader = new Uf3dLoader(); // loader.parse(SceneFileCopy.SourceFile); //} var list = GetFilesPath(@"D:\特效\out"); foreach (var item in list) { Uf3dLoader loader = new Uf3dLoader(); SceneFileCopy.openUF3D(item); loader.parse(item); } //"D:\特效\out\战斗中特效\粒子特效\命中效果\圆心扩散\冲击波 绿\ZhenJi.uf3d" //D:\特效\out\待整理文档\2017.8月需求\RPG\征服者机甲\核子轰击 //"D:\特效\out\翅膀分类专题\创世之翼\ChiBangShouQi.uf3d" //Uf3dLoader loader = new Uf3dLoader(); //string[] names1 = new string[] { "Dun", "FengBaoShuangXiong_JuQi" , "FengBaoShuangXiong_QiangKouHuoHua", "ChiBang", "ChiBangShouQi", "BeiJi", "c1"}; //string[] names = new string[] { "smoke", "xuanfeng0", "explosion1", "xuanfeng" , "UltraISO", "baofa" , "chuizi", "shuoji", "jian1", "GLOW", "HanDiYiJi", "HuoZhiQuan", "DianShanLeiMing", "TianLei_BaoZha", "JinQuTeXiao", "TianLei", "hjnbe" }; //var tmp = names; //loader.parse("D:\\Users\\Administrator\\Desktop\\uf3d\\" + tmp[tmp.Length - 4] + ".uf3d"); }
public static int Assemble(Uf3dLoader loader) { AssembleParticleSystem(loader); return(0); }
private static void AssembleParticleSystem(Uf3dLoader loader) { Dictionary <int, GameObject> particles = new Dictionary <int, GameObject>(); var root = new GameObject(Path.GetFileNameWithoutExtension(loader.StrFileName)); root.AddComponent <UnityEngine.ParticleSystem>(); UnityEngine.ParticleSystem rootUPS = root.GetComponent <UnityEngine.ParticleSystem>(); var rootMain = rootUPS.main; rootMain.duration = 0.1f; rootMain.loop = false; var tmpEmission = rootUPS.emission; tmpEmission.enabled = false; var tmpShape = rootUPS.shape; tmpShape.enabled = false; var rotateOffset = new Quaternion(); rotateOffset.eulerAngles = new Vector3(0, 0, 0); root.transform.localRotation = rotateOffset; for (int i = 0; i < loader.ParticleSystemList.Count; i++) { ParticleSystem ps = loader.ParticleSystemList[i]; ps.RootFileName = root.name; var tex2D = AssembleTexture(ps, loader.Resource); var mtl = AssembleMaterial(ps, loader.Resource); var mesh = AssembleMesh(ps, loader.Resource, true); var unityParticleSystem = new GameObject(ps.Name); unityParticleSystem.AddComponent <UnityEngine.ParticleSystem>(); var matrix = ps.Matrix; //if (ps.Parent != -1) //{ // var father = particles[ps.Parent]; // unityParticleSystem.transform.parent = father.transform; //} //else //{ // unityParticleSystem.transform.parent = root.transform; //} unityParticleSystem.transform.parent = root.transform; TransformUtil.SetTransformFromMatrix(unityParticleSystem.transform, ref matrix); var tmpRotation = unityParticleSystem.transform.localRotation; Quaternion rotNeg90 = new Quaternion(); rotNeg90.eulerAngles = new Vector3(-90, 0, 0); //local rotation tmpRotation * rotNeg90, NOT global rotation rotNeg90 * tmpRotation unityParticleSystem.transform.localRotation = tmpRotation * rotNeg90; //exchange y,z scale unityParticleSystem.transform.localScale = new Vector3(unityParticleSystem.transform.localScale.x, unityParticleSystem.transform.localScale.z, unityParticleSystem.transform.localScale.y); UnityEngine.ParticleSystem ups = unityParticleSystem.GetComponent <UnityEngine.ParticleSystem>(); //StreamWriter sw = new StreamWriter("D:\\ps.txt", false, Encoding.UTF8); //sw.WriteLine(string.Format("displayName \t propertyPath \t type")); //UnityEditor.SerializedObject so = new UnityEditor.SerializedObject(ups); //UnityEditor.SerializedProperty it = so.GetIterator(); //while (it.Next(true)) //{ // UnityEngine.Debug.Log(it.propertyPath); // int count = it.propertyPath.Count(f => f == '.'); // sw.WriteLine(string.Format("{0}{1},{2},{3},{4}", (count == 0 ? "" : String.Empty.PadLeft(count, '-')), it.displayName, it.propertyPath, it.type, it.tooltip)); //} //sw.Close(); FillMainModule(ups, ps); FillEmissionModule(ups, ps); FillShapeModule(ups, ps); FillVelocityOverLifetimeModule(ups, ps); FillRotationOverTimeModule(ups, ps); FillRenderModule(ups, ps); FillExtraParam(ups, ps); FillEffector(ups, ps); particles.Add(ps.ChunkId, unityParticleSystem); rootMain.loop = rootMain.loop | ups.main.loop; rootMain.duration = UnityEngine.Mathf.Max(rootMain.duration, ups.main.duration); } UnityEngine.Object prefab = UnityEditor.PrefabUtility.CreateEmptyPrefab(SceneFileCopy.GetRelativePrefabDir(root.name) + root.name + ".prefab"); UnityEditor.PrefabUtility.ReplacePrefab(root, prefab, UnityEditor.ReplacePrefabOptions.ReplaceNameBased); }