mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 00:08:53 -05:00
Add: docs
This commit is contained in:
parent
99346cddb0
commit
5f62a111de
53
docs/articles/en/attributes/on-list-view-changed.md
Normal file
53
docs/articles/en/attributes/on-list-view-changed.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# On List View Changed Attribute
|
||||||
|
|
||||||
|
Detects changes in collections and invokes methods accordingly. Refer to Unity's [ListView documentation](https://docs.unity3d.com/ScriptReference/UIElements.ListView.html) for details on each event.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Ensure that the types of arguments for each event exactly match the arguments listed below (or the ListView event arguments). Failure to match will result in errors and the method won't execute.
|
||||||
|
|
||||||
|
```cs
|
||||||
|
[OnListViewChanged(
|
||||||
|
OnItemChanged = nameof(OnItemChanged),
|
||||||
|
OnItemsAdded = nameof(OnItemsAdded),
|
||||||
|
OnItemsRemoved = nameof(OnItemsRemoved),
|
||||||
|
OnSelectedIndicesChanged = nameof(OnSelectedIndicesChanged),
|
||||||
|
OnItemIndexChanged = nameof(OnItemIndexChanged))
|
||||||
|
]
|
||||||
|
public float[] array;
|
||||||
|
|
||||||
|
void OnItemChanged(int index, float item)
|
||||||
|
{
|
||||||
|
Debug.Log($"Changed: [{index}] -> {item}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnItemsAdded(IEnumerable<int> indices)
|
||||||
|
{
|
||||||
|
Debug.Log($"Added: [{string.Join(',', indices)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnItemsRemoved(IEnumerable<int> indices)
|
||||||
|
{
|
||||||
|
Debug.Log($"Removed: [{string.Join(',', indices)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSelectedIndicesChanged(IEnumerable<int> indices)
|
||||||
|
{
|
||||||
|
Debug.Log($"Selected: [{string.Join(',', indices)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnItemIndexChanged(int before, int after)
|
||||||
|
{
|
||||||
|
Debug.Log($"Index Changed: [{before} -> {after}]");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| Parameter | Description |
|
||||||
|
| - | - |
|
||||||
|
| OnItemChanged | Name of the method called when an item's value changes `(int index, T value)` |
|
||||||
|
| OnItemIndexChanged | Name of the method called when an item's index changes `(int before, int after)` |
|
||||||
|
| OnItemsAdded | Name of the method called when items are added `(IEnumerable<int> indices)` |
|
||||||
|
| OnItemsRemoved | Name of the method called when items are removed `(IEnumerable<int> indices)` |
|
||||||
|
| OnItemsChosen | Name of the method called when items are chosen by pressing Enter or double-clicking `(IEnumerable<object> items)` |
|
||||||
|
| OnItemsSourceChanged | Name of the method called when the original collection changes, such as its count `(no arguments)` |
|
||||||
|
| OnSelectionChanged | Name of the method called when the selected items change `(IEnumerable<object> items)` |
|
||||||
|
| OnSelectedIndicesChanged | Name of the method called when the selected indices change `(IEnumerable<int> indices)` |
|
@ -82,6 +82,8 @@
|
|||||||
href: attributes/on-inspector-disable.md
|
href: attributes/on-inspector-disable.md
|
||||||
- name: On Inspector Enable
|
- name: On Inspector Enable
|
||||||
href: attributes/on-inspector-enable.md
|
href: attributes/on-inspector-enable.md
|
||||||
|
- name: On List View Changed
|
||||||
|
href: attributes/on-list-view-changed.md
|
||||||
- name: On Value Changed
|
- name: On Value Changed
|
||||||
href: attributes/on-value-changed.md
|
href: attributes/on-value-changed.md
|
||||||
|
|
||||||
|
53
docs/articles/ja/attributes/on-list-view-changed.md
Normal file
53
docs/articles/ja/attributes/on-list-view-changed.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# On List View Changed Attribute
|
||||||
|
|
||||||
|
コレクションの変更を検知してメソッドを呼び出します。各イベントの詳細はUnityの[ListViewのドキュメント](https://docs.unity3d.com/ScriptReference/UIElements.ListView.html)を参照してください。
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> 各イベントの引数の型が、下の表に示した引数(またはListViewのイベントの引数)と完全に一致していることを確認してください。一致しない場合、メソッドを実行できずエラーが発生します。
|
||||||
|
|
||||||
|
```cs
|
||||||
|
[OnListViewChanged(
|
||||||
|
OnItemChanged = nameof(OnItemChanged),
|
||||||
|
OnItemsAdded = nameof(OnItemsAdded),
|
||||||
|
OnItemsRemoved = nameof(OnItemsRemoved),
|
||||||
|
OnSelectedIndicesChanged = nameof(OnSelectedIndicesChanged),
|
||||||
|
OnItemIndexChanged = nameof(OnItemIndexChanged))
|
||||||
|
]
|
||||||
|
public float[] array;
|
||||||
|
|
||||||
|
void OnItemChanged(int index, float item)
|
||||||
|
{
|
||||||
|
Debug.Log($"Changed: [{index}] -> {item}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnItemsAdded(IEnumerable<int> indices)
|
||||||
|
{
|
||||||
|
Debug.Log($"Added: [{string.Join(',', indices)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnItemsRemoved(IEnumerable<int> indices)
|
||||||
|
{
|
||||||
|
Debug.Log($"Removed: [{string.Join(',', indices)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSelectedIndicesChanged(IEnumerable<int> indices)
|
||||||
|
{
|
||||||
|
Debug.Log($"Selected: [{string.Join(',', indices)}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnItemIndexChanged(int before, int after)
|
||||||
|
{
|
||||||
|
Debug.Log($"Index Changed: [{before} -> {after}]");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| パラメータ | 説明 |
|
||||||
|
| - | - |
|
||||||
|
| OnItemChanged | 要素の値を変更した際に呼ばれるメソッドの名前 `(int index, T value)` |
|
||||||
|
| OnItemIndexChanged | 要素のindexが変更された際に呼ばれるメソッドの名前 `(int before, int after)` |
|
||||||
|
| OnItemsAdded | 要素が追加された際に呼ばれるメソッドの名前 `(IEnumerable<int> indices)` |
|
||||||
|
| OnItemsRemoved | 要素が削除された際に呼ばれるメソッドの名前 `(IEnumerable<int> indices)` |
|
||||||
|
| OnItemsChosen | 要素がEnterキーやダブルクリックで選択された際に呼ばれるメソッドの名前 `(IEnumerable<object> items)` |
|
||||||
|
| OnItemsSourceChanged | 要素の個数など、元のコレクションが変更された際に呼ばれるメソッドの名前 `(引数なし)` |
|
||||||
|
| OnSelectionChanged | 選択中の要素が変更された際に呼ばれるメソッドの名前 `(IEnumerable<object> items)` |
|
||||||
|
| OnSelectedIndicesChanged | 選択中のindexが変更された際に呼ばれるメソッドの名前 `(IEnumerable<int> indices)` |
|
@ -82,6 +82,8 @@
|
|||||||
href: attributes/on-inspector-disable.md
|
href: attributes/on-inspector-disable.md
|
||||||
- name: On Inspector Enable
|
- name: On Inspector Enable
|
||||||
href: attributes/on-inspector-enable.md
|
href: attributes/on-inspector-enable.md
|
||||||
|
- name: On List View Changed
|
||||||
|
href: attributes/on-list-view-changed.md
|
||||||
- name: On Value Changed
|
- name: On Value Changed
|
||||||
href: attributes/on-value-changed.md
|
href: attributes/on-value-changed.md
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user