예제 #1
0
        public IEnumerator ChatSystem() => UniTask.ToCoroutine(async() =>
        {
            await LoadEss();

            RoomReferences.I = new RoomReferences {
                Canvas = canvas
            };
            Controller.I   = new Mock <IController>().Object;
            RoomSettings.I = new RoomSettings(0, 0, null, 0);

            await global::ChatSystem.Create();
            var cs = global::ChatSystem.I;

            await UniTask.DelayFrame(1);

            cs.ShowMessage(1, "kofta");
            await UniTask.Delay(2000);

            cs.ShowMessage(2, "angle");
            await UniTask.Delay(2000);

            cs.ShowMessage(3, "angry");
            await UniTask.Delay(2000);

            cs.ShowMessage(1, "dizzy");
            await UniTask.Delay(2000);

            cs.ShowMessage(3, "kofta");
            await UniTask.Delay(2000);

            await UniTask.Delay(int.MaxValue);
        });
예제 #2
0
    private async UniTaskVoid Initialize()
    {
        Controller.I.AddRpcContainer(this);
        // Controller.I.OnAppPause += DestroyLobby;

        await UniTask.DelayFrame(1);

        var containerRoot = new GameObject("Lobby").transform;

        new LobbyReferences();

        LobbyReferences.I.Canvas = (await Addressables.InstantiateAsync("canvas", containerRoot))
                                   .GetComponent <Transform>();

        await FriendsView.Create();

        SoundButton.Create();

        await PersonalActiveUserView.Create();

        await RoomRequester.Create();

        await Shop.Create(LobbyReferences.I.Canvas, ItemType.Cardback);

        await Shop.Create(LobbyReferences.I.Canvas, ItemType.Background);

#if HMS
        IapShop.Create();
#endif

        Background.I.SetForLobby();
    }
    // Use this for initialization
    void Start()
    {
        IObservable <Unit> Event()
        {
            return(Enumerable
                   .Select(Enumerable.Range(0, 4), (i, msg) =>
                           Observable
                           .ReturnUnit()
                           .DelayFrame(60)
                           .Do((_) => Debug.Log($"ok{i}"))
                           ).Concat());
        }

        // Observable.Concat (Event (), Event ()).Subscribe ();
        async UniTask <Unit> Event2()
        {
            foreach (var i in Enumerable.Range(0, 4))
            {
                await UniTask.DelayFrame(60);

                Debug.Log($"ok{i}");
            }
            return(Unit.Default);
        }
    }
예제 #4
0
        public async UniTask Prompt(string value, float duration = 1f)
        {
            var NoticeTextBox = Instantiate(NoticeTextBoxPrefab, transform);

            NoticeTextBox.GetComponent <TextWrapController>().Text = value;
            var rect = NoticeTextBox.GetComponent <RectTransform>();

            // Hide component for now
            // Cannot unable gameobject because the gameobject needs to be active for the layout group to calculate
            rect.anchoredPosition = new Vector2(0, -1000);

            // Wait one frame to let layout
            await UniTask.DelayFrame(1);

            var rectHeight = rect.rect.height;

            rect.anchoredPosition = new Vector2(0, -(rectHeight + padding));

            foreach (var notice in notices)
            {
                notice.Value.targetYPos = notice.Value.targetYPos + padding + rectHeight;
            }

            duration += value.Length * 0.05f;

            notices[rect] = new NoticeStatus(
                0f,
                duration,
                rect.gameObject.GetComponent <CanvasGroup>());
        }
예제 #5
0
    public async void SetModel(Level level, ColorGradient gradient)
    {
        this.level = level;

        artist.text         = level.Meta.artist;
        title.text          = level.Meta.title;
        titleLocalized.text = level.Meta.title_localized;
        titleLocalized.gameObject.SetActive(!level.Meta.title_localized.IsNullOrEmptyTrimmed());

        difficultyBall.SetModel(Difficulty.Parse(level.Meta.charts.Last().type), level.Meta.charts.Last().difficulty);
        overlayGradient.SetGradient(gradient);

        transform.RebuildLayout();
        difficultyBall.gameObject.SetActive(false);
        difficultyBall.gameObject.SetActive(true);

        LoadCover();

        await UniTask.DelayFrame(0); // Unity :)

        if (gameObject != null)
        {
            transform.RebuildLayout();
        }
    }
