public async Task SetObjectToEdit(ResourceEditorContext context)
        {
            if (context.ResInfo == null)
            {
                return;
            }

            await Particle_Client.Viewport.WaitInitComplated();

            SetBinding(TitleProperty, new Binding("ResourceName")
            {
                Source = context.ResInfo, Converter = new EditorCommon.Converter.RNameConverter_PureName()
            });

            await Particle_Client.SetObjectToEdit();

            // ResInfo 可能在不同的线程生成的,所以这里强制读取一下文件
            CurrentResourceInfo = await EditorCommon.Resources.ResourceInfoManager.Instance.CreateResourceInfoFromFile(context.ResInfo.AbsInfoFileName, context.ResInfo.ParentBrowser) as Macross.ResourceInfos.MacrossResourceInfo;

            CurrentParticleResourceInfo = CurrentResourceInfo as ParticleResourceInfo;
            UpdateUndoRedoKey();

            Particle_Client.CurrentResourceInfo = CurrentResourceInfo;
            //var ddd = new EngineNS.Bricks.Particle.McParticleEffector();
            await Particle_Client.Load();


            string filename = CurrentResourceInfo.AbsInfoFileName.Replace(CurrentResourceInfo.AbsPath, "").Replace(".macross.rinfo", "");
            string csname   = CurrentResourceInfo.ResourceName.Address + "/" + filename + "_Client.cs";

            if (!EngineNS.CEngine.Instance.FileManager.FileExists(csname))
            {
                await Save();
            }
            else
            {
                if (CurrentParticleResourceInfo.NeedRefresh)
                {
                    await CompileCode(EngineNS.EPlatformType.PLATFORM_WIN);

                    CurrentParticleResourceInfo.NeedRefresh = false;
                    await CurrentParticleResourceInfo.Save();
                }
                //await CompileCode(EngineNS.EPlatformType.PLATFORM_WIN);
                string         pfxcs   = CurrentResourceInfo.AbsInfoFileName.Replace(".rinfo", "");
                EngineNS.RName pfxname = EngineNS.RName.GetRName(pfxcs.Replace(CEngine.Instance.FileManager.ProjectContent, ""));

                await Particle_Client.AddPfxMacross(pfxname);
            }

            //await CompileCode(EngineNS.EPlatformType.PLATFORM_WIN);
        }
        public override async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new ParticleResourceInfo();

            var data = createData as ParticleCreateData;
            //result.CenterDataTypeName = data.CenterDataTypeName;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.MacrossExtension;
            result.ResourceName      = EngineNS.RName.GetRName(reName, data.RNameType);
            result.BaseTypeIsMacross = data.IsMacrossType;
            if (result.BaseTypeIsMacross)
            {
                result.BaseTypeSaveName = data.ClassType.FullName;
                var baseResInfo = await GetBaseMacrossResourceInfo(this);

                if (baseResInfo != null)
                {
                    ReferenceRNameList.Add(baseResInfo.ResourceName);
                }
            }
            else
            {
                result.BaseTypeSaveName = EngineNS.Rtti.RttiHelper.GetTypeSaveString(data.ClassType);
            }
            result.ResourceType = EngineNS.Editor.Editor_RNameTypeAttribute.Macross;


            //拷贝模板
            if (string.IsNullOrEmpty(data.TemplateName) == false)
            {
                string newfolder = result.ResourceName.Address;

                string tempfolder = RName.GetRName(data.TemplateName).Address;
                EngineNS.CEngine.Instance.FileManager.CreateDirectory(newfolder);
                EngineNS.CEngine.Instance.FileManager.CopyDirectory(tempfolder, newfolder);
                //EngineNS.CEngine.Instance.FileManager.DeleteFile(newfolder + "/particle1_Client.cs");
                //string newcsname = newfolder + "/" + data.ResourceName + "_Client.cs";
                //if (EngineNS.CEngine.Instance.FileManager.FileExists(newcsname))
                //{
                //    EngineNS.CEngine.Instance.FileManager.DeleteFile(newcsname);
                //}

                var csfiles = EngineNS.CEngine.Instance.FileManager.GetFiles(newfolder, "*.cs", System.IO.SearchOption.AllDirectories);
                if (csfiles != null && csfiles.Count != 0)
                {
                    for (int i = 0; i < csfiles.Count; i++)
                    {
                        if (EngineNS.CEngine.Instance.FileManager.FileExists(csfiles[i]))
                        {
                            EngineNS.CEngine.Instance.FileManager.DeleteFile(csfiles[i]);
                        }
                    }
                }
            }


            // 创建时走一遍编译,保证当前Macross能够取到this类型
            var csType        = ECSType.Client;
            var codeGenerator = new CodeGenerator();
            var ctrl          = new ParticleMacrossLinkControl();

            ctrl.CurrentResourceInfo = result;
            ctrl.CSType = csType;
            var codeStr = await codeGenerator.GenerateCode(result, ctrl);

            if (!EngineNS.CEngine.Instance.FileManager.DirectoryExists(result.ResourceName.Address))
            {
                EngineNS.CEngine.Instance.FileManager.CreateDirectory(result.ResourceName.Address);
            }
            var codeFile = $"{result.ResourceName.Address}/{result.ResourceName.PureName()}_{csType.ToString()}.cs";

            using (var fs = new System.IO.FileStream(codeFile, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite))
            {
                fs.Write(System.Text.Encoding.Default.GetBytes(codeStr), 0, Encoding.Default.GetByteCount(codeStr));
            }
            await codeGenerator.GenerateAndSaveMacrossCollector(csType);

            var files = codeGenerator.CollectionMacrossProjectFiles(csType);

            codeGenerator.GenerateMacrossProject(files.ToArray(), csType);
            EditorCommon.Program.BuildGameDll(true);
            return(result);
        }