public GameObject ShowWindowWithFade(GameObject windowPrefab, float fadeTime, Action <GameObject> onShow = null, bool autoClose = false, float autoCloseTime = 2.0f, Action onCloseFinish = null) { var window = windowPrefab; UnityConsole.Log("Window active : " + window.gameObject.activeInHierarchy.ToString()); if (!window.gameObject.activeInHierarchy) { window = ShowWindow(windowPrefab); } var canvasGroup = window.GetComponent <CanvasGroup> (); if (canvasGroup == null) { return(window); } StartCoroutine(canvasGroup.FadeIn(fadeTime, () => { onShow.SafeAction(window); if (autoClose) { this.UpdateAsObservable() .First() .Delay(TimeSpan.FromMilliseconds(autoCloseTime * 1000f)) .TakeUntilDestroy(this) .Subscribe(_ => CloseWindowWithFade(window, fadeTime, onCloseFinish)); } })); return(window); }
// 生成制御GUI描画. private void DrawGenerateGUI() { var languageManager = LanguageManager.Instance; var languageInfo = languageManager.Current; EditorLayoutTools.Title("Asset"); GUILayout.Space(4f); // 生成制御. using (new DisableScope(languageInfo == null)) { if (GUILayout.Button("Generate")) { TextDataGenerator.Generate(contentType, languageInfo); UnityConsole.Info("TextData generate finish."); Repaint(); } } GUILayout.Space(4f); }
private void OnSucceeded(InvokeResponse response, NetworkingResultBase result) { var decoded = Encoding.ASCII.GetString(response.Payload.ToArray()); UnityConsole.Log("Lambda Succeeded.\n" + decoded); var innerError = JsonSerializer.Deserialize <InnerErrorResponse>(response.Payload); if (innerError.IsErrorState()) { UnityConsole.Log($"Error occured in Function {result.MethodName}."); UnityConsole.Log(innerError); result.OnServerError(); return; } if (result.Deserialize(decoded)) { UnityConsole.Log($"Function {result.MethodName} Succeeded."); result.IsSucceeded.Value = true; } else { result.OnFailed(response); } }
/// <summary> /// アイテムの購入. /// </summary> protected BuyFailureReason Purchase(string productId, string developerPayload = null) { var result = PurchaseInternal(productId, developerPayload); if (result == BuyFailureReason.None) { var product = StoreProducts.FirstOrDefault(x => x.definition.storeSpecificId == productId); if (product != null) { var builder = new StringBuilder(); builder.AppendLine("------- PurchaseProducts -------"); builder.AppendLine(GetProductString(product)).AppendLine(); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } } else { var message = string.Format("Purchase Error. ({0})", result); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message, LogType.Error); } return(result); }
/// <summary> /// ストア商品リストを更新. /// </summary> /// <param name="productDefinitions"></param> private void UpdatePurchasing(ProductDefinition[] productDefinitions) { Action successCallback = () => { StoreProducts = storeController.products.all .Where(x => !string.IsNullOrEmpty(x.metadata.localizedTitle)) .Where(x => !string.IsNullOrEmpty(x.metadata.localizedPriceString)) .Where(x => productDefinitions.Any(y => y.id == x.definition.id && y.storeSpecificId == x.definition.storeSpecificId)) .ToArray(); if (onStoreProductsUpdate != null) { onStoreProductsUpdate.OnNext(StoreProducts); } }; Action <InitializationFailureReason> failCallback = reason => { var message = string.Format("UpdatePurchasing Error.({0})", reason); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message, LogType.Error); }; storeController.FetchAdditionalProducts(productDefinitions.ToHashSet(), successCallback, failCallback); }
// エクセル制御GUI描画. private void DrawExcelControlGUI() { TextDataConfig.GenerateAssetSetting setting = null; switch (contentType) { case ContentType.Embedded: setting = config.Embedded; break; case ContentType.Distribution: setting = config.Distribution; break; } EditorLayoutTools.Title("Excel"); GUILayout.Space(4f); var excelFilePath = setting.GetExcelPath(); var excelFileExists = File.Exists(excelFilePath); using (new DisableScope(!excelFileExists)) { if (GUILayout.Button("Open")) { TextDataExcel.Open(setting); } } GUILayout.Space(4f); var isLock = TextDataExcel.IsExcelFileLocked(setting); using (new DisableScope(isLock)) { if (GUILayout.Button("Import")) { var nowait = TextDataExcel.Import(contentType, true); UnityConsole.Info("TextData import record finish."); } } GUILayout.Space(4f); using (new DisableScope(!excelFileExists)) { if (GUILayout.Button("Export")) { var nowait = TextDataExcel.Export(contentType, true); UnityConsole.Info("TextData export record finish."); } } GUILayout.Space(4f); }
public void ClearMasterVersion() { masters.ForEach(x => x.ClearVersion()); Reference.Clear(); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, "Clear MasterVersion"); }
void OnEnable() { UnityConsole.Clear(); Time.fixedDeltaTime = 0.5f; TaskRunner.Instance.RunOnSchedule(StandardSchedulers.physicScheduler, PrintTime()); }
/// <summary> /// IStoreListenerの初期化失敗通知. /// </summary> public void OnInitializeFailed(InitializationFailureReason error) { IsPurchaseReady = false; var message = string.Format("InitializeFailed. ({0})", error); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message); }
void OnEnable() { UnityConsole.Clear(); Time.fixedDeltaTime = 0.5f; PrintTime().RunOnScheduler(StandardSchedulers.physicScheduler); }
public BuildLogScope(StringBuilder logBuilder, System.Diagnostics.Stopwatch stopwatch, string processName) { this.logBuilder = logBuilder; this.stopwatch = stopwatch; this.processName = processName; UnityConsole.Event(ExternalResources.ConsoleEventName, ExternalResources.ConsoleEventColor, processName); }
private IEnumerator UpdateManifestInternal() { var sw = System.Diagnostics.Stopwatch.StartNew(); // アセット管理情報読み込み. var manifestAssetInfo = AssetInfoManifest.GetManifestAssetInfo(); var assetPath = PathUtility.Combine(resourceDirectory, manifestAssetInfo.ResourcePath); // AssetInfoManifestは常に最新に保たなくてはいけない為必ずダウンロードする. var loadYield = assetBundleManager.UpdateAssetInfoManifest() .SelectMany(_ => assetBundleManager.LoadAsset <AssetInfoManifest>(manifestAssetInfo, assetPath)) .ToYieldInstruction(false); while (!loadYield.IsDone) { yield return(null); } if (loadYield.HasError || loadYield.IsCanceled) { yield break; } SetAssetInfoManifest(loadYield.Result); sw.Stop(); if (LogEnable && UnityConsole.Enable) { var message = string.Format("UpdateManifest: ({0:F2}ms)", sw.Elapsed.TotalMilliseconds); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message); } // アセット管理情報を登録. assetBundleManager.SetManifest(assetInfoManifest); #if ENABLE_CRIWARE_ADX || ENABLE_CRIWARE_SOFDEC criAssetManager.SetManifest(assetInfoManifest); #endif // 不要になったファイル削除. var deleteCacheYield = DeleteDisUsedCache().ToYieldInstruction(false); while (!deleteCacheYield.IsDone) { yield return(null); } if (deleteCacheYield.HasError) { Debug.LogException(deleteCacheYield.Error); } }
private void CopyFile() { UnityConsole.Log("Create File :" + outputPath); if (File.Exists(outputPath)) { File.Delete(outputPath); } File.Copy(templatePath, outputPath); }
private SoundSheet GetSoundSheet(CueInfo cueInfo) { if (cueInfo == null) { return(null); } var assetPath = cueInfo.CueSheetPath; var soundSheet = managedSoundSheets.GetValueOrDefault(assetPath); if (soundSheet == null) { // パス情報生成. var acbPath = SoundSheet.AcbPath(assetPath); var awbPath = SoundSheet.AwbPath(assetPath); // ACBファイルのロード. CriAtomCueSheet cueSheet = null; try { cueSheet = CriAtom.AddCueSheet(assetPath, acbPath, awbPath); } catch (Exception ex) { Debug.LogException(ex); return(null); } if (cueSheet.acb == null) { return(null); } // ロードしたACBを保持した状態で再生成. soundSheet = new SoundSheet(assetPath, cueSheet.acb); managedSoundSheets.Add(soundSheet.AssetPath, soundSheet); var builder = new StringBuilder(); builder.AppendFormat("Load : {0} : {1}", cueInfo.Cue, cueInfo.CueId).AppendLine(); builder.AppendLine(); builder.AppendFormat("Cue : {0}", cueInfo.Cue).AppendLine(); builder.AppendFormat("CueId : {0}", cueInfo.CueId).AppendLine(); builder.AppendFormat("FileName : {0}", Path.GetFileName(acbPath)).AppendLine(); if (!string.IsNullOrEmpty(cueInfo.Summary)) { builder.AppendFormat("Summary: {0}", cueInfo.Summary).AppendLine(); } UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } return(soundSheet); }
/// <summary> /// IStoreListenerの初期化完了通知. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { storeController = controller; storeExtensionProvider = extensions; // 各ストアの拡張処理. if (storePurchasing != null) { storePurchasing.OnStoreListenerInitialized(controller, extensions); } // ストアに販売中のアイテムを更新. StoreProducts = controller.products.all; if (StoreProducts.Any()) { var builder = new StringBuilder(); builder.AppendLine("------- StoreProducts -------"); foreach (var item in StoreProducts) { builder.AppendLine(GetProductString(item)).AppendLine(); } UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } // Pending状態のアイテムを更新. foreach (var product in controller.products.all) { UpdatePendingProduct(product, PurchaseProcessingResult.Pending); } if (PendingProducts.Any()) { var builder = new StringBuilder(); builder.AppendLine("------- PendingProducts -------"); foreach (var item in PendingProducts) { builder.AppendLine(GetProductString(item)).AppendLine(); } UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } if (onStoreProductsUpdate != null) { onStoreProductsUpdate.OnNext(StoreProducts); } IsPurchaseReady = true; }
private void Generate(BehaviorControlSetting setting, Dictionary <string, ImportData> importData) { var success = true; var failedMessage = new StringBuilder(); if (importData.Any()) { failedMessage.AppendLine("Failed:"); Action <string> onErrorCallback = message => { using (new DisableStackTraceScope(LogType.Error)) { Debug.LogError(message); } }; var dataBuilder = new ImportDataConverter <TBehaviorData, TAction, TTarget, TCondition>(onErrorCallback); using (new AssetEditingScope()) { foreach (var item in importData) { var dataPath = item.Key; var assetPath = ConvertDataPathToAssetPath(setting, dataPath); var behaviorData = dataBuilder.Convert(dataPath, item.Value); if (behaviorData != null) { var lastUpdate = File.GetLastWriteTimeUtc(item.Key); var result = CreateBehaviorDataAsset(assetPath, behaviorData, lastUpdate); if (!result) { failedMessage.AppendFormat("- {0}", assetPath).AppendLine(); success = false; } } } } } if (success) { UnityConsole.Info("Generate asset complete."); } else { Debug.LogError(failedMessage.ToString()); } }
void CopyDatabase(TextAsset textAsset) { string databaseFilePath = DatabasePath.RemoveString("URI=file:"); File.Delete(databaseFilePath); using (FileStream fs = File.Create(databaseFilePath)) { fs.Write(textAsset.bytes, 0, textAsset.bytes.Length); } UnityConsole.Log("Resource DB Copied.\nPath : " + databaseFilePath); }
void OnEnable() { UnityConsole.Clear(); _runner = new StaggeredMonoRunner("StaggeredRunner", MaxTasksPerFrame); for (int i = 0; i < 300; i++) { TaskRunner.Instance.RunOnSchedule(_runner, PrintFrame); } }
public void TestProcessNextAction_NoAction() { LogAssert.Expect(LogType.Warning, "Unable to process. TurnManager has no remaining actions"); combatManager.ProcessNextAction(); mockTurnManager.Verify(turns => turns.GetNextAction(), Times.Never()); mockCharacterManager.Verify(manager => manager.ProcessAction(It.IsAny <CharacterAction>()), Times.Never()); UnityConsole.Clear(); }
void OnEnable() { UnityConsole.Clear(); _runner = new StaggeredMonoRunner("StaggeredRunner", MaxTasksPerFrame); for (int i = 0; i < 300; i++) { PrintFrame().Run(_runner); } }
public AlternativeDialog ShowAlternativeDialog(AlternativeDialogContents contents) { if (singleDialog == null) { UnityConsole.Log("[singleDialog] is empty!!"); return(null); } var dialog = ShowWindowWithFade(alternativeDialog.gameObject, contents.AnimationTime).GetComponent <AlternativeDialog>(); dialog.SetContents(contents); return(dialog); }
/// <summary> /// IStoreListenerアプリ内課金の失敗の通知. /// </summary> public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason) { IsPurchaseing = false; if (onStorePurchaseComplete != null) { onStorePurchaseComplete.OnNext(new PurchaseResult(product, failureReason)); } var message = string.Format("PurchaseFailed. ({0})\n{1}", failureReason, GetProductString(product)); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message, LogType.Error); }
/// <summary> /// 通信の影響で購入失敗したアイテムや、再インストール時に(非消費型/サブスクリプション型)アイテムを復元. /// </summary> public BuyFailureReason Restore() { var result = RestoreInternal(); if (result != BuyFailureReason.None) { var message = string.Format("Restore Error. ({0})", result); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message); } return(result); }
/// <summary> /// Pending状態のアイテムを更新. /// </summary> private void UpdatePendingProduct(Product product, PurchaseProcessingResult result) { // レシートを持っていない. if (!product.hasReceipt) { return; } if (string.IsNullOrEmpty(product.transactionID)) { return; } var pendingProducts = new List <Product>(PendingProducts); // Pendingの場合は最新のものに更新. if (result == PurchaseProcessingResult.Pending) { var pendingProduct = pendingProducts.FirstOrDefault(x => x.transactionID == product.transactionID); if (pendingProduct != null) { pendingProducts.Remove(pendingProduct); } pendingProducts.Add(product); } else if (result == PurchaseProcessingResult.Complete) { // 完了した場合は削除. var pendingProduct = pendingProducts.FirstOrDefault(x => x.transactionID == product.transactionID); if (pendingProduct != null) { pendingProducts.Remove(pendingProduct); } storeController.ConfirmPendingPurchase(product); var builder = new StringBuilder(); builder.AppendLine("------- ConfirmPendingProducts -------"); builder.AppendLine(GetProductString(product)).AppendLine(); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } PendingProducts = pendingProducts.ToArray(); }
private IEnumerator AppendCore(IObserver <SceneInstance> observer, Scenes?identifier, bool activeOnLoad) { if (!identifier.HasValue) { yield break; } SceneInstance sceneInstance = null; var diagnostics = new TimeDiagnostics(); diagnostics.Begin(TimeDiagnostics.Measure.Append); var loadYield = LoadScene(identifier.Value, LoadSceneMode.Additive).ToYieldInstruction(false); while (!loadYield.IsDone) { yield return(null); } if (loadYield.HasError) { OnLoadError(loadYield.Error, identifier); } if (loadYield.HasResult) { sceneInstance = loadYield.Result; appendSceneInstances.Add(sceneInstance); diagnostics.Finish(TimeDiagnostics.Measure.Append); var additiveTime = diagnostics.GetTime(TimeDiagnostics.Measure.Append); var message = string.Format("{0} ({1:F2}ms)(Additive)", identifier.Value, additiveTime); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message); if (activeOnLoad) { sceneInstance.Enable(); } } observer.OnNext(sceneInstance); observer.OnCompleted(); }
private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { var components = MainCanvasManager.Instance.GetComponentsInChildren <INeedPrepare>(); UnityConsole.Log($"PrepareTargets : {components.Length}"); if (components.Length == 0) { ShowPage(); return; } this.UpdateAsObservable().Select(_ => components.All(x => x.IsPrepared)) .DistinctUntilChanged() .Where(x => x) .Take(1) .Subscribe(_ => ShowPage()); }
private IEnumerator GetMovieInfoInternal(IObserver <ManaInfo> observer, string resourcePath) { if (string.IsNullOrEmpty(resourcePath)) { observer.OnError(new ArgumentException("resourcePath")); } else { var filePath = ConvertCriFilePath(resourcePath); if (!localMode) { if (!CheckAssetVersion(resourcePath, filePath)) { var assetInfo = GetAssetInfo(resourcePath); var assetPath = PathUtility.Combine(resourceDir, resourcePath); var sw = System.Diagnostics.Stopwatch.StartNew(); var updateYield = UpdateAsset(resourcePath).ToYieldInstruction(false, yieldCancel.Token); while (!updateYield.IsDone) { yield return(null); } sw.Stop(); var builder = new StringBuilder(); builder.AppendFormat("Update: {0} ({1:F2}ms)", Path.GetFileName(filePath), sw.Elapsed.TotalMilliseconds).AppendLine(); builder.AppendLine(); builder.AppendFormat("LoadPath = {0}", assetPath).AppendLine(); builder.AppendFormat("FileName = {0}", assetInfo.FileName).AppendLine(); builder.AppendFormat("Hash = {0}", assetInfo.FileHash).AppendLine(); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } } filePath = PathUtility.GetPathWithoutExtension(filePath) + CriAssetDefinition.UsmExtension; observer.OnNext(File.Exists(filePath) ? new ManaInfo(filePath) : null); } observer.OnCompleted(); }
private void OnComplete(Texture2D texture, double totalMilliseconds) { if (Debug.isDebugBuild) { var builder = new StringBuilder(); builder.AppendFormat("URL: {0} ({1:F1}ms)", currentRequest.url, totalMilliseconds).AppendLine(); builder.AppendLine(); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, builder.ToString()); } if (onComplete != null) { onComplete.OnNext(texture); } }
private void ReleaseSoundSheet() { for (var i = 0; i < soundElements.Count; ++i) { if (!soundElements[i].FinishTime.HasValue) { continue; } // 終了確認した時間から一定時間経過していたら解放. if (soundElements[i].FinishTime.Value + releaseTime < Time.realtimeSinceStartup) { soundElements.RemoveAt(i); } } var targets = new List <SoundSheet>(); foreach (var item in managedSoundSheets) { var release = true; // 再生中のCueが存在したら生存. foreach (var soundElement in soundElements) { if (item.Key == soundElement.SoundSheet.AssetPath) { release = false; break; } } if (release) { targets.Add(item.Value); } } foreach (var target in targets) { CriAtom.RemoveCueSheet(target.AssetPath); managedSoundSheets.Remove(target.AssetPath); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, "UnLoad : {0}", SoundSheet.AcbPath(target.AssetPath)); } }
private IObservable <Unit> PreLoadScene(Scenes[] targetScenes) { if (targetScenes.IsEmpty()) { return(Observable.ReturnUnit()); } var builder = new StringBuilder(); var observers = new List <IObservable <Unit> >(); foreach (var scene in targetScenes) { // キャッシュ済みのシーンがある場合はプリロードしない. if (cacheScenes.Any(x => x.Identifier == scene)) { continue; } var observer = Observable.Defer(() => Observable.FromMicroCoroutine(() => PreLoadCore(scene, builder))); observers.Add(observer); } if (observers.IsEmpty()) { return(Observable.ReturnUnit()); } var sw = System.Diagnostics.Stopwatch.StartNew(); return(observers.WhenAll() .Do(_ => { sw.Stop(); var time = sw.Elapsed.TotalMilliseconds; var detail = builder.ToString(); var message = string.Format("PreLoad Complete ({0:F2}ms)\n\n{1}", time, detail); UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message); }) .AsUnitObservable()); }