Ejemplo n.º 1
0
        private void SetDragEffect(Vector3 screenPosition)
        {
            if (dragEffectPrefab == null)
            {
                return;
            }

            ParticlePlayer particleController = null;

            if (cachedDragEffects.Count != 0)
            {
                particleController = cachedDragEffects.Dequeue();
            }
            else
            {
                particleController = UnityUtility.Instantiate <ParticlePlayer>(dragEffectRoot, dragEffectPrefab);

                UnityUtility.SetLayer(TargetLayer, particleController.gameObject, true);

                // キャッシュ目的なのでDeactiveを指定.
                particleController.EndActionType = EndActionType.Deactivate;

                particleController.OnEndAsObservable().Subscribe(x => cachedDragEffects.Enqueue(x)).AddTo(this);
            }

            SetTouchEffectPosition(particleController, screenPosition);

            particleController.Play().Subscribe().AddTo(this);
        }
Ejemplo n.º 2
0
        private void RegisterGlobal(Window popupWindow)
        {
            // 新規登録された場合.
            if (globalPopups.All(x => x != popupWindow))
            {
                UnityUtility.SetLayer(gameObject, popupWindow.gameObject, true);
                UnityUtility.SetParent(popupWindow.gameObject, parentGlobal.Parent);

                popupWindow.OnCloseAsObservable()
                .Subscribe(
                    _ =>
                {
                    globalPopups.Remove(popupWindow);
                    UpdateContents();
                })
                .AddTo(this);

                globalPopups.Add(popupWindow);
            }
            else
            {
                // 既に登録済みの場合は最後尾に再登録.
                globalPopups.Remove(popupWindow);
                globalPopups.Add(popupWindow);
            }

            globalPopups = globalPopups.OrderBy(x => x.DisplayPriority).ToList();
        }
Ejemplo n.º 3
0
        private void SetDragEffect(Vector3 screenPosition)
        {
            if (dragEffectPrefab == null)
            {
                return;
            }

            ParticlePlayer particleController = null;

            if (cachedDragEffects.Count != 0)
            {
                particleController = cachedDragEffects.Dequeue();
            }
            else
            {
                particleController = UnityUtility.Instantiate <ParticlePlayer>(dragEffectRoot, dragEffectPrefab);

                UnityUtility.SetLayer((int)Layer.Overlap, particleController.gameObject, true);

                // キャッシュ目的なのでDeactiveを指定.
                particleController.EndActionType = EndActionType.Deactivate;

                particleController.OnEndAsObservable().Subscribe(x => cachedDragEffects.Enqueue(x)).AddTo(this);
            }

            var originPosition = renderCamera.ScreenToWorldPoint(screenPosition);

            particleController.transform.position = new Vector3(originPosition.x, originPosition.y);

            particleController.Play().Subscribe().AddTo(this);
        }
Ejemplo n.º 4
0
        private void RegisterScene(Window popupWindow)
        {
            // 新規登録された場合.
            if (scenePopups.All(x => x != popupWindow))
            {
                UnityUtility.SetLayer(gameObject, popupWindow.gameObject, true);
                UnityUtility.SetParent(popupWindow.gameObject, parentInScene.Parent);

                popupWindow.OnCloseAsObservable()
                .Subscribe(
                    _ =>
                {
                    scenePopups.Remove(popupWindow);
                    UpdateContents();
                })
                .AddTo(this);

                scenePopups.Add(popupWindow);
            }
            else
            {
                // 既に登録済みの場合は最後尾に再登録.
                scenePopups.Remove(popupWindow);
                scenePopups.Add(popupWindow);
            }
        }
        //----- method -----

        protected override void Start()
        {
            base.Start();

            sendReportSheet = UnityUtility.Instantiate <SendReportSheetController>(container, sendReportSheetPrefab, false);
            UnityUtility.SetLayer(gameObject, sendReportSheet.gameObject, true);

            sendReportSheet.Initialize();
        }
Ejemplo n.º 6
0
        private PopupParent CreatePopupParent(string instanceName, GameObject parent, int layer, int canvasOrder)
        {
            var popupParent = UnityUtility.Instantiate <PopupParent>(parent, parentPrefab);

            popupParent.transform.name      = instanceName;
            popupParent.Canvas.sortingOrder = canvasOrder;

            UnityUtility.SetLayer(layer, popupParent.gameObject, true);

            popupParent.Canvas.worldCamera = UnityUtility.FindCameraForLayer(1 << layer).FirstOrDefault();

            return(popupParent);
        }
