Beispiel #1
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            State = ResState.Loading;


            if (FromUnityToDll.Setting.SimulationMode)
            {
            }
            else
            {
                var url    = AssetBundleSettings.AssetBundleName2Url(mAssetName);
                var bundle = AssetBundle.LoadFromFile(url);

                mUnloadFlag = true;

                if (bundle == null)
                {
                    Log.E("Failed Load AssetBundle:" + mAssetName);
                    OnResLoadFaild();
                    return(false);
                }

                AssetBundle = bundle;
            }

            State = ResState.Ready;

            return(true);
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            State = ResState.Loading;

#if UNITY_EDITOR
            if (AssetBundleSettings.SimulateAssetBundleInEditor)
            {
            }
            else
#endif
            {
                var url    = AssetBundleSettings.AssetBundleName2Url(mAssetName);
                var bundle = AssetBundle.LoadFromFile(url);

                mUnloadFlag = true;

                if (bundle == null)
                {
                    Log.E("Failed Load AssetBundle:" + mAssetName);
                    OnResLoadFaild();
                    return(false);
                }

                AssetBundle = bundle;
            }

            State = ResState.Ready;

            return(true);
        }
Beispiel #4
0
        public string GetPlatformName()
        {
#if UNITY_EDITOR
            return(GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
#else
            return(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform));
#endif
        }
Beispiel #5
0
        public override bool LoadSync()
        {
            if (!CheckLoadAble())
            {
                return(false);
            }

            State = ResState.Loading;


            if (AssetBundlePathHelper.SimulationMode)
            {
            }
            else
            {
                var         url = AssetBundleSettings.AssetBundleName2Url(mAssetName);
                AssetBundle bundle;
                // var zipFileHelper = ResKit.Architecture.Interface.GetUtility<IZipFileHelper>();

                // if (File.ReadAllText(url).Contains(AES.AESHead))
                // {
                //     if (AESKey == string.Empty)
                //     {
                //         AESKey = JsonUtility.FromJson<EncryptConfig>(Resources.Load<TextAsset>("EncryptConfig").text).AESKey;
                //     }
                //
                //      bundle= AssetBundle.LoadFromMemory((AES.AESFileByteDecrypt(url, AESKey)));
                //
                // }
                // else
                // {
                bundle = AssetBundle.LoadFromFile(url);
                // }


                mUnloadFlag = true;

                if (bundle == null)
                {
                    Log.E("Failed Load AssetBundle:" + mAssetName);
                    OnResLoadFaild();
                    return(false);
                }

                AssetBundle = bundle;
            }

            State = ResState.Ready;

            return(true);
        }
        //生成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();
        }
Beispiel #7
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());
            }
        }
        public string[] GetAllDependenciesByUrl(string url)
        {
            var abName = AssetBundleSettings.AssetBundleUrl2Name(url);

            for (var i = mAllAssetDataGroup.Count - 1; i >= 0; --i)
            {
                string[] depends;
                if (!mAllAssetDataGroup[i].GetAssetBundleDepends(abName, out depends))
                {
                    continue;
                }

                return(depends);
            }

            return(null);
        }
Beispiel #9
0
        public IEnumerator InitResMgrAsync()
        {
#if UNITY_EDITOR
            if (AssetBundleSettings.SimulateAssetBundleInEditor)
            {
                ResKit.ResData = EditorRuntimeAssetDataCollector.BuildDataTable();
                yield return(null);
            }
            else
#endif
            {
                ResKit.ResData.Reset();

                var    outResult  = new List <string>();
                string pathPrefix = "";
#if UNITY_EDITOR || UNITY_IOS
                pathPrefix = "file://";
#endif
                // 未进行过热更
                if (ResKit.LoadResFromStreammingAssetsPath)
                {
                    string streamingPath = Application.streamingAssetsPath + "/AssetBundles/" +
                                           AssetBundleSettings.GetPlatformName() + "/" + ResKit.ResData.FileName;
                    outResult.Add(pathPrefix + streamingPath);
                }
                // 进行过热更
                else
                {
                    string persistenPath = Application.persistentDataPath + "/AssetBundles/" +
                                           AssetBundleSettings.GetPlatformName() + "/" + ResKit.ResData.FileName;
                    outResult.Add(pathPrefix + persistenPath);
                }

                foreach (var outRes in outResult)
                {
                    Debug.Log(outRes);
                    yield return(ResKit.ResData.LoadFromFileAsync(outRes));
                }

                yield return(null);
            }
        }
