// OrderInLayerの値が指定順に並んでいるか確認する // 並んでいない場合は調整する void ModifyOrder(int stratumId) { Stratum stratum = strata.GetValue(stratumId); IReadOnlyList <CanvasInStratum> canvasList = canvasListHolder.GetCanvasList(stratumId); if (stratum == null && !canvasList.IsEmpty()) { Debug.LogError($"Cannot get stratum: stratumId={stratumId}"); return; } int usableMinOrder = stratum.MinOrder; for (int i = 0; i < canvasList.Count; i++) { CanvasInStratum canvas = canvasList[i]; int currentOrder = canvas.CanvasOrderUpdater.CanvasOrder; int usableExclusiveMaxOrder = stratum.ExclusiveMaxOrder - (canvasList.Count - i - 1) * stratum.Setting.OrderInterval; if (currentOrder < usableMinOrder || currentOrder >= usableExclusiveMaxOrder) { canvas.CanvasOrderUpdater.SetOrder(usableMinOrder); currentOrder = usableMinOrder; } usableMinOrder = currentOrder + stratum.Setting.OrderInterval; } }
void ICanvasBank.AddCanvas(CanvasInStratum canvas, IEnumerable <CameraMat> cameraMats) { canvasRepository.AddCanvas(canvas); canvasOrderModifier.SetOrder(canvas.StratumId); if (cameraMats != null) { cameraMatRepository.ReplaceCameraMatList(canvas.StratumId, cameraMats); } SetCameraToCanvases(); }
int GetIndexToInsert(List <CanvasInStratum> canvasList, CanvasInStratum insertingCanvas) { for (int i = canvasList.Count - 1; i >= 0; i--) { if (canvasList[i].OrderInStratum > insertingCanvas.OrderInStratum) { continue; } return(i + 1); } return(0); }
public IEnumerable <CanvasInStratum> EnumerateCanvases() { // CanvasOrderModifierを通すことでorderの降順に並ぶことが期待される for (int i = canvasListDictionary.Count - 1; i >= 0; i--) { List <CanvasInStratum> canvasList = canvasListDictionary.Values[i]; for (int j = canvasList.Count - 1; j >= 0; j--) { CanvasInStratum canvasInStratum = canvasList[j]; if (canvasInStratum.CanvasOrderUpdater != null) { yield return(canvasInStratum); } } } }
public void AddCanvas(CanvasInStratum canvas) { List <CanvasInStratum> canvasList = this.canvasListDictionary.GetValue(canvas.StratumId, false); if (canvasList == null) { canvasList = new List <CanvasInStratum>(); this.canvasListDictionary.Add(canvas.StratumId, canvasList); } // DestroyされたCanvasを消去する canvasList.RemoveAll(cs => cs.CanvasOrderUpdater == null); int index = GetIndexToInsert(canvasList, canvas); canvasList.Insert(index, canvas); }