예제 #1
0
        public void LocalVersionGetter(Action <DLLVersion> onLocalVersionGetted)
        {
            if (ILRuntimeScriptSetting.LoadDLLFromStreamingAssetsPath)
            {
                var localJsonFile =
                    StreamingAssetPath.CombinePath(
                        "AssetBundles/{0}/hotfix.json".FillFormat(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform)));

                ObservableWWW.Get(localJsonFile).Subscribe(content =>
                {
                    var localVersion = content.FromJson <DLLVersion>();

                    onLocalVersionGetted(localVersion);
                });
            }
            else
            {
                var localJsonFile =
                    PersistentDataPath.CombinePath(
                        "AssetBundles/{0}/hotfix.json".FillFormat(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform)));

                var localVersion = localJsonFile.LoadJson <DLLVersion>();

                onLocalVersionGetted(localVersion);
            }
        }
예제 #2
0
        public string GetPlatformName()
        {
#if UNITY_EDITOR
            return(GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
#else
            return(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform));
#endif
        }
        //生成clr绑定
        private static void GenClrBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin)
        {
            if (platform == RuntimePlatform.Lumin)
            {
                platform = Application.platform;
            }

            //用新的分析热更dll调用引用来生成绑定代码
            var dllpath = Application.streamingAssetsPath + "/AssetBundles/" + AssetBundleSettings.GetPlatformForAssetBundles(platform) +
                          "/hotfix.dll";

            ILRuntimeHelper.LoadHotfix(dllpath, false);
            BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain,
                                                     "Assets/" + ILRuntimeScriptSetting.Default.GenClrBindPath.CreateDirIfNotExists());
            AssetDatabase.Refresh();
        }
예제 #4
0
        IEnumerator DoDownload()
        {
            var savePath = PersistentDataPath.CombinePath("AssetBundles")
                           .CombinePath(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform));

            savePath.DeleteDirIfExists();
            savePath.CreateDirIfNotExists();

            var fileNames = new string[]
            {
                "Android",
                "Android.manifest",
                "Android.manifest.meta",
                "Android.meta",
                "README.en.md",
                "asset_bindle_config.bin",
                "asset_bindle_config.bin.meta",
                "audio",
                "audio.manifest",
                "audio.manifest.meta",
                "audio.meta",
                "hotfix.dll",
                "hotfix.dll.mdb",
                "hotfix.dll.mdb.meta",
                "hotfix.dll.meta",
                "hotfix.json",
                "hotfix.json.meta",
                "shapes",
                "shapes.manifest",
                "shapes.manifest.meta",
                "shapes.meta",
                "uitetrispanel_prefab",
                "uitetrispanel_prefab.manifest",
                "uitetrispanel_prefab.manifest.meta",
                "uitetrispanel_prefab.meta",
            };

            foreach (var fileName in fileNames)
            {
                var www         = new UnityWebRequest(ServerHost + fileName);
                var persistFile = savePath.CombinePath(fileName);

                www.downloadHandler = new DownloadHandlerFile(persistFile);
                yield return(www.SendWebRequest());
            }
        }
예제 #5
0
        public static void Load()
        {
            // 获取本地的版本

            // 从哪里获取 本地版本号
            // 2. persistentDataPath

            // 从来没更新过就从 stream 加载

            // 更新过 从 persistentDataPath

            // 怎么判断是否进行更新过

            // 1. streamingAssetsPath
            var versionJsonPath = Application.streamingAssetsPath + "/" + AssetBundleSettings.GetPlatformForAssetBundles(Application.platform) +
                                  "/hotfix/hotfix.json";

            var version = SerializeHelper.LoadJson <DLLVersion>(versionJsonPath);

            Version = version;
            Debug.Log("Local Version Loded:" + version.Version);
        }
예제 #6
0
 static string GetPlatformForAssetBundles(RuntimePlatform platform)
 {
     return(AssetBundleSettings.GetPlatformForAssetBundles(platform));
 }
예제 #7
0
 public static string GetPlatformForAssetBundles(UnityEditor.BuildTarget target)
 {
     return(AssetBundleSettings.GetPlatformForAssetBundles(target));
 }