Beispiel #10
0
        public override IEnumerator DoLoadAsync(System.Action finishCallback)
        {
            //开启的时候已经结束了
            if (RefCount <= 0)
            {
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

#if UNITY_EDITOR
            if (AssetBundleSettings.SimulateAssetBundleInEditor)
            {
                yield return(null);
            }
            else
#endif
            {
                var url  = AssetBundleSettings.AssetBundleName2Url(mAssetName);
                var abcR = AssetBundle.LoadFromFileAsync(url);

                mAssetBundleCreateRequest = abcR;
                yield return(abcR);

                mAssetBundleCreateRequest = null;

                if (!abcR.isDone)
                {
                    Log.E("AssetBundleCreateRequest Not Done! Path:" + mAssetName);
                    OnResLoadFaild();
                    finishCallback();
                    yield break;
                }

                AssetBundle = abcR.assetBundle;
            }

            State = ResState.Ready;
            finishCallback();
        }
Beispiel #11
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);
        }
        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);
        }
Beispiel #13
0
 private static string GetPlatformName()
 {
     return(AssetBundleSettings.GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
 }
Beispiel #14
0
 public static string GetPlatformName()
 {
     return(AssetBundleSettings.GetPlatformName());
 }
Beispiel #15
0
        public override IEnumerator DoLoadAsync(System.Action finishCallback)
        {
            //开启的时候已经结束了
            if (RefCount <= 0)
            {
                OnResLoadFaild();
                finishCallback();
                yield break;
            }

            if (AssetBundlePathHelper.SimulationMode)
            {
                yield return(null);
            }
            else
            {
                var url = AssetBundleSettings.AssetBundleName2Url(mAssetName);

                if (FromUnityToDll.Platform.IsWebGL)
                {
                    var abcR    = UnityWebRequestAssetBundle.GetAssetBundle(url);
                    var request = abcR.SendWebRequest();

                    mAssetBundleCreateRequest = request;
                    yield return(request);

                    mAssetBundleCreateRequest = null;

                    if (!request.isDone)
                    {
                        Log.E("AssetBundleCreateRequest Not Done! Path:" + mAssetName);
                        OnResLoadFaild();
                        finishCallback();
                        yield break;
                    }

                    var ab = DownloadHandlerAssetBundle.GetContent(abcR);

                    AssetBundle = ab;

                    // 销毁
                    abcR.Dispose();
                }
                else
                {
                    var abcR = AssetBundle.LoadFromFileAsync(url);

                    mAssetBundleCreateRequest = abcR;
                    yield return(abcR);

                    mAssetBundleCreateRequest = null;

                    if (!abcR.isDone)
                    {
                        Log.E("AssetBundleCreateRequest Not Done! Path:" + mAssetName);
                        OnResLoadFaild();
                        finishCallback();
                        yield break;
                    }

                    AssetBundle = abcR.assetBundle;
                }
            }

            State = ResState.Ready;
            finishCallback();
        }
Beispiel #16
0
 public static string AssetBundleUrl2Name(string url)
 {
     return(AssetBundleSettings.AssetBundleUrl2Name(url));
 }
Beispiel #17
0
 public static string AssetBundleName2Url(string name)
 {
     return(AssetBundleSettings.AssetBundleName2Url(name));
 }
Beispiel #18
0
 public static string GetPlatformForAssetBundles(UnityEditor.BuildTarget target)
 {
     return(AssetBundleSettings.GetPlatformForAssetBundles(target));
 }
Beispiel #19
0
 static string GetPlatformForAssetBundles(RuntimePlatform platform)
 {
     return(AssetBundleSettings.GetPlatformForAssetBundles(platform));
 }