public override bool LoadSync() { if (!CheckLoadAble()) { return(false); } State = ResState.Loading; #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { } else #endif { var url = QFrameworkSettingData.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); }
private static void Open() { var frameworkConfigEditorWindow = (PreferencesWindow)GetWindow(typeof(PreferencesWindow), true); frameworkConfigEditorWindow.titleContent = new GUIContent("QFramework Settings"); frameworkConfigEditorWindow.CurSettingData = QFrameworkSettingData.Load(); frameworkConfigEditorWindow.Show(); OnShow(); }
public string[] GetAllDependenciesByUrl(string url) { var abName = QFrameworkSettingData.AssetBundleUrl2Name(url); var a = new AssetBundleManifest(); for (var i = m_ActiveAssetDataGroup.Count - 1; i >= 0; --i) { string[] depends; if (!m_ActiveAssetDataGroup[i].GetAssetBundleDepends(abName, out depends)) { continue; } return(depends); } return(null); }
public override IEnumerator DoLoadAsync(System.Action finishCallback) { //开启的时候已经结束了 if (RefCount <= 0) { OnResLoadFaild(); finishCallback(); yield break; } #if UNITY_EDITOR if (SimulateAssetBundleInEditor) { yield return(null); } else #endif { var url = QFrameworkSettingData.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(); }
public static QFrameworkSettingData Load() { mConfigSavedDir.CreateDirIfNotExists(); if (!File.Exists(mConfigSavedDir + mConfigSavedFileName)) { using (var fileStream = File.Create(mConfigSavedDir + mConfigSavedFileName)) { fileStream.Close(); } } var frameworkConfigData = SerializeHelper.LoadJson <QFrameworkSettingData>(mConfigSavedDir + mConfigSavedFileName); if (frameworkConfigData == null || string.IsNullOrEmpty(frameworkConfigData.Namespace)) { frameworkConfigData = new QFrameworkSettingData(); frameworkConfigData.Namespace = "QFramework.Example"; } return(frameworkConfigData); }
private void CreateUIPanelCode(GameObject uiPrefab, string uiPrefabPath) { if (null == uiPrefab) { return; } var behaviourName = uiPrefab.name; var strFilePath = string.Empty; var prefabDirPattern = QFrameworkSettingData.Load().UIPrefabDir; if (uiPrefabPath.Contains(prefabDirPattern)) { strFilePath = uiPrefabPath.Replace(prefabDirPattern, GetScriptsPath()); } else if (uiPrefabPath.Contains("/Resources")) { strFilePath = uiPrefabPath.Replace("/Resources", GetScriptsPath()); } else { strFilePath = uiPrefabPath.Replace("/" + uiPrefabPath.GetLastDirName(), GetScriptsPath()); } strFilePath.Replace(uiPrefab.name + ".prefab", string.Empty).CreateDirIfNotExists(); strFilePath = strFilePath.Replace(".prefab", ".cs"); if (File.Exists(strFilePath) == false) { UIPanelCodeTemplate.Generate(strFilePath, behaviourName, GetProjectNamespace()); } CreateUIPanelComponentsCode(behaviourName, strFilePath); Debug.Log(">>>>>>>Success Create UIPrefab Code: " + behaviourName); }
private static string GetProjectNamespace() { return(QFrameworkSettingData.Load().Namespace); }
private static string GetScriptsPath() { return(QFrameworkSettingData.Load().UIScriptDir); }