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);
        }
        async Task CompileCode(EngineNS.EPlatformType platform, bool usecache = false)
        {
            if (!Particle_Client.CheckError())
            {
                return;
            }

            CurrentResourceInfo.Version++;

            List <Macross.ResourceInfos.MacrossResourceInfo.CustomFunctionData> functions = new List <Macross.ResourceInfos.MacrossResourceInfo.CustomFunctionData>();

            Particle_Client.CollectFuncDatas(functions);

            //if (CheckCompileResult(await CompileCode(Macross_Client, platform, functions), platform) == false)
            //    return;
            //if (CheckCompileResult(await CompileMacrossCollector(Macross_Client, platform), platform) == false)
            //    return;
            if (await CompileCode(Particle_Client, ECSType.Client, usecache))
            {
                CompileStatusIcon = TryFindResource("Good") as ImageSource;
            }
            else
            {
                CompileStatusIcon = TryFindResource("Fail") as ImageSource;
                EditorCommon.MessageBox.Show($"{platform}平台MacrossScript编译失败!详细信息请编译游戏工程!\r\n");
                return;
            }

            if (platform == EngineNS.EPlatformType.PLATFORM_WIN)
            {
                //var scriptDllName = EngineNS.CEngine.Instance.FileManager.Bin + "MacrossScript.dll";
                //EngineNS.CEngine.Instance.MacrossDataManager.RefreshMacrossCollector();
                //var assembly = EngineNS.CEngine.Instance.MacrossDataManager.MacrossScripAssembly;//EngineNS.Rtti.RttiHelper.GetAssemblyFromDllFileName(EngineNS.CIPlatform.Instance.CSType, scriptDllName, "", true, true);
                //var clsTypeFullName = Macross.Program.GetClassNamespace(CurrentResourceInfo, ECSType.Client) + "." + Macross.Program.GetClassName(CurrentResourceInfo, ECSType.Client);
                //var clsType = assembly.GetType(clsTypeFullName);
                //var clsIdPro = clsType.GetProperty("ClassId");
                //var classId = (EngineNS.Hash64)clsIdPro.GetValue(null);
                //EngineNS.CEngine.Instance.MacrossDataManager.RefreshMacrossData(ref classId, clsType);
                EngineNS.Macross.MacrossFactory.SetVersion(CurrentResourceInfo.ResourceName, CurrentResourceInfo.Version);
            }

            Particle_Client.PG.Instance = null;

            string pfxcs = CurrentResourceInfo.AbsInfoFileName.Replace(".rinfo", "");

            EngineNS.RName pfxname = EngineNS.RName.GetRName(pfxcs.Replace(CEngine.Instance.FileManager.ProjectContent, ""));
            await Particle_Client.AddPfxMacross(pfxname);
        }