예제 #6
0
    public async Task SearchForPlayers()
    {
        await UniTask.DelayFrame(5);

        this.targets = this.entitiesStorage.Value.Entities.Values.
                       Where(o => o.GetComponent <Lizard>() || o.GetComponent <Hedgehog>()).Select(o => o.transform).ToArray();
    }
예제 #7
0
    public async void OnScreenChangeStarted(Screen from, Screen to)
    {
        if (to is GamePreparationScreen || to is TierSelectionScreen)
        {
            FadeOutLoopPlayer();
            return;
        }
        if ((from is GamePreparationScreen || from is TierSelectionScreen) && to != null)
        {
            FadeInLoopPlayer();
            PlayAudio(MainLoopAudio);
            return;
        }
        if ((from == null || from is InitializationScreen) && to is MainMenuScreen)
        {
            PlayAudio(MainLoopAudio, 0);
            return;
        }
        if (to is ResultScreen || to is TierBreakScreen)
        {
            PlayAudio(resultLoopAudio, 0);
            await UniTask.DelayFrame(5); // Introloop bug: Audio not switched immediately, causing ear rape

            FadeInLoopPlayer(0);
        }
    }
예제 #8
0
        private static async UniTaskVoid waitXFramesThenAsync(int framesCount, Action action,
                                                              CancellationToken token = default)
        {
            await UniTask.DelayFrame(framesCount, cancellationToken : token);

            action.Invoke();
        }
예제 #9
0
    private async UniTask <int> _LoadSomeData(int min, int max)
    {
        var delay = Random.Range(1, 1000);
        await UniTask.DelayFrame(delay);

        return(Random.Range(min, max));
    }
예제 #10
0
        public async void Ship(ShipSignal signal)
        {
            _trackFactory.Create();
            await UniTask.DelayFrame(30);

            _signalBus.Fire(new SoundSignal(Sound.Ship));
        }
예제 #11
0
    public virtual async UniTask Show()
    {
        if (!shownStatus)
        {
            shownStatus = true;
            transform.SetAsLastSibling();

            if (UIAnimator != null && UIAnimator.Count > 0)
            {
                UIAnimator?.ForEach(x => x.SetTrigger(ANIMATOR_HASH_ON));
                await UniTask.DelayFrame(1);// wait one frame because sometimes animation state wont change until after frame ends

                await UniTask.WaitWhile(() =>
                {
                    bool isUIAnimating = false;
                    foreach (var uiAnim in UIAnimator)
                    {
                        var animState      = uiAnim.GetCurrentAnimatorStateInfo(ANIMATOR_LAYER_INDEX);
                        bool isNameCorrect = animState.IsName(ANIMATOR_STATE_NAME_ON);
                        if (isNameCorrect && animState.normalizedTime < 1.0f)
                        {
                            isUIAnimating = true;
                        }
                    }
                    return(isUIAnimating);
                });
            }
        }

        OnShown();


        await UniTask.CompletedTask;
    }
예제 #12
0
        public async UniTask WaitBootSceneReady()
        {
            var sceneCount = SceneManager.sceneCount;

            // 読み込み待ち.

            while (true)
            {
                var loadFinish = true;

                for (var i = 0; i < sceneCount; i++)
                {
                    var scene = SceneManager.GetSceneAt(i);

                    loadFinish &= scene.isLoaded;
                }

                if (loadFinish)
                {
                    break;
                }

                await UniTask.DelayFrame(1);
            }
        }