Ejemplo n.º 7
0
        public void Clean()
        {
            foreach (var scenePopup in scenePopups)
            {
                UnityUtility.DeleteGameObject(scenePopup);
            }

            scenePopups.Clear();

            UnityUtility.SetParent(touchBloc.gameObject, parentGlobal.Parent);
            UnityUtility.SetLayer(parentGlobal.Parent, touchBloc.gameObject, true);

            if (globalPopups.IsEmpty())
            {
                if (touchBlocDisposable != null)
                {
                    touchBlocDisposable.Dispose();
                    touchBlocDisposable = null;
                }

                touchBloc.Hide();
                touchBloc.transform.SetSiblingIndex(0);
            }
        }
Ejemplo n.º 8
0
        protected void UpdateContents()
        {
            var        touchBlocIndex = 0;
            GameObject parent         = null;

            CreateTouchBloc();

            if (scenePopups.Any())
            {
                var index = 0;

                parent         = parentInScene.Parent;
                touchBlocIndex = 0;

                var lastPopup = scenePopups.LastOrDefault();

                foreach (var popup in scenePopups)
                {
                    if (popup == lastPopup)
                    {
                        touchBlocIndex = index++;
                    }

                    popup.transform.SetSiblingIndex(index++);
                }
            }

            if (globalPopups.Any())
            {
                var index = 0;

                parent         = parentGlobal.Parent;
                touchBlocIndex = 0;

                var lastPopup = globalPopups.LastOrDefault();

                foreach (var popup in globalPopups)
                {
                    if (popup == lastPopup)
                    {
                        touchBlocIndex = index++;
                    }

                    popup.transform.SetSiblingIndex(index++);
                }
            }

            // ポップアップがなかった場合はグローバルの下に退避.
            if (parent == null)
            {
                parent = parentGlobal.Parent;
            }

            UnityUtility.SetParent(touchBloc.gameObject, parent);

            touchBloc.transform.SetSiblingIndex(touchBlocIndex);

            UnityUtility.SetLayer(parent, touchBloc.gameObject, true);

            // 一つでも登録されたら表示.
            if (!touchBloc.Active && (scenePopups.Any() || globalPopups.Any()))
            {
                if (touchBlocDisposable != null)
                {
                    touchBlocDisposable.Dispose();
                    touchBlocDisposable = null;
                }

                UnityUtility.SetActive(touchBloc, true);

                touchBlocDisposable = touchBloc.FadeIn().Subscribe().AddTo(this);
            }

            // 空になったら非表示.
            if (touchBloc.Active && (scenePopups.IsEmpty() && globalPopups.IsEmpty()))
            {
                if (touchBlocDisposable != null)
                {
                    touchBlocDisposable.Dispose();
                    touchBlocDisposable = null;
                }

                touchBlocDisposable = touchBloc.FadeOut()
                                      .Subscribe(_ => UnityUtility.SetActive(touchBloc, false))
                                      .AddTo(this);
            }
        }
Ejemplo n.º 9
0
        protected void UpdateContents()
        {
            var        touchBlocIndex = 0;
            GameObject parent         = null;

            if (touchBloc == null)
            {
                touchBloc = UnityUtility.Instantiate <TouchBloc>(parentGlobal.Parent, touchBlocPrefab);
                touchBloc.Initialize();
            }

            if (scenePopups.Any())
            {
                var index = 0;

                parent         = parentInScene.Parent;
                touchBlocIndex = 0;

                foreach (var item in scenePopups)
                {
                    if (item == scenePopups.LastOrDefault())
                    {
                        touchBlocIndex = index++;
                    }

                    item.transform.SetSiblingIndex(index++);
                }
            }

            if (globalPopups.Any())
            {
                var index = 0;

                parent         = parentGlobal.Parent;
                touchBlocIndex = 0;

                foreach (var item in globalPopups)
                {
                    if (item == globalPopups.LastOrDefault())
                    {
                        touchBlocIndex = index++;
                    }

                    item.transform.SetSiblingIndex(index++);
                }
            }

            // ポップアップがなかった場合はグローバルの下に退避.
            if (parent == null)
            {
                parent = parentGlobal.Parent;
            }

            UnityUtility.SetParent(touchBloc.gameObject, parent);

            touchBloc.transform.SetSiblingIndex(touchBlocIndex);

            UnityUtility.SetLayer(parent, touchBloc.gameObject, true);

            // 一つでも登録されたら表示.
            if (!touchBloc.Active && (scenePopups.Any() || globalPopups.Any()))
            {
                if (touchBlocDisposable != null)
                {
                    touchBlocDisposable.Dispose();
                    touchBlocDisposable = null;
                }

                touchBlocDisposable = touchBloc.FadeIn().Subscribe().AddTo(this);
            }

            // 空になったら非表示.
            if (touchBloc.Active && (scenePopups.IsEmpty() && globalPopups.IsEmpty()))
            {
                if (touchBlocDisposable != null)
                {
                    touchBlocDisposable.Dispose();
                    touchBlocDisposable = null;
                }

                touchBlocDisposable = touchBloc.FadeOut().Subscribe().AddTo(this);
            }
        }