// 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 InitStrata(IEnumerable <StratumSetting> stratumSettings) { int minOrder = 0; strata = new Dictionary <int, Stratum>(); foreach (var setting in stratumSettings) { var stratum = new Stratum(setting, minOrder); strata.Add(setting.Id, stratum); minOrder = stratum.ExclusiveMaxOrder; } }
// Canvas数が予定数以内か確認する bool CanHoldCanvases(int stratumId) { Stratum stratum = strata.GetValue(stratumId); if (stratum == null) { return(true); } IReadOnlyList <CanvasInStratum> canvasList = canvasListHolder.GetCanvasList(stratumId); if (stratum.Setting.PlannedMaxCanvasCount >= canvasList.Count) { return(true); } Debug.LogError($"Unexpected canvas count: stratumId={stratumId}, plannedMaxCanvasCount={stratum.Setting.PlannedMaxCanvasCount}, currentCanvasCount={canvasList.Count}"); return(false); }