void CanvasSetState(UICanvasBase obj, bool active) { if (active) { obj.ChengeUIState(UICanvasBase.UISTATE.ACTIVE); } else { obj.ChengeUIState(UICanvasBase.UISTATE.CLOSE); } }
public override void AddCanvas(UICanvasBase target) { if (_openCanvasHirtory.Count > 0) { var head = _openCanvasHirtory.Peek(); head.ChengeUIState(UICanvasBase.UISTATE.SLEEP); } CanvasSetState(target, true); target.GetComponent <Canvas>().sortingOrder = CaluculateNextSortOrder(); _openCanvasHirtory.Push(target); }
//実際に遷移を実行する void RunTransition(UICanvasBase chengeUI, bool selfActive) { if (selfActive) { _uiCtrl.AddCanvas(chengeUI); } else { //_uiCtrl.CloseToNextCanvas(chengeUI); _uiCtrl.CloseAndAddCanvas(chengeUI); } }
public override void AddCanvas(UICanvasBase target) { if (_openCanvasHirtory.Count > 0) { var head = _openCanvasHirtory.Peek(); head.ChengeUIState(UICanvasBase.UISTATE.SLEEP); } target.gameObject.SetActive(true); _openCanvasHirtory.Push(target); target.ChengeUIState(UICanvasBase.UISTATE.ACTIVE); }
//UIのグループを閉じて別のUIを開く という動きをしたいができない public void CloseAndAddCanvas(UICanvasBase nextCanvas) { var impl = (DefaultCanvasImpl)_uiCvImpl; if (impl.ContaintHitory(nextCanvas)) { CloseToNextCanvas(nextCanvas); } else { CloseCanvas(impl._historyTop); AddCanvas(nextCanvas); } }
public override void CloseCanvas(UICanvasBase nextCanvas, bool lastOpen) { if (_openCanvasHirtory.Contains(nextCanvas)) { while (true) { //nextCanvasより上の階層のものをすべて閉じる //lastOpen=falseならnextCanvasも閉じる var next = _openCanvasHirtory.Peek(); if (next != nextCanvas) { _openCanvasHirtory.Pop(); next.gameObject.SetActive(false); next.ChengeUIState(UICanvasBase.UISTATE.CLOSE); } else if (next == nextCanvas && !lastOpen) { _openCanvasHirtory.Pop(); next.gameObject.SetActive(false); next.ChengeUIState(UICanvasBase.UISTATE.CLOSE); break; } else if (next == nextCanvas && lastOpen) { next.ChengeUIState(UICanvasBase.UISTATE.ACTIVE); break; } } } else { //閉じるものがスタックにないときのエラー //わかりやすいエラーコードにしたい Debug.Log("DefaultCanvasImpl error"); return; } }
public override void CloseCanvas(UICanvasBase nextCanvas) { if (_openCanvasHirtory.Contains(nextCanvas)) { while (true) { //nextCanvasより上の階層のものをすべて閉じる //lastOpen=falseならnextCanvasも閉じる var topCanvas = _openCanvasHirtory.Pop(); CanvasSetState(topCanvas, false); if (topCanvas == nextCanvas) { break; } } } else { //閉じるものがスタックにないときのエラー //わかりやすいエラーコードにしたい Debug.Log("DefaultCanvasImpl error"); return; } }
void SetSortOrder(UICanvasBase target, int order) { target.SelfCanvas.sortingOrder = order; }
public DefaultCanvasImpl(UICanvasBase firstCanvas) : base(firstCanvas) { }
//履歴stackに含まれているかどうか public bool ContaintHitory(UICanvasBase target) { return(_openCanvasHirtory.Contains(target)); }
//履歴にあるキャンバスまで閉じる //lastOpen=trueならnextCanvasは閉じない public abstract void CloseCanvas(UICanvasBase nextCanvas, bool lastOpen);
//現在のキャンバスを閉じて別のものを開く ができない //キャンバスを開く処理 public abstract void AddCanvas(UICanvasBase target);
//コンストラクタなくてもいいかも public UICanvasOpenImplementor(UICanvasBase firstCanvas) { AddCanvas(firstCanvas); }
public void CloseToNextCanvas(UICanvasBase nextCanvas) { _uiCvImpl.CloseCanvas(nextCanvas, lastOpen: true); }
public void CloseCanvas(UICanvasBase target) { _uiCvImpl.CloseCanvas(target, lastOpen: false); }
public void AddCanvas(UICanvasBase target) { SetSortOrder(target, _uiCvImpl.CaluculateNextSortOrder()); _uiCvImpl.AddCanvas(target); }
//履歴にあるキャンバスまで閉じる //lastOpen=trueならnextCanvasは閉じない public abstract void CloseCanvas(UICanvasBase nextCanvas);