예제 #13
0
    async UniTask Initialize()
    {
        webCamDevices = WebCamTexture.devices;
        while (webCamDevices.Length < 1)
        {
            await UniTask.DelayFrame(1);
        }

        for (int i = 0; i < webCamDevices.Length; i++)
        {
            Debug.Log(string.Format("WebCam Devices {0} th is {1}", i, webCamDevices[i].name));
            if (webCamDevices[i].isFrontFacing)
            {
                // frontCamTexture = new WebCamTexture(webCamDevices[i].name, frontWidth, frontHeight, fps);
                frontIndex = i;
            }
            else
            {
                backCamTexture = new WebCamTexture(webCamDevices[i].name, backWidth, backHeight, fps);
                backIndex      = i;
            }
        }
        pngImage.texture = new  Texture2D(1920, 1080);
        backCamTexture.Play();
        // frontCamTexture.Play();
    }
예제 #14
0
        /*
         *      IEnumerator GetText() {
         *              Debug.Log("API実行");
         *              UnityWebRequest request = UnityWebRequest.Get("https://us-central1-oshiroquiz.cloudfunctions.net/hello");
         *              // リクエスト送信
         *              yield return request.Send();
         *
         *              // 通信エラーチェック
         *              if (request.isHttpError) {
         *                      Debug.Log("■API結果がエラー:"+request.error);
         *              } else {
         *                      if (request.responseCode == 200) {
         *                              // UTF8文字列として取得する
         *                              string text = request.downloadHandler.text;
         *                              Debug.Log("■API結果のtext:"+text);
         *                              testText.text = text;
         *
         *                              // バイナリデータとして取得する
         *                              byte[] results = request.downloadHandler.data;
         *                              foreach(byte a in results) {
         *                                      Debug.Log("■API結果のbyte:"+a);
         *                              }
         *                      }
         *              }
         *      }
         */

        // private void FirebaseInit()
        // {
        //  Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
        //      var dependencyStatus = task.Result;
        //      if (dependencyStatus == Firebase.DependencyStatus.Available) {
        //          // Create and hold a reference to your FirebaseApp,
        //          // where app is a Firebase.FirebaseApp property of your application class.
        //          //   app = Firebase.FirebaseApp.DefaultInstance;

        //          // Set a flag here to indicate whether Firebase is ready to use by your app.

        //          var oshiroRemoteConfig = OshiroRemoteConfig.Instance();

        //          oshiroRemoteConfig.RemoteConfigFetch();

        //      } else {
        //          UnityEngine.Debug.LogError(System.String.Format(
        //          "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
        //          // Firebase Unity SDK is not safe to use here.
        //      }
        //  });
        // }

        private async UniTask gameStart()
        {
            if (isGameStart)
            {
                return;
            }
            isGameStart = true;

            this.titleAnimator.SetTrigger("blinkEnd");

            SoundController.instance.TapToStart();

            await UniTask.Delay(650);

            var loadingColor = loadingText.color;

            loadingColor.a    = 255;
            loadingText.color = loadingColor;

            await UniTask.DelayFrame(1);


            // ゲームシーンロード
            SceneManager.LoadScene("GameScene");
        }
예제 #15
0
        protected virtual void OnPlayerConnected(SteamPlayer steamPlayer)
        {
            if (m_Users.Any(d => d.Player.SteamPlayer.Equals(steamPlayer)))
            {
                return;
            }

            var pending = m_PendingUsers.FirstOrDefault(d => d.SteamId == steamPlayer.playerID.steamID);

            if (pending != null)
            {
                FinishSession(pending);
            }

            var user = new UnturnedUser(this, m_UserDataStore, steamPlayer.player, pending);

            m_Users.Add(user);

            var connectedEvent = new UnturnedUserConnectedEvent(user);

            async UniTaskVoid EmitDelayedEvent(UnturnedUserConnectedEvent @event)
            {
                await UniTask.DelayFrame(1);

                await m_EventBus.EmitAsync(m_Runtime, this, @event);
            }

            EmitDelayedEvent(connectedEvent).Forget();
        }
예제 #16
0
    public static async void Fix(Transform transform, bool updateTransitionElementDefaultState = false, int count = 4)
    {
        var children = transform.GetComponentsInChildren <LayoutFixer>().ToList();

        for (var i = 1; i < count; i++)
        {
            if (transform == null)
            {
                return;
            }
            transform.RebuildLayout();
            foreach (var it in children)
            {
                if (it == null)
                {
                    continue;
                }
                it.transform.RebuildLayout();
            }
            await UniTask.DelayFrame(0);
        }
        if (updateTransitionElementDefaultState)
        {
            transform.GetComponent <TransitionElement>()?.UseCurrentStateAsDefault();
        }
    }
