예제 #1
0
        private IEnumerator PlayInternal()
        {
            UnityUtility.SetActive(gameObject, true);

            ApplySortingOrder(sortingOrder);

            while (true)
            {
                if (!UnityUtility.IsActiveInHierarchy(gameObject))
                {
                    break;
                }

                // 状態リセット.
                ResetContents();

                // 開始.
                SetState(State.Play);

                for (var i = 0; i < particleInfos.Length; i++)
                {
                    var particleInfo = particleInfos[i];

                    // 止まってたら開始.
                    if (!particleInfo.ParticleSystem.isPlaying)
                    {
                        particleInfo.ParticleSystem.Play();
                    }

                    particleInfo.LifeCycle = LifecycleType.None;
                }

                // 再生速度.
                ApplySpeedRate();

                // 終了待ち.
                var updateYield = Observable.FromMicroCoroutine(() => FrameUpdate()).ToYieldInstruction();

                while (!updateYield.IsDone)
                {
                    yield return(null);
                }

                if (endActionType != EndActionType.Loop)
                {
                    break;
                }

                if (State == State.Stop)
                {
                    break;
                }
            }


            if (!UnityUtility.IsNull(this))
            {
                EndAction();
            }
        }
예제 #2
0
        private DynValue CommandFunction(float time = 0.4f, string colorCode = "#000000", string easingType = null)
        {
            try
            {
                var advEngine = AdvEngine.Instance;

                UnityUtility.SetActive(FadeImage, true);

                var color = colorCode.HexToColor();

                color.a = 0f;

                TweenCallback onComplete = () =>
                {
                    advEngine.Resume();
                };

                FadeImage.color = color;

                var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                var tweener = FadeImage.DOFade(1f, time)
                              .SetEase(ease)
                              .OnComplete(onComplete);

                advEngine.SetTweenTimeScale(tweener);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(YieldWait);
        }
예제 #3
0
        public void Update()
        {
            if (UnityUtility.IsNull(movieController))
            {
                return;
            }

            var prevStatus = Status;

            Status = Player.status;

            PlayTime  = GetPlayTime();
            TotalTime = GetTotalTime();

            if (prevStatus != Status && Status == Player.Status.PlayEnd)
            {
                UnityUtility.SetActive(movieController.gameObject, false);

                UnityUtility.DeleteComponent(movieController);

                if (onFinish != null)
                {
                    onFinish.OnNext(Unit.Default);
                }
            }
        }
예제 #4
0
        //----- method -----

        void OnEnable()
        {
            if (!language.Equals(CurrentLanguage))
            {
                UnityUtility.SetActive(gameObject, false);
            }
        }
예제 #5
0
        private void CommandFunction(string fileIdentifier)
        {
            try
            {
                var advEngine = AdvEngine.Instance;

                var fileName = string.Empty;

                if (!string.IsNullOrEmpty(fileIdentifier))
                {
                    fileName = advEngine.Resource.FindFileName <AdvBackground>(fileIdentifier);
                }

                var advBackground = advEngine.ObjectManager.Get <AdvBackground>(AdvBackground.UniqueIdentifier);

                if (advBackground != null)
                {
                    advBackground.Set(fileName);
                }

                UnityUtility.SetActive(advBackground, !string.IsNullOrEmpty(fileName));
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
예제 #6
0
        private void EndAction()
        {
            Stop();

            switch (endActionType)
            {
            case EndActionType.Deactivate:
                if (Application.isPlaying)
                {
                    UnityUtility.SetActive(gameObject, false);
                }
                break;

            case EndActionType.Destroy:
                if (Application.isPlaying)
                {
                    UnityUtility.SafeDelete(gameObject);
                }
                break;

            case EndActionType.Loop:
                break;
            }

            playObservable = null;

            if (onEnd != null)
            {
                onEnd.OnNext(this);
            }
        }
예제 #7
0
        public void Set(string fileName)
        {
            var advEngine = AdvEngine.Instance;

            if (string.IsNullOrEmpty(fileName))
            {
                image.sprite = null;
                return;
            }

            var resourcePath = advEngine.Resource.GetResourcePath <AdvBackground>(fileName);

            if (string.IsNullOrEmpty(resourcePath))
            {
                return;
            }

            image.sprite = advEngine.Resource.Get <Sprite>(resourcePath);

            var rectTransform = gameObject.transform as RectTransform;

            rectTransform.FillRect();

            UnityUtility.SetActive(gameObject, true);
        }
예제 #8
0
        private void EndAction()
        {
            switch (endActionType)
            {
            case EndActionType.None:
                currentState = State.Stop;
                break;

            case EndActionType.Deactivate:
                if (Application.isPlaying)
                {
                    UnityUtility.SetActive(gameObject, false);
                }

                currentState = State.Stop;
                break;

            case EndActionType.Destroy:
                if (Application.isPlaying)
                {
                    UnityUtility.SafeDelete(gameObject);
                }

                currentState = State.Stop;
                break;

            case EndActionType.Loop:
                break;
            }

            if (onEndAnimation != null)
            {
                onEndAnimation.OnNext(this);
            }
        }
예제 #9
0
        private void UpdateItem(VirtualScrollItem <T> item, int index)
        {
            switch (scrollType)
            {
            case ScrollType.Limited:
            {
                var enable = Contents != null && 0 <= index && index < Contents.Length;

                item.UpdateItem(index, Contents);
                UnityUtility.SetActive(item.gameObject, enable);
            }
            break;

            case ScrollType.Loop:
            {
                if (index < 0)
                {
                    index = Contents.Length - 1;
                }

                if (Contents.Length <= index)
                {
                    index = 0;
                }

                item.UpdateItem(index, Contents);
                UnityUtility.SetActive(item.gameObject, true);
            }
            break;
            }

            item.transform.name = index.ToString();
        }
예제 #10
0
        public IObservable <Unit> Play(string animationName)
        {
            if (string.IsNullOrEmpty(animationName))
            {
                return(Observable.ReturnUnit());
            }

            UnityUtility.SetActive(gameObject, true);

            // ヒエラルキー上で非アクティブでないか.
            if (!UnityUtility.IsActiveInHierarchy(gameObject))
            {
                Debug.LogErrorFormat("Animation can't play not active in hierarchy.\n{0}", gameObject.transform.name);
                return(Observable.ReturnUnit());
            }

            this.animationName = animationName;

            var hash = Animator.StringToHash(animationName);

            if (animatorInfo.Animator.HasState(0, hash))
            {
                return(Observable.FromCoroutine(() => PlayInternal()));
            }

            this.animationName = string.Empty;

            Debug.LogErrorFormat("Animation State Not found. {0}", animationName);

            return(Observable.ReturnUnit());
        }
예제 #11
0
        /// <summary>
        /// ExternalResources内や、直接指定での動画再生用のインスタンスを生成.
        /// ※ 頭出しなどを行う時はこの関数で生成したPlayerを使って頭出しを実装する.
        /// </summary>
        public static MovieElement CreateElement(string moviePath, Graphic targetGraphic, Player.ShaderDispatchCallback shaderOverrideCallBack = null)
        {
            if (!File.Exists(moviePath))
            {
                throw new FileNotFoundException(moviePath);
            }

            var movieController = UnityUtility.GetOrAddComponent <CriManaMovieControllerForUI>(targetGraphic.gameObject);

            movieController.target  = targetGraphic;
            movieController.enabled = true;

            UnityUtility.SetActive(movieController.gameObject, true);

            var moviePlayer = movieController.player;

            moviePlayer.SetFile(null, moviePath);

            if (shaderOverrideCallBack != null)
            {
                moviePlayer.SetShaderDispatchCallback(shaderOverrideCallBack);
            }

            var movieElement = new MovieElement(moviePlayer, movieController, moviePath);

            Instance.movieElements.Add(movieElement);

            return(movieElement);
        }
예제 #12
0
        private IEnumerator InitializeItem(VirtualScrollItem <T> item)
        {
            UnityUtility.SetActive(item, true);

            OnCreateItem(item);

            if (onCreateItem != null)
            {
                onCreateItem.OnNext(item);
            }

            // 初期化.
            var initializeYield = item.Initialize().ToObservable().ToYieldInstruction(false);

            while (!initializeYield.IsDone)
            {
                yield return(null);
            }

            if (initializeYield.HasError)
            {
                Debug.LogException(initializeYield.Error);
            }

            UnityUtility.SetActive(item, false);
        }
예제 #13
0
        public IObservable <Unit> Close(bool inputProtect = true)
        {
            var protect = inputProtect ? new InputProtect() : null;

            return(OnClose()
                   .Do(_ =>
            {
                UnityUtility.SetActive(gameObject, false);

                if (protect != null)
                {
                    protect.Dispose();
                    protect = null;
                }

                if (onClose != null)
                {
                    onClose.OnNext(Unit.Default);
                }

                if (deleteOnClose)
                {
                    UnityUtility.SafeDelete(gameObject);
                }
            })
                   .AsUnitObservable());
        }
예제 #14
0
        private DynValue CommandFunction(string identifier, float duration = 0, string easingType = null, bool wait = true)
        {
            var returnValue = DynValue.Nil;

            try
            {
                var advEngine = AdvEngine.Instance;

                var advObject = advEngine.ObjectManager.Get <AdvObject>(identifier);

                if (advObject == null)
                {
                    return(DynValue.Nil);
                }

                var canvasGroup = UnityUtility.GetComponent <CanvasGroup>(advObject);

                if (canvasGroup != null)
                {
                    if (duration != 0)
                    {
                        TweenCallback onComplete = () =>
                        {
                            UnityUtility.SetActive(advObject, false);

                            if (wait)
                            {
                                advEngine.Resume();
                            }
                        };

                        var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                        var tweener = canvasGroup.DOFade(0f, duration)
                                      .SetEase(ease)
                                      .OnComplete(onComplete);

                        advEngine.SetTweenTimeScale(tweener);

                        returnValue = wait ? YieldWait : DynValue.Nil;
                    }
                    else
                    {
                        canvasGroup.alpha = 0f;

                        UnityUtility.SetActive(advObject, false);
                    }
                }
                else
                {
                    UnityUtility.SetActive(advObject, false);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(returnValue);
        }
예제 #15
0
        protected override void ChangeResourceOnDrawSub(AdvGraphicInfo grapic)
        {
            var settingData = grapic.File.SettingData;

            if (settingData != null)
            {
                if (instance == null)
                {
                    instance = currentObject;

                    animationController = UnityUtility.GetComponent <AnimationPlayer>(currentObject);
                }

                var animationName = settingData.RowData.ParseCellOptional <string>(ANIMATION_ROW_NAME, null);

                var enable = !string.IsNullOrEmpty(animationName);

                UnityUtility.SetActive(gameObject, enable);

                if (enable)
                {
                    animationController.Play(animationName).Subscribe().AddTo(this);
                }
            }
            else
            {
                UnityUtility.SetActive(gameObject, false);
            }
        }
예제 #16
0
        public void Initialize()
        {
            if (!initialized && IsEnable())
            {
                // 一旦アクティブにならないとログ収集しないので一瞬アクティブ化.
                SRDebug.Instance.ShowDebugPanel();
                SRDebug.Instance.HideDebugPanel();

                UnityUtility.SetActive(blockCollider, SRDebug.Instance.IsDebugPanelVisible);

                SRDebug.Instance.PanelVisibilityChanged += x => { UnityUtility.SetActive(blockCollider, x); };

                button.OnClickAsObservable()
                .Subscribe(_ => OnClick())
                .AddTo(this);

                ApplicationLogHandler.Instance.OnLogReceiveAsObservable()
                .Subscribe(x => OnLogReceive(x))
                .AddTo(this);

                SRTrackLogService.Initialize();

                UnityUtility.SetActive(blockCollider, false);

                background.color = defaultColor;

                initialized = true;
            }
        }
예제 #17
0
        //----- property -----

        //----- method -----

        public void Show(string fileName, float?width, float?height)
        {
            var advEngine = AdvEngine.Instance;

            var resourcePath = advEngine.Resource.GetResourcePath <AdvSprite>(fileName);

            var sprite = advEngine.Resource.Get <Sprite>(resourcePath);

            var rt = transform as RectTransform;

            if (rt != null)
            {
                var size = new Vector2()
                {
                    x = width.HasValue ? width.Value : sprite.rect.width,
                    y = height.HasValue ? height.Value : sprite.rect.height,
                };

                rt.SetSize(size);
            }

            image.sprite = sprite;

            UnityUtility.SetActive(gameObject, true);
        }
예제 #18
0
        public void SetTouchBlock(GameObject touchBlock)
        {
            this.touchBlock = touchBlock;

            var srDebug = SRDebug.Instance;

            UnityUtility.SetActive(touchBlock, srDebug.IsDebugPanelVisible);
        }
예제 #19
0
        private void CommandFunction(bool show, string colorCode = "#000000FF")
        {
            var color = colorCode.HexToColor();

            FadeImage.color = color;

            UnityUtility.SetActive(FadeImage, show);
        }
예제 #20
0
        public void SetAlpha(float value)
        {
            fadeAlpha         = Mathf.Clamp(value, 0f, 1f);
            canvasGroup.alpha = fadeAlpha;

            Active = 0 < fadeAlpha;

            UnityUtility.SetActive(canvasGroup.gameObject, Active);
        }
예제 #21
0
        internal override void OnEffectColorsChange(AdvEffectColor color)
        {
            if (prevAlpha == 1f && color.MulColor.a < prevAlpha)
            {
                UnityUtility.SetActive(instance, false);
            }

            prevAlpha = color.MulColor.a;
        }
예제 #22
0
        //----- property -----

        //----- method -----

        public void Initialize()
        {
            UnityUtility.SetActive(touchBlockObject, false);

            fpsStats.Initialize();

            #if ENABLE_SRDEBUGGER
            srDiagnosis.Initialize();
            #endif
        }
예제 #23
0
        private void CommandFunction(string identifier, bool state)
        {
            var advEngine = AdvEngine.Instance;

            var advObject = advEngine.ObjectManager.Get <AdvObject>(identifier);

            if (advObject != null)
            {
                UnityUtility.SetActive(advObject, state);
            }
        }
예제 #24
0
        public bool Enable()
        {
            if (!scene.HasValue)
            {
                return(false);
            }

            if (enable)
            {
                return(true);
            }

            if (activeRoots == null)
            {
                return(true);
            }

            if (!scene.Value.isLoaded || !scene.Value.IsValid())
            {
                return(false);
            }

            var rootObjects = scene.Value.GetRootGameObjects();

            foreach (var rootObject in activeRoots)
            {
                if (UnityUtility.IsNull(rootObject))
                {
                    continue;
                }

                if (!rootObjects.Contains(rootObject))
                {
                    continue;
                }

                var ignoreControl = UnityUtility.GetComponent <IgnoreControl>(rootObject);

                if (ignoreControl != null)
                {
                    if (ignoreControl.Type.HasFlag(IgnoreControl.IgnoreType.ActiveControl))
                    {
                        continue;
                    }
                }

                UnityUtility.SetActive(rootObject, true);
            }

            enable = true;

            return(true);
        }
예제 #25
0
        public void Show(string patternName)
        {
            var advEngine = AdvEngine.Instance;

            patternImage.PatternTexture = advEngine.Resource.Get <PatternTexture.PatternTexture>(resourcePath);

            patternImage.PatternName = patternName;

            patternImage.SetNativeSize();

            UnityUtility.SetActive(gameObject, true);
        }
예제 #26
0
        //----- method -----

        /// <summary> 初期化. </summary>
        public virtual void Initialize()
        {
            if (initialized)
            {
                return;
            }

            aesManaged = CreateAesManaged();
            reportForm = new List <IMultipartFormSection>();

            var srDebug = SRDebug.Instance;

            VisibilityChangedDelegate onPanelVisibilityChanged = visible =>
            {
                if (visible && gameObject.activeInHierarchy)
                {
                    UpdateContents();
                }
            };

            srDebug.PanelVisibilityChanged += onPanelVisibilityChanged;

            UpdateView();

            sendReportButton.OnClickAsObservable()
            .Subscribe(_ =>
            {
                if (sendReportDisposable != null)
                {
                    PostCancel();
                }
                else
                {
                    sendReportDisposable = Observable.FromCoroutine(() => PostReport())
                                           .Subscribe(__ =>
                    {
                        sendReportDisposable = null;
                    })
                                           .AddTo(this);
                }
            })
            .AddTo(this);

            titleInputField.ObserveEveryValueChanged(x => x.text)
            .Subscribe(x => UnityUtility.SetActive(sendReportButton, !string.IsNullOrEmpty(x)))
            .AddTo(this);

            titleInputField.text   = string.Empty;
            commentInputField.text = string.Empty;

            initialized = true;
        }
        private void UpdateView()
        {
            var status = sendReportDisposable == null;

            sendReportButtonText.text = status ? "Send Report" : "Cancel";
            UnityUtility.SetActive(progressBar, !status);

            // 送信中.
            if (status)
            {
                UpdatePostProgress(0f);
            }
        }
예제 #28
0
        void OnEnable()
        {
            UpdateView();

            Observable.NextFrame()
            .TakeUntilDisable(this)
            .Subscribe(_ => OnRequestRefreshInputText())
            .AddTo(this);

            Observable.EveryUpdate()
            .TakeUntilDisable(this)
            .Subscribe(_ => UnityUtility.SetActive(sendReportButton, IsSendReportButtonEnable()))
            .AddTo(this);
        }
예제 #29
0
        private void CommandFunction(bool show, string colorCode = "#000000FF")
        {
            try
            {
                var color = colorCode.HexToColor();

                FadeImage.color = color;

                UnityUtility.SetActive(FadeImage, show);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
예제 #30
0
        private void OnFocuseChanged(bool isFocused)
        {
            // フォーカスされた時に既存の文字が全選択されるのを解除する.
            if (isFocused)
            {
                inputField.MoveTextEnd(true);
            }

            #if UNITY_EDITOR
            UnityUtility.SetActive(inputFieldText, !isFocused);
            UnityUtility.SetActive(inputField.textComponent, isFocused);

            inputFieldText.text = inputField.text;
            #endif
        }