public override void RemoveView(RavenhillViewType viewType) { if (openedViews.ContainsKey(viewType)) { GameObject instance = openedViews[viewType]; openedViews.Remove(viewType); if (instance) { RavenhillBaseView baseView = instance.GetComponentInChildren <RavenhillBaseView>(); baseView?.OnViewWillBeClosed(); if (baseView) { baseView.FadeOut(); } else { GameObject.Destroy(instance); } lastViewRemovedTime = Time.time; RavenhillEvents.OnViewRemoved(viewType); } } }
private GameObject CreatePrefabAndAddToScreen(RavenhillViewType viewType, object data = null) { GameObject prefab = GetPrefab(viewType); GameObject instance = GameObject.Instantiate <GameObject>(prefab); RavenhillBaseView baseView = instance.GetComponentInChildren <RavenhillBaseView>(); baseView?.Setup(data); ICanvasSerive canvasService = engine.GetService <ICanvasSerive>(); canvasService?.Add(instance.transform); SetSibling(baseView); return(instance); }
private void SetSibling(RavenhillBaseView baseView) { if (baseView == null) { return; } List <RavenhillBaseView> currentViews = (from kvp in openedViews where kvp.Value let view = kvp.Value.GetComponentInChildren <RavenhillBaseView>() where view select view).ToList(); currentViews.Add(baseView); currentViews.Sort((a, b) => a.siblingIndex.CompareTo(b.siblingIndex)); for (int i = 0; i < currentViews.Count; i++) { currentViews[i].transform.SetSiblingIndex(i); } ICanvasSerive canvasService = engine.GetService <ICanvasSerive>(); canvasService?.RestoreSiblings(); }