/** ******************************************************************************** * @summary コンストラクタ ***********************************************************************************/ public TextureTreeView(TextureTreeViewState state, TextureColumnHeaderState headerState) : base(new TextureTreeViewState(), new TextureColumnHeader(headerState)) { showAlternatingRowBackgrounds = true; // 背景のシマシマを表示 showBorder = true; // 境界線を表示 var textureColumnHeader = multiColumnHeader as TextureColumnHeader; textureColumnHeader.sortingChanged += OnSortingChanged; // ソート変化時の処理を登録 textureColumnHeader.searchChanged += CallSearchChanged; // 列の検索が変化したときの処理を登録 foreach (var searchField in headerState.SearchFields) { //searchField.searchChanged += () => CallSearchChanged(""); searchField.searchChanged += CallSearchChanged; } }
/** ******************************************************************************** * @summary 列の検索ボックスの描画 ***********************************************************************************/ public void OnGUI(Rect searchRect, TextureColumnHeaderState headerState, int columnIndex) { var columnHeaderId = (EHeaderColumnId)columnIndex; var searchState = headerState.SearchStates[columnIndex]; switch (columnHeaderId) { case EHeaderColumnId.TextureName: searchState.searchString = SearchField.OnToolbarGUI(searchRect, searchState.searchString); break; case EHeaderColumnId.TextureType: searchState.searchFilter = EditorGUI.EnumPopup(searchRect, (Enum_TextureImporterType)searchState.searchFilter).GetHashCode(); break; case EHeaderColumnId.NPot: searchState.searchFilter = EditorGUI.EnumPopup(searchRect, (Enum_TextureImporterNPOTScale)searchState.searchFilter).GetHashCode(); break; case EHeaderColumnId.MaxSize: searchState.searchFilter = EditorGUI.EnumPopup(searchRect, (Enum_MaxTextureSize)searchState.searchFilter).GetHashCode(); break; case EHeaderColumnId.GenerateMips: searchState.searchFilter = EditorGUI.EnumPopup(searchRect, (Enum_GenerateMipMaps)searchState.searchFilter).GetHashCode(); break; case EHeaderColumnId.AlphaIsTransparency: searchState.searchFilter = EditorGUI.EnumPopup(searchRect, (Enum_AlphaIsTransparency)searchState.searchFilter).GetHashCode(); break; case EHeaderColumnId.TextureSize: searchState.searchString = SearchField.OnToolbarGUI(searchRect, searchState.searchString); break; case EHeaderColumnId.DataSize: searchState.searchFilter = EditorGUI.EnumPopup(searchRect, (Enum_DataSize_Unit)searchState.searchFilter).GetHashCode(); break; default: break; } }
/** ******************************************************************************** * @summary TreeView の更新 Update ***********************************************************************************/ private void CreateTreeView() { if (treeView != null) { return; } if (isCreatingTreeView) { return; } isCreatingTreeView = true; Repaint(); EditorApplication.delayCall += () => { if (columnSearchStates == null || columnSearchStates.Length != ToolConfig.HeaderColumnNum) { columnSearchStates = new SearchState[ToolConfig.HeaderColumnNum]; for (int i = 0; i < ToolConfig.HeaderColumnNum; i++) { columnSearchStates[i] = new SearchState(); } } treeViewState = treeViewState ?? new TextureTreeViewState(); headerState = headerState ?? new TextureColumnHeaderState(ToolConfig.HeaderColumns, columnSearchStates); headerState.ResetSearch(); // TreeView作成 treeView = treeView ?? new TextureTreeView(treeViewState, headerState); treeView.searchString = TextureTreeView.defaultSearchString; treeView.Reload(); // Reloadを呼ぶとBuildRootが実行され、次にBuildRowsが実行されます。 // SearchFieldを初期化 searchField = new SearchField(); searchField.downOrUpArrowKeyPressed += treeView.SetFocusAndEnsureSelectedItem; isCreatingTreeView = false; }; }