예제 #8
0
 private static string GetPlatformName()
 {
     return(AssetBundleSettings.GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
 }
        public void Init(IQFrameworkContainer container)
        {
            SerializeHelper.SerializeContainer.RegisterInstance <IJsonSerializer>(new JsonDotnetSerializer());

            mRootLayout = new VerticalLayout();

            EasyIMGUI.Label().Text("ScriptKitILRuntime 的编辑器").FontSize(12).Parent(mRootLayout);

            //EditorStyles.popup.fixedHeight = 30;

            var verticalLayout = new VerticalLayout("box").Parent(mRootLayout);

            var versionText = "0";

            verticalLayout.AddChild(new HorizontalLayout()
                                    .AddChild(EasyIMGUI.Label().Text("版本号(数字):"))
                                    .AddChild(EasyIMGUI.TextField()
                                              .Text(versionText)
                                              .Self(text => text.Content.Bind(t => versionText = t)))
                                    );

            var versionBtn = EasyIMGUI.Button();

            versionBtn.AddLayoutOption(GUILayout.Height(30));
            verticalLayout.AddChild(versionBtn.Text("生成版本信息").OnClick(() =>
            {
                var generatePath = Application.streamingAssetsPath + "/AssetBundles/" +
                                   AssetBundleSettings.GetPlatformForAssetBundles(Application.platform) + "/";

                var filenames = Directory.GetFiles(generatePath);

                new DLLVersion()
                {
                    Assets  = filenames.Select(f => f.GetFileName()).ToList(),
                    Version = versionText.ToInt()
                }.SaveJson(generatePath + "/hotfix.json");

                AssetDatabase.Refresh();
            }));

            EasyIMGUI.Custom().OnGUI(() =>
            {
                GUILayout.BeginVertical();
                {
                    showGenDll = EditorGUILayout.BeginFoldoutHeaderGroup(showGenDll, "编译热更dll");
                    if (showGenDll)
                    {
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("编译dll(Debug)", GUILayout.Height(30)))
                        {
                            var outpath_win = Application.streamingAssetsPath + "/AssetBundles/" +
                                              AssetBundleSettings.GetPlatformForAssetBundles(Application.platform);
                            ScriptBuildTools.BuildDll(outpath_win, ScriptBuildTools.BuildMode.Debug);
                        }
                        if (GUILayout.Button("编译dll(Release)", GUILayout.Height(30)))
                        {
                            var outpath_win = Application.streamingAssetsPath + "/AssetBundles/" +
                                              AssetBundleSettings.GetPlatformForAssetBundles(Application.platform);
                            ScriptBuildTools.BuildDll(outpath_win, ScriptBuildTools.BuildMode.Release);
                        }
                        GUILayout.EndHorizontal();
                        GUI.color = Color.green;
                        GUILayout.Label(
                            @"注意事项:
     1.编译服务使用Roslyn,请放心使用
     2.如编译出现报错,请仔细看报错信息,和报错的代码行列,
       一般均为语法错
     3.语法报错原因可能有:主工程访问hotfix中的类, 使用宏
       编译时代码结构发生变化..等等,需要细心的你去发现"
                            );
                        GUI.color = GUI.backgroundColor;
                    }
                    EditorGUILayout.EndFoldoutHeaderGroup();

                    showGenAdapter = EditorGUILayout.BeginFoldoutHeaderGroup(showGenAdapter, "生成跨域Adapter");
                    if (showGenAdapter)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("程序集名:");
                        assemblyName = GUILayout.TextField(assemblyName);
                        GUILayout.EndHorizontal();
                        EditorGUILayout.HelpBox("类名如果有命名空间需要带上", MessageType.Info);
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("类名:");
                        adapterClassName = GUILayout.TextField(adapterClassName);
                        GUILayout.EndHorizontal();
                        if (GUILayout.Button("生成", GUILayout.Height(30)))
                        {
                            GenCrossBindAdapter();
                        }
                    }
                    EditorGUILayout.EndFoldoutHeaderGroup();

                    showGenDllBind = EditorGUILayout.BeginFoldoutHeaderGroup(showGenDllBind, "Clr Binding And Link");
                    if (showGenDllBind)
                    {
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("生成Clr绑定(不知道干嘛别点!)", GUILayout.Height(30)))
                        {
                            GenClrBindingByAnalysis();
                        }
                        if (GUILayout.Button("生成Link.xml", GUILayout.Height(30)))
                        {
                            StripCode.GenLinkXml();
                        }
                        GUILayout.EndHorizontal();
                    }

                    EditorGUILayout.EndFoldoutHeaderGroup();
                }
                GUILayout.EndVertical();
            }).Parent(verticalLayout);

            var runModelPop = new EnumPopupView(ILRuntimeScriptSetting.Default.HotfixRunMode);

            runModelPop.Style.Value.fixedHeight = 30;
            runModelPop.AddLayoutOption(GUILayout.Height(30));
            runModelPop.ValueProperty.Bind(v => ILRuntimeScriptSetting.Default.HotfixRunMode = (HotfixCodeRunMode)v);
            EasyIMGUI.Horizontal().AddChild(EasyIMGUI.Label().Text("运行模式")).AddChild(runModelPop).Parent(mRootLayout);
        }