public void Copy(UnitCatalogItemContext _data) { _data.Index = Index; _data.master = master; _data.DidSelectItem = DidSelectItem; _data.DidLongPressItem = DidLongPressItem; if (m_isIconColorSet) { _data.IconColor = IconColor; } else { SetIconColorLater(_data); } if (m_isIconImageLoaded) { _data.IconImage = IconImage; } else { SetIconImageLater(_data); } }
public RectTransform GetItem(int index, RectTransform recyclableItem) { // indexの位置にあるセルを読み込む処理 if (null == recyclableItem) { // 初回ロード時はinstantateItemCountで指定した回数分だけitemがnullで来るので、ここで生成してあげる // 以降はitemが再利用されるため、Reflesh()しない限りnullは来ない recyclableItem = Instantiate(itemPrefab).GetComponent <RectTransform>(); } // セルの内容書き換え { UnitCatalogLine _line = recyclableItem.GetComponent <UnitCatalogLine>(); _line.ItemList.Clear(); int start_id = index * 5; for (int i = 0; i < 5; i++) { if (start_id + i >= MasterCatalogList.Count) { continue; } UnitCatalogItemContext copyContext = new UnitCatalogItemContext(); MasterCatalogList[start_id + i].Copy(copyContext); copyContext.requestId = UnitIconImageProvider.Instance.Get( copyContext.master.fix_id, sprite => { copyContext.IconImage = sprite; }); _line.ItemList.Add(copyContext); } m_Count++; if (m_Count >= 100) { System.GC.Collect(); m_Count = 0; } } return(recyclableItem); }
protected override void Start() { base.Start(); MasterDataParamChara[] charaArray = MasterFinder <MasterDataParamChara> .Instance.GetAll(); for (int i = 0; i < charaArray.Length; i++) { if (charaArray[i].fix_id == 0) { continue; } UnitCatalogItemContext _newItem = new UnitCatalogItemContext(); _newItem.IconImage = testData; _newItem.Index = (int)charaArray[i].draw_id; unitCatalog.MasterCatalogList.Add(_newItem); } unitCatalog.Init(); }
private void SetIconImageLater(UnitCatalogItemContext _data) { // コピー元のアイコンロード完了時にコピー先がいなくなっていた場合の対策 bool isAlive = true; _data.OnDestructed += () => { isAlive = false; }; RegisteronIconImageUpdatedOnce(sprite => { if (!isAlive) { return; } _data.IconImage = sprite; }); }
private void updateUnitCatalog() { m_TotalCount = 0; if (m_UnitCatalog.MasterCatalogList.Count == 0) { //sqlite対応 チェック済み そのまま残す MasterDataParamChara[] charaArray = MasterFinder <MasterDataParamChara> .Instance.GetAll(); for (int i = 0; i < charaArray.Length; i++) { if (charaArray[i] == null || charaArray[i].fix_id == 0) { continue; } bool bGet = false; //GETしてるかチェック if (IsGetUnit(charaArray[i].fix_id)) { bGet = true; } if (bGet) { m_TotalCount++; } UnitCatalogItemContext item = new UnitCatalogItemContext(); item.Index = (int)charaArray[i].draw_id; item.master = charaArray[i]; if (!bGet) { item.IconColor = GrayColor; } else { item.IconColor = WhiteColor; } /* * UnitIconImageProvider.Instance.Get( * charaArray[i].fix_id, * sprite => * { * item.IconImage = sprite; * }); */ item.DidSelectItem = SelectItem; m_UnitCatalog.MasterCatalogList.Add(item); } } else { for (int i = 0; i < m_UnitCatalog.MasterCatalogList.Count; i++) { int index = i; var data = m_UnitCatalog.MasterCatalogList[index]; bool bGet = false; //GETしてるかをチェック if (IsGetUnit(data.master.fix_id)) { bGet = true; } if (bGet) { m_TotalCount++; } /* * UnitIconImageProvider.Instance.Get( * data.master.fix_id, * sprite => * { * m_UnitCatalog.MasterCatalogList[index].IconImage = sprite; * }); */ if (!bGet) { data.IconColor = GrayColor; } else { data.IconColor = WhiteColor; } } } m_UnitCatalog.Init(); // ユニット所持数表示 m_UnitCatalog.CountText = string.Format(GameTextUtil.GetText("zukan_counttext"), m_TotalCount, m_UnitCatalog.MasterCatalogList.Count); }
protected override void PageSwitchSetting(bool initalize) { base.PageSwitchSetting(initalize); // TODO: ページ解説テキスト設定 // TODO: タイトル設定 m_DebugGetUnitSelectPanel = m_CanvasObj.GetComponentInChildren <DebugGetUnitSelectPanel>(); m_UnitCatalog = m_CanvasObj.GetComponentInChildren <UnitCatalog>(); if (m_DebugGetUnitSelectPanel != null) { m_DebugGetUnitSelectPanel.Units.Clear(); for (int i = 0; i < UNIT_NUM; i++) { DebugGetUnitListItemContext unit = new DebugGetUnitListItemContext(); unit.ClickAction = OnClickSelectedUnit; unit.LongPressAction = OnLongPressSelectedUnit; m_DebugGetUnitSelectPanel.Units.Add(unit); } m_DebugGetUnitSelectPanel.ClickFixButtonAction = OnClickFixButton; m_DebugGetUnitSelectPanel.ClickResetButtonAction = OnClickResetButton; m_DebugGetUnitSelectPanel.ClickSearchAddButtonAction = OnClickSearchAddButton; m_DebugGetUnitSelectPanel.ResetParam(); if (SafeAreaControl.HasInstance) { float bottom_space_height = SafeAreaControl.Instance.bottom_space_height; if (bottom_space_height > 0) { float height = (bottom_space_height / 2) * -1; m_DebugGetUnitSelectPanel.transform.AddLocalPositionY(height); } } } if (m_UnitCatalog != null) { m_UnitCatalog.SetPositionAjustStatusBar(new Vector2(0, -112f), new Vector2(0, -495f)); m_UnitCatalog.LabelText = ""; m_UnitCatalog.IsActiveLabel = false; if (m_UnitCatalog.MasterCatalogList.Count == 0) { MasterDataParamChara[] charamsterArray = MasterFinder <MasterDataParamChara> .Instance.GetAll(); for (int i = 0; i < charamsterArray.Length; ++i) { if (charamsterArray[i] == null) { continue; } if (charamsterArray[i].fix_id == 0) { continue; } UnitCatalogItemContext unit = new UnitCatalogItemContext(); unit.master = charamsterArray[i]; unit.Index = (int)unit.master.draw_id; unit.DidSelectItem = OnClickUnit; unit.DidLongPressItem = OnLongPressUnit; /* * UnitIconImageProvider.Instance.Get( * unit.master.fix_id, * sprite => * { * unit.IconImage = sprite; * }); */ m_UnitCatalog.MasterCatalogList.Add(unit); } m_UnitCatalog.Init(); } } }