예제 #17
0
    /// <summary>
    /// 刷新底部栏高度
    /// </summary>
    /// <param name="type"></param>
    public async UniTask RefreshBottom(int type)
    {
        RectTransform tageRect = null;

        switch (type)
        {
        case 0:
            tageRect = _btnBoxRect;
            break;

        case 1:
            tageRect = _ImagBoxRect;
            break;

        case 2:
            Debug.Log("还原底部栏");
            break;
        }
        float height = 0;

        if (tageRect != null)
        {
            LayoutRebuilder.ForceRebuildLayoutImmediate(tageRect);
            Debug.Log("底部按钮内容栏高:" + tageRect.sizeDelta);
            await UniTask.DelayFrame(1);

            height = _controlStripRect.sizeDelta.y + tageRect.sizeDelta.y;
        }
        else
        {
            height = _controlStripRect.sizeDelta.y;
        }
        RefreshContentRectSize(height);
        await ChapterTool.ChangeUiSize(_bottomRect, new Vector2(_bottomRect.sizeDelta.x, height), 50f, 0.01f, null, () => { Debug.Log("尺寸更改完毕"); });
    }
예제 #18
0
    async UniTask <Texture2D> CopyTexture(WebCamTexture webCamTexture, bool isFront)
    {
        while (webCamTexture.height <= 16 && webCamTexture.width <= 16)
        {
            await UniTask.DelayFrame(1);
        }

        int height;
        int width;
        int rotate;

        if (isFront)
        {
            height = frontHeight;
            width  = frontWidth;
            rotate = frontRotate;
        }
        else
        {
            height = backHeight;
            width  = backWidth;
            rotate = backRotate;
        }
        Texture2D copyed = new Texture2D(width, height);

        _color32s = new Color32[width * height];
        webCamTexture.GetPixels32(_color32s);
        // _color32s = RotateColor32s(_color32s, width, height, rotate);
        copyed.SetPixels32(_color32s);
        copyed.Apply();
        Texture2D resTex2d = RotateTexture2D(copyed, rotate);

        return(resTex2d);
    }
예제 #19
0
 private async UniTask Wait(int frames)
 {
     if (frames > 0)
     {
         await UniTask.DelayFrame(frames, PlayerLoopTiming.FixedUpdate);
     }
 }
        /// <summary>
        /// 数フレームだけ無敵フラグを有効にする
        /// </summary>
        private async UniTaskVoid ChangeInvincibleAsync(CancellationToken token)
        {
            _isInvincible = true;
            await UniTask.DelayFrame(3, PlayerLoopTiming.Update, token);

            _isInvincible = false;
        }
        public async UniTask <UniRx.Unit> PlanUnitMovement(IUnit unit)
        {
            using (_inputLock.Lock()) {
                // Action Planning / Confirmation
                _logger.Log(LoggedFeature.Units, "Planning Action: SelectMoveDestination");
                var destinationResult = await _unitActionPlanner.PlanAction(unit, UnitAction.SelectMoveDestination);

                _logger.Log(LoggedFeature.Units, "Done Planning Action: SelectMoveDestination");
                if (destinationResult.resultType == UnitActionPlanResult.PlanResultType.Canceled)
                {
                    await UniTask.DelayFrame(5);

                    return(UniRx.Unit.Default);
                }

                _logger.Log(LoggedFeature.Units, "Planning Action: ChooseMovePath");
                var choosePathResult = await _unitActionPlanner.PlanAction(unit, UnitAction.ChooseMovePath);

                _logger.Log(LoggedFeature.Units, "Done Planning Action: ChooseMovePath");
                if (choosePathResult.resultType == UnitActionPlanResult.PlanResultType.Canceled)
                {
                    await UniTask.DelayFrame(5);

                    return(UniRx.Unit.Default);
                }

                _logger.Log(LoggedFeature.Units, "Planning Action: AnimateMovement");
                await _unitActionPlanner.PlanAction(unit, UnitAction.AnimateMovement);

                _logger.Log(LoggedFeature.Units, "Done Planning Action: AnimateMovement");

                return(UniRx.Unit.Default);
            }
        }
