private void CreateTouchBloc() { if (touchBloc != null) { return; } touchBloc = UnityUtility.Instantiate <TouchBloc>(parentGlobal.Parent, touchBlocPrefab); touchBloc.Initialize(); touchBloc.OnBlocTouchAsObservable() .Subscribe(_ => { if (onBlocTouch != null) { onBlocTouch.OnNext(Unit.Default); } }) .AddTo(this); }
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); } }