예제 #22
0
    protected override async void OnRendered()
    {
        base.OnRendered();

        toggleOfflineButton.GetComponentInChildren <Text>().text = Context.IsOnline() ? "OFFLINE_GO_OFFLINE".Get() : "OFFLINE_GO_ONLINE".Get();
        LayoutFixer.Fix(toggleOfflineButton.transform);
        profileTab.characterTransitionElement.Enter();
        profileTab.changeCharacterButton.gameObject.SetActive(LoadedPayload.IsPlayer);
        contentTabs.gameObject.SetActive(LoadedPayload.IsPlayer);
        topRightColumn.gameObject.SetActive(LoadedPayload.IsPlayer);
        // Always use local character if local player
        if (LoadedPayload.Profile.User.Uid == Context.Player.Id)
        {
            profileTab.characterDisplay.Load(CharacterAsset.GetTachieBundleId(Context.CharacterManager.SelectedCharacterId));
        }
        else if (LoadedPayload.Profile.Character != null)
        {
            profileTab.characterDisplay.Load(CharacterAsset.GetTachieBundleId(LoadedPayload.Profile.Character.AssetId));
        }
        contentTabs.Select(LoadedPayload.TabIndex);
        await UniTask.DelayFrame(2);

        if (LoadedPayload.ProfileScrollPosition > -1)
        {
            profileTab.scrollRect.verticalNormalizedPosition = LoadedPayload.ProfileScrollPosition;
        }
    }
예제 #23
0
        public IEnumerator ExceptionUnobserved2() => UniTask.ToCoroutine(async() =>
        {
            bool calledEx             = false;
            Action <Exception> action = exx =>
            {
                calledEx = true;
                exx.Message.Should().Be("MyException");
            };

            UniTaskScheduler.UnobservedTaskException += action;

            var ex = InException2();
            ex     = default(UniTask <int>);

            await UniTask.DelayFrame(3);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            await UniTask.DelayFrame(1);

            calledEx.Should().BeTrue();

            UniTaskScheduler.UnobservedTaskException -= action;
        });
예제 #24
0
    private async UniTask ChangePlace(Sprite newImage, string newName, bool isSEOn = false)
    {
        placeText.text = "";
        Color color = Color.white;

        color.a = 1;
        float time = 0;
        float th   = 0.5f;

        while (time < th)
        {
            time            += Time.deltaTime;
            color.a          = 1 - 1 * time / th;
            placeImage.color = color;
            await UniTask.DelayFrame(1);
        }
        placeText.text    = newName;
        placeImage.sprite = newImage;
        if (isSEOn)
        {
            sound.SetAndPlaySE(1); //ドア音オン
        }

        color.a = 0;
        time    = 0;
        while (time < th)
        {
            time            += Time.deltaTime;
            color.a          = 1 * time / th;
            placeImage.color = color;
            await UniTask.DelayFrame(1);
        }
        onViewChanged.OnNext(Unit.Default);
    }
예제 #25
0
        public IEnumerator SetupHost() => UniTask.ToCoroutine(async() =>
        {
            networkManagerGo = new GameObject();
            networkManagerGo.AddComponent <MockTransport>();
            sceneManager        = networkManagerGo.AddComponent <NetworkSceneManager>();
            serverObjectManager = networkManagerGo.AddComponent <ServerObjectManager>();
            clientObjectManager = networkManagerGo.AddComponent <ClientObjectManager>();
            manager             = networkManagerGo.AddComponent <NetworkManager>();
            manager.client      = networkManagerGo.GetComponent <NetworkClient>();
            manager.server      = networkManagerGo.GetComponent <NetworkServer>();
            server = manager.server;
            client = manager.client;
            sceneManager.client        = client;
            sceneManager.server        = server;
            serverObjectManager.server = server;
            serverObjectManager.networkSceneManager = sceneManager;
            clientObjectManager.client = client;
            clientObjectManager.networkSceneManager = sceneManager;

            ExtraSetup();

            // wait for all Start() methods to get invoked
            await UniTask.DelayFrame(1);

            await StartHost();

            playerGO  = new GameObject("playerGO", typeof(Rigidbody));
            identity  = playerGO.AddComponent <NetworkIdentity>();
            component = playerGO.AddComponent <T>();

            serverObjectManager.AddPlayerForConnection(server.LocalConnection, playerGO);

            client.Update();
        });
예제 #26
0
 public async Task PlayVideo(VideoClip videoClip, AudioClip audioClip, Action action)
 {
     if (isSelfValid)
     {
         if (videoClip == null)
         {
             CommonVideoPlayer.FinishJob(this);
             return;
         }
         videoAudio.clip  = audioClip;
         videoPlayer.clip = videoClip;
         videoPlayer.Prepare();
         while (!videoPlayer.isPrepared)
         {
             await UniTask.DelayFrame(1);
         }
         videoPlayer.Play();
         videoAudio.Play();
         TimerComponent timerComponent = ETModel.Game.Scene.GetComponent <ETModel.TimerComponent>();
         int            time_ms        = (int)((videoPlayer.length + 0.5d) * 1000);
         videoPlayer.loopPointReached += (player) => {
             CommonVideoPlayer.FinishJob(this);
             if (action != null)
             {
                 action();
             }
         };
         await UniTask.Delay(time_ms);
     }
 }
예제 #27
0
    private async Task LoadBundleAsync(string assetBundleName)
    {
        if (bundles.ContainsKey(assetBundleName))
        {
            Debug.Log($"已有Bundle {assetBundleName}");
            return;
        }

        if (loading)
        {
            Debug.Log($"读取 {assetBundleName} 等待 之前的 读取 {loadName}");
            while (loading)
            {
                await UniTask.DelayFrame(2);
            }
        }
        if (bundles.ContainsKey(assetBundleName))
        {
            Debug.Log($"重复读取{assetBundleName}");
            return;
        }
        var loadStartTime = Time.realtimeSinceStartup;

        loading  = true;
        loadName = assetBundleName;

        await RealLoadBundleAsync(assetBundleName);

        Debug.Log($"读取Bundle: {assetBundleName} 完成 耗费时间 {Time.realtimeSinceStartup - loadStartTime}");

        loading  = false;
        loadName = "";
    }
 public IEnumerator IAsyncInitializeNotifiable_NotifyAsyncが呼ばれる() => UniTask.ToCoroutine(async() =>
 {
     InstallBasicInterfaceBindings <IAsyncInitializeNotifiable>();
     await UniTask.DelayFrame(1);
     var mock = Container.Resolve <IAsyncInitializeNotifiable>();
     await mock.ReceivedWithAnyArgs(1).OnInitializeAsync();
 });
    /// <summary>
    /// 数フレームだけ無敵判定にする
    /// </summary>
    private async UniTaskVoid ChangeInvincibleAsync()
    {
        _isInvincible = true;
        await UniTask.DelayFrame(3, PlayerLoopTiming.Update);

        _isInvincible = false;
    }
예제 #30
0
    async UniTask Init()
    {
        webCamDevices = WebCamTexture.devices;
        while (webCamDevices.Length < 1)
        {
            await UniTask.DelayFrame(1);
        }
        for (int i = 0; i < webCamDevices.Length; i++)
        {
            if (webCamDevices[i].isFrontFacing)
            {
                Debug.Log("Front Facing Texture");
                webCamTexture = new WebCamTexture(webCamDevices[i].name);
                camIndex      = i;
                Debug.Log(webCamDevices[i].name);
                rawImage.texture = webCamTexture;
                DebugInformation(webCamTexture, webCamDevices[i]);
            }
            else
            {
                Debug.Log("Rear Facing Texture");
                DebugInformation(new WebCamTexture(webCamDevices[i].name), webCamDevices[i]);
            }
        }

        webCamTexture.Play();
    }