mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 00:08:53 -05:00
commit
88ab870b26
54
.github/workflows/publish-docfx.yml
vendored
Normal file
54
.github/workflows/publish-docfx.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: Publish DocFX
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v3
|
||||
|
||||
- name: Setup Dotnet
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
|
||||
- name: Setup DocFx
|
||||
run: dotnet tool update -g docfx
|
||||
|
||||
- name: Dotnet Restore
|
||||
run: dotnet tool restore
|
||||
|
||||
- name: Build
|
||||
run: docfx docs/docfx.json
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
path: docs/_site
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v2
|
3
docs/.gitignore
vendored
Normal file
3
docs/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.cache
|
||||
/**/_site/
|
||||
*.DS_Store
|
3
docs/api/.gitignore
vendored
Normal file
3
docs/api/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# temp file
|
||||
*.yml
|
||||
.manifest
|
9
docs/articles/en/about.md
Normal file
9
docs/articles/en/about.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Alchemy Overview
|
||||
|
||||
![header](../../images/header.png)
|
||||
|
||||
Alchemy is a library that provides a rich set of editor extensions for Unity. By integrating Alchemy, over 30 attributes are added to easily extend the Inspector. Additionally, by utilizing the Unity.Serialization package and a dedicated Source Generator, it becomes possible to serialize and edit types not normally serializable in Unity (`Dictionary`, `HashSet`, `Nullable`, `ValueTuple`, etc.) directly from the Inspector.
|
||||
|
||||
![img](../../images/img-v2.0.png)
|
||||
|
||||
Furthermore, version 2.0 introduces new features such as EditorWindow extensions and Hierarchy extensions. These enable the easy creation of tools to streamline the development workflow within the editor.
|
53
docs/articles/en/alchemy-editor-window.md
Normal file
53
docs/articles/en/alchemy-editor-window.md
Normal file
@ -0,0 +1,53 @@
|
||||
# AlchemyEditorWindow
|
||||
|
||||
By inheriting from `AlchemyEditorWindow` instead of `EditorWindow`, you can create editor windows using Alchemy attributes.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Editor;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
public class EditorWindowExample : AlchemyEditorWindow
|
||||
{
|
||||
[MenuItem("Window/Example")]
|
||||
static void Open()
|
||||
{
|
||||
var window = GetWindow<EditorWindowExample>("Example");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[HorizontalGroup]
|
||||
public class DatabaseItem
|
||||
{
|
||||
[LabelWidth(30f)]
|
||||
public float foo;
|
||||
|
||||
[LabelWidth(30f)]
|
||||
public Vector3 bar;
|
||||
|
||||
[LabelWidth(30f)]
|
||||
public GameObject baz;
|
||||
}
|
||||
|
||||
[ListViewSettings(ShowAlternatingRowBackgrounds = AlternatingRowBackground.All, ShowFoldoutHeader = false)]
|
||||
public List<DatabaseItem> items;
|
||||
|
||||
[Button, HorizontalGroup]
|
||||
public void Button1() { }
|
||||
|
||||
[Button, HorizontalGroup]
|
||||
public void Button2() { }
|
||||
|
||||
[Button, HorizontalGroup]
|
||||
public void Button3() { }
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-editor-window.png)
|
||||
|
||||
Data from windows created by inheriting `AlchemyEditorWindow` is saved in JSON format in the ProjectSettings folder of the project. For more details, refer to the [Saving Editor Window Data](saving-editor-window-data.md) page.
|
80
docs/articles/en/alchemy-serialization-process.md
Normal file
80
docs/articles/en/alchemy-serialization-process.md
Normal file
@ -0,0 +1,80 @@
|
||||
# Alchemy Serialization Process
|
||||
|
||||
In Alchemy, by adding the `[AlchemySerialize]` attribute to the target type, a dedicated Source Generator automatically implements `ISerializationCallbackReceiver`. Within this process, all fields annotated with `[AlchemySerializeField]` are gathered, and using the Unity.Serialization package, they are converted to JSON format. However, fields of type `UnityEngine.Object` cannot be handled in JSON format, so their instances are saved in a single list, and only their indices are written to JSON.
|
||||
|
||||
For example, consider the following class:
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Alchemy.Serialization;
|
||||
|
||||
[AlchemySerialize]
|
||||
public partial class AlchemySerializationExample : MonoBehaviour
|
||||
{
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public Dictionary<string, GameObject> dictionary = new();
|
||||
}
|
||||
```
|
||||
|
||||
Alchemy generates code similar to the following:
|
||||
|
||||
```cs
|
||||
partial class AlchemySerializationExample : global::UnityEngine.ISerializationCallbackReceiver
|
||||
{
|
||||
[global::System.Serializable]
|
||||
sealed class AlchemySerializationData
|
||||
{
|
||||
[global::System.Serializable]
|
||||
public sealed class Item
|
||||
{
|
||||
[global::UnityEngine.HideInInspector] public bool isCreated;
|
||||
[global::UnityEngine.TextArea] public string data;
|
||||
}
|
||||
|
||||
public Item dictionary = new();
|
||||
|
||||
[global::UnityEngine.SerializeField] private global::System.Collections.Generic.List<UnityEngine.Object> unityObjectReferences = new();
|
||||
|
||||
public global::System.Collections.Generic.IList<UnityEngine.Object> UnityObjectReferences => unityObjectReferences;
|
||||
}
|
||||
|
||||
[global::UnityEngine.HideInInspector, global::UnityEngine.SerializeField] private AlchemySerializationData alchemySerializationData = new();
|
||||
|
||||
void global::UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
if (this is global::Alchemy.Serialization.IAlchemySerializationCallbackReceiver receiver) receiver.OnBeforeSerialize();
|
||||
alchemySerializationData.UnityObjectReferences.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
alchemySerializationData.dictionary.data = global::Alchemy.Serialization.Internal.SerializationHelper.ToJson(this.dictionary , alchemySerializationData.UnityObjectReferences);
|
||||
alchemySerializationData.dictionary.isCreated = true;
|
||||
}
|
||||
catch (global::System.Exception ex)
|
||||
{
|
||||
global::UnityEngine.Debug.LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void global::UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (alchemySerializationData.dictionary.isCreated)
|
||||
{
|
||||
this.dictionary = global::Alchemy.Serialization.Internal.SerializationHelper.FromJson<System.Collections.Generic.Dictionary<string, UnityEngine.GameObject>>(alchemySerializationData.dictionary.data, alchemySerializationData.UnityObjectReferences);
|
||||
}
|
||||
}
|
||||
catch (global::System.Exception ex)
|
||||
{
|
||||
global::UnityEngine.Debug.LogException(ex);
|
||||
}
|
||||
|
||||
if (this is global::Alchemy.Serialization.IAlchemySerializationCallbackReceiver receiver) receiver.OnAfterDeserialize();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Using `[AlchemySerializeField]` increases the processing load for serialization and deserialization. Therefore, it is recommended to avoid using `[AlchemySerializeField]` whenever possible.
|
13
docs/articles/en/attributes/assets-only.md
Normal file
13
docs/articles/en/attributes/assets-only.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Assets Only Attribute
|
||||
|
||||
Limits the reference that can be entered into an object field to assets only.
|
||||
|
||||
![img](../../../images/img-attribute-assets-only.png)
|
||||
|
||||
```cs
|
||||
[AssetsOnly]
|
||||
public Object asset1;
|
||||
|
||||
[AssetsOnly]
|
||||
public GameObject asset2;
|
||||
```
|
14
docs/articles/en/attributes/blockquote.md
Normal file
14
docs/articles/en/attributes/blockquote.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Blockquote Attribute
|
||||
|
||||
Displays a quotation in the Inspector.
|
||||
|
||||
![img](../../../images/img-attribute-blockquote.png)
|
||||
|
||||
```cs
|
||||
[Blockquote("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")]
|
||||
public float foo;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Text | The text to display in the quotation |
|
29
docs/articles/en/attributes/box-group.md
Normal file
29
docs/articles/en/attributes/box-group.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Box Group Attribute
|
||||
|
||||
Creates a group that wraps multiple members in a box for display.
|
||||
|
||||
![img](../../../images/img-attribute-box-group.png)
|
||||
|
||||
```cs
|
||||
[BoxGroup("Group1")]
|
||||
public float foo;
|
||||
|
||||
[BoxGroup("Group1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[BoxGroup("Group1")]
|
||||
public GameObject baz;
|
||||
|
||||
[BoxGroup("Group1/Group2")]
|
||||
public float alpha;
|
||||
|
||||
[BoxGroup("Group1/Group2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[BoxGroup("Group1/Group2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| GroupPath | Specifies the path of the group. Groups can be nested by separating them with `/`. |
|
30
docs/articles/en/attributes/button.md
Normal file
30
docs/articles/en/attributes/button.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Button Attribute
|
||||
|
||||
Displays a button in the Inspector that can execute a method. If the method has parameters, input fields for those parameters will be added.
|
||||
|
||||
![img](../../../images/img-attribute-button.png)
|
||||
|
||||
```cs
|
||||
[Button]
|
||||
public void Foo()
|
||||
{
|
||||
Debug.Log("Foo");
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(int parameter)
|
||||
{
|
||||
Debug.Log("Foo: " + parameter);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(SampleClass parameter)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine();
|
||||
builder.Append("foo = ").AppendLine(parameter.foo.ToString());
|
||||
builder.Append("bar = ").AppendLine(parameter.bar.ToString());
|
||||
builder.Append("baz = ").Append(parameter.baz == null ? "Null" : parameter.baz.ToString());
|
||||
Debug.Log("Foo: " + builder.ToString());
|
||||
}
|
||||
```
|
15
docs/articles/en/attributes/disable-alchemy-editor.md
Normal file
15
docs/articles/en/attributes/disable-alchemy-editor.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Disable Alchemy Editor Attribute
|
||||
|
||||
Disables the AlchemyEditor for the target class and uses the default Inspector for rendering. When this attribute is added to a field, only that field will be rendered using the default PropertyField.
|
||||
|
||||
![img](../../../images/img-attribute-disable-alchemy-editor.png)
|
||||
|
||||
```cs
|
||||
[DisableAlchemyEditor]
|
||||
public class DisableAlchemyEditorExample : MonoBehaviour
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
```
|
27
docs/articles/en/attributes/disable-if.md
Normal file
27
docs/articles/en/attributes/disable-if.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Disable If Attribute
|
||||
|
||||
If the boolean value of the target member is true, the field becomes disabled.
|
||||
|
||||
![img](../../../images/img-attribute-disable-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-disable-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool isDisabled;
|
||||
|
||||
public bool IsDisabled => isDisabled;
|
||||
public bool IsDisabledMethod() => isDisabled;
|
||||
|
||||
[DisableIf("isDisabled")]
|
||||
public int disableIfField;
|
||||
|
||||
[DisableIf("IsDisabled")]
|
||||
public int disableIfProperty;
|
||||
|
||||
[DisableIf("IsDisabledMethod")]
|
||||
public int disableIfMethod;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Condition | The name of the field, property, or method used for condition evaluation. |
|
12
docs/articles/en/attributes/disable-in-edit-mode.md
Normal file
12
docs/articles/en/attributes/disable-in-edit-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Disable In Edit Mode Attribute
|
||||
|
||||
During Edit Mode, the field becomes disabled.
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-edit-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-edit-mode-player.png)
|
||||
|
||||
```cs
|
||||
[DisableInEditMode]
|
||||
public float foo;
|
||||
```
|
12
docs/articles/en/attributes/disable-in-play-mode.md
Normal file
12
docs/articles/en/attributes/disable-in-play-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Disable In Play Mode Attribute
|
||||
|
||||
During Play Mode, the field becomes disabled.
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-play-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-play-mode-player.png)
|
||||
|
||||
```cs
|
||||
[DisableInPlayMode]
|
||||
public float foo;
|
||||
```
|
27
docs/articles/en/attributes/enable-if.md
Normal file
27
docs/articles/en/attributes/enable-if.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Enable If Attribute
|
||||
|
||||
The field becomes editable only if the boolean value of the target member is true.
|
||||
|
||||
![img](../../../images/img-attribute-enable-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-enable-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool isEnabled;
|
||||
|
||||
public bool IsEnabled => isEnabled;
|
||||
public bool IsEnabledMethod() => isEnabled;
|
||||
|
||||
[EnableIf("isEnabled")]
|
||||
public int enableIfField;
|
||||
|
||||
[EnableIf("IsEnabled")]
|
||||
public int enableIfProperty;
|
||||
|
||||
[EnableIf("IsEnabledMethod")]
|
||||
public int enableIfMethod;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Condition | The name of the field, property, or method used for condition evaluation |
|
29
docs/articles/en/attributes/foldout-group.md
Normal file
29
docs/articles/en/attributes/foldout-group.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Foldout Group Attribute
|
||||
|
||||
Creates collapsible groups for multiple members.
|
||||
|
||||
![img](../../../images/img-attribute-foldout-group.png)
|
||||
|
||||
```cs
|
||||
[FoldoutGroup("Group1")]
|
||||
public float foo;
|
||||
|
||||
[FoldoutGroup("Group1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[FoldoutGroup("Group1")]
|
||||
public GameObject baz;
|
||||
|
||||
[FoldoutGroup("Group2")]
|
||||
public float alpha;
|
||||
|
||||
[FoldoutGroup("Group2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[FoldoutGroup("Group2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| GroupPath | Specifies the path of the group. Groups can be nested using `/`. |
|
29
docs/articles/en/attributes/group.md
Normal file
29
docs/articles/en/attributes/group.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Group Attribute
|
||||
|
||||
Creates a group to display multiple members together.
|
||||
|
||||
![img](../../../images/img-attribute-group.png)
|
||||
|
||||
```cs
|
||||
[Group("Group1")]
|
||||
public float foo;
|
||||
|
||||
[Group("Group1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[Group("Group1")]
|
||||
public GameObject baz;
|
||||
|
||||
[Group("Group2")]
|
||||
public float alpha;
|
||||
|
||||
[Group("Group2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[Group("Group2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| GroupPath | Specifies the path of the group. Groups can be nested using `/`. |
|
21
docs/articles/en/attributes/help-box.md
Normal file
21
docs/articles/en/attributes/help-box.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Help Box Attribute
|
||||
|
||||
Adds a note or warning above a field.
|
||||
|
||||
![img](../../../images/img-attribute-help-box.png)
|
||||
|
||||
```cs
|
||||
[HelpBox("Custom Info")]
|
||||
public float foo;
|
||||
|
||||
[HelpBox("Custom Warning", HelpBoxMessageType.Warning)]
|
||||
public Vector2 bar;
|
||||
|
||||
[HelpBox("Custom Error", HelpBoxMessageType.Error)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Message | The text to display inside the box. |
|
||||
| MessageType | The type of message. |
|
27
docs/articles/en/attributes/hide-if.md
Normal file
27
docs/articles/en/attributes/hide-if.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Hide If Attribute
|
||||
|
||||
Hides the member in the Inspector if the boolean value is true.
|
||||
|
||||
![img](../../../images/img-attribute-hide-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-hide-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool hide;
|
||||
|
||||
public bool Hide => hide;
|
||||
public bool IsHideTrue() => hide;
|
||||
|
||||
[HideIf("hide")]
|
||||
public int hideIfField;
|
||||
|
||||
[HideIf("Hide")]
|
||||
public int hideIfProperty;
|
||||
|
||||
[HideIf("IsHideTrue")]
|
||||
public int hideIfMethod;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Condition | The name of the field, property, or method used for the condition evaluation. |
|
12
docs/articles/en/attributes/hide-in-edit-mode.md
Normal file
12
docs/articles/en/attributes/hide-in-edit-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Hide In Edit Mode Attribute
|
||||
|
||||
Hides the field while in Edit Mode.
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-edit-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-edit-mode-player.png)
|
||||
|
||||
```cs
|
||||
[HideInEditMode]
|
||||
public float foo;
|
||||
```
|
12
docs/articles/en/attributes/hide-in-play-mode.md
Normal file
12
docs/articles/en/attributes/hide-in-play-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Hide In Play Mode Attribute
|
||||
|
||||
Hides the field while in Play Mode.
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-play-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-play-mode-player.png)
|
||||
|
||||
```cs
|
||||
[HideInPlayMode]
|
||||
public float foo;
|
||||
```
|
16
docs/articles/en/attributes/hide-label.md
Normal file
16
docs/articles/en/attributes/hide-label.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Hide Label Attribute
|
||||
|
||||
Hides the label of the field.
|
||||
|
||||
![img](../../../images/img-attribute-hide-label.png)
|
||||
|
||||
```cs
|
||||
[HideLabel]
|
||||
public float foo;
|
||||
|
||||
[HideLabel]
|
||||
public Vector3 bar;
|
||||
|
||||
[HideLabel]
|
||||
public GameObject baz;
|
||||
```
|
15
docs/articles/en/attributes/hide-script-field.md
Normal file
15
docs/articles/en/attributes/hide-script-field.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Hide Script Field Attribute
|
||||
|
||||
Hides the target script field.
|
||||
|
||||
![img](../../../images/img-attribute-hide-script-field.png)
|
||||
|
||||
```cs
|
||||
[HideScriptField]
|
||||
public class HideScriptFieldSample : MonoBehaviour
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
```
|
44
docs/articles/en/attributes/horizontal-group.md
Normal file
44
docs/articles/en/attributes/horizontal-group.md
Normal file
@ -0,0 +1,44 @@
|
||||
# Horizontal Attribute
|
||||
|
||||
Creates a group that displays multiple members horizontally.
|
||||
|
||||
![img](../../../images/img-attribute-horizontal-group.png)
|
||||
|
||||
```cs
|
||||
[HorizontalGroup("Group1")]
|
||||
public int a;
|
||||
|
||||
[HorizontalGroup("Group1")]
|
||||
public int b;
|
||||
|
||||
[HorizontalGroup("Group1")]
|
||||
public int c;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box1")]
|
||||
public float foo;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box1")]
|
||||
public GameObject baz;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box2")]
|
||||
public float alpha;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| GroupPath | Specifies the path of the group. Groups can be nested using `/`. |
|
23
docs/articles/en/attributes/horizontal-line.md
Normal file
23
docs/articles/en/attributes/horizontal-line.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Horizontal Line Attribute
|
||||
|
||||
Adds a horizontal line to the Inspector.
|
||||
|
||||
![img](../../../images/img-attribute-horizontal-line.png)
|
||||
|
||||
```cs
|
||||
[HorizontalLine]
|
||||
public float foo;
|
||||
|
||||
[HorizontalLine(1f, 0f, 0f)]
|
||||
public Vector2 bar;
|
||||
|
||||
[HorizontalLine(1f, 0.5f, 0f, 0.5f)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| r | Red component of the line color |
|
||||
| g | Green component of the line color |
|
||||
| b | Blue component of the line color |
|
||||
| a | Alpha value of the line color |
|
20
docs/articles/en/attributes/indent.md
Normal file
20
docs/articles/en/attributes/indent.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Indent Attribute
|
||||
|
||||
Adds an indent to the field in the Inspector.
|
||||
|
||||
![img](../../../images/img-attribute-indent.png)
|
||||
|
||||
```cs
|
||||
[Indent]
|
||||
public float foo;
|
||||
|
||||
[Indent(2)]
|
||||
public Vector2 bar;
|
||||
|
||||
[Indent(3)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Indent | Number of indents |
|
10
docs/articles/en/attributes/inline-editor.md
Normal file
10
docs/articles/en/attributes/inline-editor.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Inline Editor Attribute
|
||||
|
||||
Displays the Inspector of the target ScriptableObject or component inline, allowing for editing.
|
||||
|
||||
![img](../../../images/img-attribute-inline-editor.png)
|
||||
|
||||
```cs
|
||||
[InlineEditor]
|
||||
public SampleScriptableObject sample;
|
||||
```
|
30
docs/articles/en/attributes/label-text.md
Normal file
30
docs/articles/en/attributes/label-text.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Label Text Attribute
|
||||
|
||||
Overrides the label text of the field.
|
||||
|
||||
![img](../../../images/img-attribute-label-text.png)
|
||||
|
||||
```cs
|
||||
[LabelText("FOO!")]
|
||||
public float foo;
|
||||
|
||||
[LabelText("BAR!")]
|
||||
public Vector3 bar;
|
||||
|
||||
[LabelText("BAZ!")]
|
||||
public GameObject baz;
|
||||
|
||||
[Space]
|
||||
[LabelText("α")]
|
||||
public float alpha;
|
||||
|
||||
[LabelText("β")]
|
||||
public Vector3 beta;
|
||||
|
||||
[LabelText("γ")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Text | The text to display on the field label |
|
28
docs/articles/en/attributes/list-view-settings.md
Normal file
28
docs/articles/en/attributes/list-view-settings.md
Normal file
@ -0,0 +1,28 @@
|
||||
# List View Settings Attribute
|
||||
|
||||
Changes the display settings for collections. This attribute allows you to enhance the readability of rows, and create arrays where the element count/order cannot be changed from the Inspector.
|
||||
|
||||
![img](../../../images/img-attribute-list-view-settings.png)
|
||||
|
||||
```cs
|
||||
[ListViewSettings(ShowAlternatingRowBackgrounds = AlternatingRowBackground.All, ShowFoldoutHeader = false)]
|
||||
public int[] array1;
|
||||
|
||||
[ListViewSettings(Reorderable = false, ShowAddRemoveFooter = false, ShowBorder = false, ShowBoundCollectionSize = false)]
|
||||
public Vector3[] array2 = new Vector3[]
|
||||
{
|
||||
Vector3.zero,
|
||||
Vector3.one
|
||||
};
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| ShowAddRemoveFooter | Whether to display the footer for adding/removing elements |
|
||||
| ShowAlternatingRowBackgrounds | Whether to change the background color for every other row |
|
||||
| ShowBorder | Whether to display borders |
|
||||
| ShowBoundCollectionSize | Whether to display the field for changing the number of elements |
|
||||
| ShowFoldoutHeader | Whether to display the foldout header |
|
||||
| SelectionType | Selection settings for elements |
|
||||
| Reorderable | Whether elements can be reordered |
|
||||
| ReorderMode | Settings for displaying reordering |
|
11
docs/articles/en/attributes/on-inspector-destroy.md
Normal file
11
docs/articles/en/attributes/on-inspector-destroy.md
Normal file
@ -0,0 +1,11 @@
|
||||
# On Inspector Destroy Attribute
|
||||
|
||||
Executes a method when the Inspector is destroyed.
|
||||
|
||||
```cs
|
||||
[OnInspectorDestroy]
|
||||
void OnInspectorDestroy()
|
||||
{
|
||||
Debug.Log("Destroy");
|
||||
}
|
||||
```
|
11
docs/articles/en/attributes/on-inspector-disable.md
Normal file
11
docs/articles/en/attributes/on-inspector-disable.md
Normal file
@ -0,0 +1,11 @@
|
||||
# On Inspector Disable Attribute
|
||||
|
||||
Executes a method when the Inspector is disabled.
|
||||
|
||||
```cs
|
||||
[OnInspectorDisable]
|
||||
void OnInspectorDisable()
|
||||
{
|
||||
Debug.Log("Disable");
|
||||
}
|
||||
```
|
11
docs/articles/en/attributes/on-inspector-enable.md
Normal file
11
docs/articles/en/attributes/on-inspector-enable.md
Normal file
@ -0,0 +1,11 @@
|
||||
# On Inspector Enable Attribute
|
||||
|
||||
Executes a method when the Inspector is enabled.
|
||||
|
||||
```cs
|
||||
[OnInspectorEnable]
|
||||
void OnInspectorEnable()
|
||||
{
|
||||
Debug.Log("Enable");
|
||||
}
|
||||
```
|
17
docs/articles/en/attributes/on-value-changed.md
Normal file
17
docs/articles/en/attributes/on-value-changed.md
Normal file
@ -0,0 +1,17 @@
|
||||
# On Value Changed Attribute
|
||||
|
||||
Executes a method with the specified name when the value of the field changes.
|
||||
|
||||
```cs
|
||||
[OnValueChanged("OnValueChanged")]
|
||||
public int foo;
|
||||
|
||||
void OnValueChanged(int value)
|
||||
{
|
||||
Debug.Log(value);
|
||||
}
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| MethodName | The name of the method to be called when the value changes. |
|
20
docs/articles/en/attributes/order.md
Normal file
20
docs/articles/en/attributes/order.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Order Attribute
|
||||
|
||||
Changes the display order of the field. The default value of order is 0, and members are displayed in ascending order.
|
||||
|
||||
![img](../../../images/img-attribute-order.png)
|
||||
|
||||
```cs
|
||||
[Order(2)]
|
||||
public float foo;
|
||||
|
||||
[Order(1)]
|
||||
public Vector3 bar;
|
||||
|
||||
[Order(0)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Order | The display order of the member. |
|
19
docs/articles/en/attributes/read-only.md
Normal file
19
docs/articles/en/attributes/read-only.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Read Only Attribute
|
||||
|
||||
Makes the field uneditable.
|
||||
|
||||
![img](../../../images/img-attribute-read-only.png)
|
||||
|
||||
```cs
|
||||
[ReadOnly]
|
||||
public float field = 2.5f;
|
||||
|
||||
[ReadOnly]
|
||||
public int[] array = new int[5];
|
||||
|
||||
[ReadOnly]
|
||||
public SampleClass classField;
|
||||
|
||||
[ReadOnly]
|
||||
public SampleClass[] classArray = new SampleClass[3];
|
||||
```
|
17
docs/articles/en/attributes/required.md
Normal file
17
docs/articles/en/attributes/required.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Required Attribute
|
||||
|
||||
Displays a warning if the field does not have an object reference assigned.
|
||||
|
||||
![img](../../../images/img-attribute-required.png)
|
||||
|
||||
```cs
|
||||
[Required]
|
||||
public GameObject requiredField1;
|
||||
|
||||
[Required("Custom message")]
|
||||
public Material requiredField2;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Message | Text to display in the warning |
|
27
docs/articles/en/attributes/show-if.md
Normal file
27
docs/articles/en/attributes/show-if.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Show If Attribute
|
||||
|
||||
Displays in the Inspector only if the boolean value of the target member is true.
|
||||
|
||||
![img](../../../images/img-attribute-show-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-show-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool show;
|
||||
|
||||
public bool Show => show;
|
||||
public bool IsShowTrue() => show;
|
||||
|
||||
[ShowIf("show")]
|
||||
public int showIfField;
|
||||
|
||||
[ShowIf("Show")]
|
||||
public int showIfProperty;
|
||||
|
||||
[ShowIf("IsShowTrue")]
|
||||
public int showIfMethod;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Condition | The name of the field, property, or method used for condition checking |
|
19
docs/articles/en/attributes/show-in-inspector.md
Normal file
19
docs/articles/en/attributes/show-in-inspector.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Show In Inspector Attribute
|
||||
|
||||
Allows non-serialized fields or properties to be edited in the Inspector. Note that these values are not serialized, and changes are not saved.
|
||||
|
||||
![img](../../../images/img-attribute-show-in-inspector.png)
|
||||
|
||||
```cs
|
||||
[NonSerialized, ShowInInspector]
|
||||
public int field;
|
||||
|
||||
[NonSerialized, ShowInInspector]
|
||||
public SampleClass classField = new();
|
||||
|
||||
[ShowInInspector]
|
||||
public int Getter => 10;
|
||||
|
||||
[field: NonSerialized, ShowInInspector]
|
||||
public string Property { get; set; } = string.Empty;
|
||||
```
|
30
docs/articles/en/attributes/tab-group.md
Normal file
30
docs/articles/en/attributes/tab-group.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Tab Group Attribute
|
||||
|
||||
Creates a group that divides multiple members into tabs.
|
||||
|
||||
![img](../../../images/img-attribute-tab-group.png)
|
||||
|
||||
```cs
|
||||
[TabGroup("Group1", "Tab1")]
|
||||
public float foo;
|
||||
|
||||
[TabGroup("Group1", "Tab2")]
|
||||
public Vector3 bar;
|
||||
|
||||
[TabGroup("Group1", "Tab3")]
|
||||
public GameObject baz;
|
||||
|
||||
[TabGroup("Group1", "Tab1")]
|
||||
public float alpha;
|
||||
|
||||
[TabGroup("Group1", "Tab2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[TabGroup("Group1", "Tab3")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| GroupPath | Specifies the path of the group. Groups can be nested using `/`. |
|
||||
| TabName | Specifies the name of the tab to which the member belongs. |
|
22
docs/articles/en/attributes/title.md
Normal file
22
docs/articles/en/attributes/title.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Title Attribute
|
||||
|
||||
Displays a header with a separator line in the Inspector.
|
||||
|
||||
![img](../../../images/img-attribute-title.png)
|
||||
|
||||
```cs
|
||||
[Title("Title1")]
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
|
||||
[Title("Title2", "Subtitle")]
|
||||
public float alpha;
|
||||
public Vector3 beta;
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Title | Text to display in the header. |
|
||||
| Subtitle | Text displayed below the title in smaller font. |
|
28
docs/articles/en/attributes/validate-input.md
Normal file
28
docs/articles/en/attributes/validate-input.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Validate Input Attribute
|
||||
|
||||
Displays a warning if the value of the specified member is false.
|
||||
|
||||
![img](../../../images/img-attribute-validate-input.png)
|
||||
|
||||
```cs
|
||||
[ValidateInput("IsNotNull")]
|
||||
public GameObject obj;
|
||||
|
||||
[ValidateInput("IsZeroOrGreater", "foo must be 0 or greater.")]
|
||||
public int foo = -1;
|
||||
|
||||
static bool IsNotNull(GameObject go)
|
||||
{
|
||||
return go != null;
|
||||
}
|
||||
|
||||
static bool IsZeroOrGreater(int a)
|
||||
{
|
||||
return a >= 0;
|
||||
}
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
| - | - |
|
||||
| Condition | Name of the field, property, or method used for validation. |
|
||||
| Message | Text displayed in the warning. |
|
45
docs/articles/en/button-attribute.md
Normal file
45
docs/articles/en/button-attribute.md
Normal file
@ -0,0 +1,45 @@
|
||||
# Button Attribute
|
||||
|
||||
By adding the `[Button]` attribute to a method, you can display a button in the Inspector to execute the method.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
[Serializable]
|
||||
public sealed class Example
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
|
||||
public class ButtonAttributeExample : MonoBehaviour
|
||||
{
|
||||
[Button]
|
||||
public void Foo()
|
||||
{
|
||||
Debug.Log("Foo");
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(int parameter)
|
||||
{
|
||||
Debug.Log("Foo: " + parameter);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(Example parameter)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine();
|
||||
builder.Append("foo = ").AppendLine(parameter.foo.ToString());
|
||||
builder.Append("bar = ").AppendLine(parameter.bar.ToString());
|
||||
builder.Append("baz = ").Append(parameter.baz == null ? "Null" : parameter.baz.ToString());
|
||||
Debug.Log("Foo: " + builder.ToString());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-button.png)
|
15
docs/articles/en/comparison-with-other-libraries.md
Normal file
15
docs/articles/en/comparison-with-other-libraries.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Comparison with Other Libraries
|
||||
|
||||
Alchemy offers features equivalent to or surpassing those of other assets/libraries for editor extensions. Here's a comparison of Alchemy's features with other assets/libraries:
|
||||
|
||||
| | Alchemy | [Odin Inspector & Serializer](https://odininspector.com/) | [NaughtyAttributes](https://github.com/dbrizov/NaughtyAttributes) | [Tri Inspector](https://github.com/codewriter-packages/Tri-Inspector) | [Unity Editor Toolbox](https://github.com/arimger/Unity-Editor-Toolbox) |
|
||||
| - | - | - | - | - | - |
|
||||
| Open Source | ✔︎ | ❌ | ✔︎ | ✔︎ | ✔︎ |
|
||||
| Grouping Attributes | ✔︎ | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
|
||||
| Button Attribute | ✔︎ | ✔︎ | ✔︎ <br>(without arguments) | ✔︎ | ✔︎ <br>(without arguments) |
|
||||
| Editing NonSerialized Members | ✔︎ | ✔︎ | ❌ | ✔︎ | ❌ |
|
||||
| SerializeReference Support | ✔︎ | ✔︎ | ❌ | ✔︎ | ✔︎ |
|
||||
| Serialization Extension | ✔︎ <br>(requires partial) | ✔︎ <br>(inherit from dedicated types) | ❌ | ❌ | ❌ <br>(provides serializable types) |
|
||||
| UI Toolkit Support | ✔︎ | ✔︎ | ❌ | ✔︎ | ❌ |
|
||||
| EditorWindow Extensions | ✔︎ | ✔︎ | ❌ | ❌ | ❌ |
|
||||
| Hierarchy Extensions | ✔︎ | ❌ | ❌ | ❌ | ✔︎ |
|
48
docs/articles/en/creating-custom-attribute.md
Normal file
48
docs/articles/en/creating-custom-attribute.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Creating Custom Attributes
|
||||
|
||||
By using `AlchemyAttributeDrawer`, it is possible to create custom attributes that work within Alchemy. Here is an example demonstrating the implementation of `HelpBoxAttribute` and its corresponding drawer.
|
||||
|
||||
First, define the attribute to be added to fields or properties.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public sealed class HelpBoxAttribute : Attribute
|
||||
{
|
||||
public HelpBoxAttribute(string message, HelpBoxMessageType messageType = HelpBoxMessageType.Info)
|
||||
{
|
||||
Message = message;
|
||||
MessageType = messageType;
|
||||
}
|
||||
|
||||
public string Message { get; }
|
||||
public HelpBoxMessageType MessageType { get; }
|
||||
}
|
||||
```
|
||||
|
||||
Next, create the drawer corresponding to the defined attribute. Drawer scripts should be placed within the Editor folder.
|
||||
|
||||
```cs
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Editor;
|
||||
|
||||
[CustomAttributeDrawer(typeof(HelpBoxAttribute))]
|
||||
public sealed class HelpBoxDrawer : AlchemyAttributeDrawer
|
||||
{
|
||||
HelpBox helpBox;
|
||||
|
||||
public override void OnCreateElement()
|
||||
{
|
||||
var att = (HelpBoxAttribute)Attribute;
|
||||
helpBox = new HelpBox(att.Message, att.MessageType);
|
||||
|
||||
var parent = TargetElement.parent;
|
||||
parent.Insert(parent.IndexOf(TargetElement), helpBox);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Implement the `OnCreateElement()` method to add processing when creating the corresponding VisualElement for the member. Unlike regular `PropertyDrawer`s that override the drawing process, here we're adding post-processing after the creation of the Visual Element. This mechanism allows Alchemy to combine multiple drawers.
|
||||
|
||||
Additionally, make sure to add the `CustomAttributeDrawer` attribute to the defined drawer, with the type of the defined attribute as an argument. Alchemy uses this attribute to search for the necessary drawers for element rendering.
|
41
docs/articles/en/creating-custom-group-attribute.md
Normal file
41
docs/articles/en/creating-custom-group-attribute.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Creating Custom Group Attributes
|
||||
|
||||
By using `AlchemyGroupDrawer`, it is possible to create custom attributes for grouping fields. Here is an example demonstrating the implementation of `FoldoutGroupAttribute` and its corresponding drawer. (Some parts of the actual implementation have been omitted for the sake of explanation.)
|
||||
|
||||
First, define the attribute to be used for defining groups. This attribute must inherit from `PropertyGroupAttribute`.
|
||||
|
||||
```cs
|
||||
using Alchemy.Inspector;
|
||||
|
||||
public sealed class FoldoutGroupAttribute : PropertyGroupAttribute
|
||||
{
|
||||
public FoldoutGroupAttribute() : base() { }
|
||||
public FoldoutGroupAttribute(string groupPath) : base(groupPath) { }
|
||||
}
|
||||
```
|
||||
|
||||
Next, create the drawer corresponding to the defined attribute. Drawer scripts should be placed within the Editor folder.
|
||||
|
||||
```cs
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Editor;
|
||||
|
||||
[CustomGroupDrawer(typeof(FoldoutGroupAttribute))]
|
||||
public sealed class FoldoutGroupDrawer : AlchemyGroupDrawer
|
||||
{
|
||||
public override VisualElement CreateRootElement(string label)
|
||||
{
|
||||
var foldout = new Foldout()
|
||||
{
|
||||
style = {
|
||||
width = Length.Percent(100f)
|
||||
},
|
||||
text = label
|
||||
};
|
||||
|
||||
return foldout;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Implement the `CreateRootElement(string label)` method to create the root VisualElement for each group. Additionally, make sure to add the `CustomGroupDrawer` attribute to the defined drawer, with the type of the defined attribute as an argument. Alchemy uses this attribute to search for the necessary drawers for group rendering.
|
20
docs/articles/en/debugging-serialized-data.md
Normal file
20
docs/articles/en/debugging-serialized-data.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Debugging Serialized Data
|
||||
|
||||
By adding the `[ShowAlchemySerializationData]` attribute along with `[AlchemySerialize]`, you can inspect serialized data from the Inspector.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Alchemy.Serialization;
|
||||
|
||||
[AlchemySerialize]
|
||||
[ShowAlchemySerializationData]
|
||||
public partial class AlchemySerializationExample : MonoBehaviour
|
||||
{
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public Dictionary<string, GameObject> dictionary = new();
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-show-serialization-data.png)
|
19
docs/articles/en/decorating-hierarchy.md
Normal file
19
docs/articles/en/decorating-hierarchy.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Decorating Hierarchy
|
||||
|
||||
Alchemy allows you to decorate the Hierarchy by adding headers and separators, making it more visually appealing and easier to navigate.
|
||||
|
||||
![img](../../images/img-hierarchy.png)
|
||||
|
||||
To add headers and separators, navigate to the Hierarchy and click the "+" button, then choose `Alchemy > Header/Separator`.
|
||||
|
||||
![img](../../images/img-create-hierarchy-object.png)
|
||||
|
||||
These objects used for decoration in the Hierarchy are called `HierarchyObjects` in Alchemy. They are excluded from the build process. If any child objects exist, they will be detached using `transform.DetachChildren()` before deletion.
|
||||
|
||||
You can configure the handling of `HierarchyObjects` in the Alchemy settings under `Project Settings > Alchemy`.
|
||||
|
||||
![img](../../images/img-project-settings.png)
|
||||
|
||||
For individual `HierarchyObjects`, you can adjust their settings from the Inspector.
|
||||
|
||||
![img](../../images/img-hierarchy-header-inspector.png)
|
5
docs/articles/en/disable-default-editor.md
Normal file
5
docs/articles/en/disable-default-editor.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Disabling the Default Editor
|
||||
|
||||
By default, Alchemy uses its own editor class to handle the drawing of all types. However, to avoid conflicts with other libraries or assets, you can disable this behavior.
|
||||
|
||||
To disable the default editor, add `ALCHEMY_DISABLE_DEFAULT_EDITOR` to the `Scripting Define Symbols` field in `Project Settings > Player`. If you want to use Alchemy's features while this option is enabled, you'll need to define your own editor class that inherits from `AlchemyEditor`.
|
21
docs/articles/en/extending-alchemy-editor.md
Normal file
21
docs/articles/en/extending-alchemy-editor.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Extending AlchemyEditor
|
||||
|
||||
If a MonoBehaviour or ScriptableObject has its own custom editor class, Alchemy attributes won't work by default.
|
||||
To combine your custom editor extension with Alchemy, you need to inherit from `AlchemyEditor` class instead of the regular `Editor` class.
|
||||
|
||||
```cs
|
||||
using UnityEditor;
|
||||
using Alchemy.Editor;
|
||||
|
||||
[CustomEditor(typeof(Example))]
|
||||
public class EditorExample : AlchemyEditor
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
// Always call the base CreateInspectorGUI
|
||||
base.CreateInspectorGUI();
|
||||
|
||||
// Add your custom logic here
|
||||
}
|
||||
}
|
||||
```
|
85
docs/articles/en/group-attributes.md
Normal file
85
docs/articles/en/group-attributes.md
Normal file
@ -0,0 +1,85 @@
|
||||
# Group Attributes
|
||||
|
||||
Alchemy provides attributes to group fields together.
|
||||
|
||||
```cs
|
||||
using UnityEngine;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
public class GroupAttributesExample : MonoBehaviour
|
||||
{
|
||||
[FoldoutGroup("Foldout")]
|
||||
public int a;
|
||||
|
||||
[FoldoutGroup("Foldout")]
|
||||
public int b;
|
||||
|
||||
[FoldoutGroup("Foldout")]
|
||||
public int c;
|
||||
|
||||
[TabGroup("Tab", "Tab1")]
|
||||
public int x;
|
||||
|
||||
[TabGroup("Tab", "Tab2")]
|
||||
public string y;
|
||||
|
||||
[TabGroup("Tab", "Tab3")]
|
||||
public Vector3 z;
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-group-1.png)
|
||||
|
||||
Each group can be nested by using slashes.
|
||||
|
||||
```cs
|
||||
using UnityEngine;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
public class GroupAttributesExample : MonoBehaviour
|
||||
{
|
||||
[HorizontalGroup("Horizontal"), BoxGroup("Horizontal/Box1")]
|
||||
public float foo;
|
||||
|
||||
[HorizontalGroup("Horizontal"), BoxGroup("Horizontal/Box1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[HorizontalGroup("Horizontal"), BoxGroup("Horizontal/Box1")]
|
||||
public GameObject baz;
|
||||
|
||||
[HorizontalGroup("Horizontal"), BoxGroup("Horizontal/Box2")]
|
||||
public float alpha;
|
||||
|
||||
[HorizontalGroup("Horizontal"), BoxGroup("Horizontal/Box2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[HorizontalGroup("Horizontal"), BoxGroup("Horizontal/Box2")]
|
||||
public GameObject gamma;
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-group-2.png)
|
||||
|
||||
Additionally, you can add group attributes to a defined Serializable class to change how its members are displayed within corresponding groups.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
[Serializable]
|
||||
[BoxGroup]
|
||||
public sealed class Example
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
|
||||
public class GroupAttributeExample : MonoBehaviour
|
||||
{
|
||||
public Example example;
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-group-3.png)
|
9
docs/articles/en/hierarchy-toggles-and-icons.md
Normal file
9
docs/articles/en/hierarchy-toggles-and-icons.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Toggles and Icons
|
||||
|
||||
By integrating Alchemy, you can add toggles to the Hierarchy to switch objects between active and inactive states, as well as icons for each component.
|
||||
|
||||
![gif](../../images/gif-hierarchy-toggle.gif)
|
||||
|
||||
These features are disabled by default. You can configure Hierarchy display settings in `Project Settings > Alchemy`.
|
||||
|
||||
![img](../../images/img-project-settings.png)
|
28
docs/articles/en/inspector-extension-with-attributes.md
Normal file
28
docs/articles/en/inspector-extension-with-attributes.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Inspector Extension with Attributes
|
||||
|
||||
Alchemy allows you to extend the Inspector using attributes. To customize the display in the Inspector, you can add attributes to the fields of your class.
|
||||
|
||||
```cs
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Inspector; // Add Alchemy.Inspector namespace
|
||||
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[LabelText("Custom Label")]
|
||||
public float foo;
|
||||
|
||||
[HideLabel]
|
||||
public Vector3 bar;
|
||||
|
||||
[AssetsOnly]
|
||||
public GameObject baz;
|
||||
|
||||
[Title("Title")]
|
||||
[HelpBox("HelpBox", HelpBoxMessageType.Info)]
|
||||
[ReadOnly]
|
||||
public string message = "Read Only";
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-attributes-example.png)
|
40
docs/articles/en/installation.md
Normal file
40
docs/articles/en/installation.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Installation
|
||||
|
||||
Let's install Alchemy into your project to start using it.
|
||||
|
||||
### Requirements
|
||||
|
||||
* Unity 2021.2 or later (Unity 2022.1 or later recommended for serialization extensions)
|
||||
* Serialization 2.0 or later (if using serialization extensions)
|
||||
|
||||
### Install via Package Manager (Recommended)
|
||||
|
||||
You can install Alchemy via the Package Manager.
|
||||
|
||||
1. Open the Package Manager by navigating to Window > Package Manager.
|
||||
2. Click the "+" button and choose "Add package from git URL".
|
||||
3. Enter the following URL:
|
||||
|
||||
```text
|
||||
https://github.com/AnnulusGames/Alchemy.git?path=/Alchemy/Assets/Alchemy
|
||||
```
|
||||
|
||||
![img1](../../images/img-setup-1.png)
|
||||
|
||||
Alternatively, you can add the following line to the dependencies block in your Packages/manifest.json file:
|
||||
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"com.annulusgames.alchemy": "https://github.com/AnnulusGames/Alchemy.git?path=/Alchemy/Assets/Alchemy"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Install from unitypackage
|
||||
|
||||
You can also install Alchemy from a unitypackage file.
|
||||
|
||||
1. Go to Releases and navigate to the latest release.
|
||||
2. Download the unitypackage file.
|
||||
3. Open the file and import it into your project.
|
39
docs/articles/en/saving-editor-window-data.md
Normal file
39
docs/articles/en/saving-editor-window-data.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Saving EditorWindow Data
|
||||
|
||||
The data of an editor window created by inheriting from `AlchemyEditorWindow` is automatically saved in JSON format within the ProjectSettings folder of your project.
|
||||
|
||||
You can customize the saving/loading process and the destination path by overriding the `SaveWindowData()`, `LoadWindowData()`, and `GetWindowDataPath()` methods.
|
||||
|
||||
```cs
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Alchemy.Editor;
|
||||
|
||||
public class EditorWindowExample : AlchemyEditorWindow
|
||||
{
|
||||
[MenuItem("Window/Example")]
|
||||
static void Open()
|
||||
{
|
||||
var window = GetWindow<EditorWindowExample>("Example");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
protected override string GetWindowDataPath()
|
||||
{
|
||||
// Return the path where the data will be saved
|
||||
return ...
|
||||
}
|
||||
|
||||
protected override void LoadWindowData(string dataPath)
|
||||
{
|
||||
// Write the loading process here
|
||||
...
|
||||
}
|
||||
|
||||
protected override void SaveWindowData(string dataPath)
|
||||
{
|
||||
// Write the saving process here
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
21
docs/articles/en/serialization-callback.md
Normal file
21
docs/articles/en/serialization-callback.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Serialization Callbacks
|
||||
|
||||
When using the `[AlchemySerialize]` attribute, the Source Generator automatically implements `ISerializationCallbackReceiver`. Therefore, you cannot use `ISerializationCallbackReceiver` to add callbacks.
|
||||
|
||||
Instead, Alchemy provides an alternative interface called `IAlchemySerializationCallbackReceiver`. Please use this interface instead of `ISerializationCallbackReceiver` when using `[AlchemySerialize]`.
|
||||
|
||||
```cs
|
||||
[AlchemySerialize]
|
||||
public partial class AlchemySerializationSample : MonoBehaviour, IAlchemySerializationCallbackReceiver
|
||||
{
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
Debug.Log("OnAfterDeserialize");
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
Debug.Log("OnBeforeSerialize");
|
||||
}
|
||||
}
|
||||
```
|
49
docs/articles/en/serialization-extension.md
Normal file
49
docs/articles/en/serialization-extension.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Serialization Extension
|
||||
|
||||
If you want to edit types that Unity cannot serialize normally, such as Dictionary, you can serialize them using the `[AlchemySerialize]` attribute.
|
||||
|
||||
To use serialization extension, you need the [Unity.Serialization](https://docs.unity3d.com/Packages/com.unity.serialization@3.1/manual/index.html) package. Also, please note that reflection-based Unity.Serialization serialization may not work in AOT environments prior to Unity 2022.1. Please refer to the package manual for details.
|
||||
|
||||
Here is a sample using Alchemy's serialization extension to serialize various types and make them editable in the Inspector:
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Alchemy.Serialization; // Add Alchemy.Serialization namespace
|
||||
|
||||
[AlchemySerialize]
|
||||
public partial class AlchemySerializationExample : MonoBehaviour
|
||||
{
|
||||
// Add the [AlchemySerializeField] and [NonSerialized] attributes to the target field.
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public HashSet<GameObject> hashSet = new();
|
||||
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public Dictionary<string, GameObject> dictionary = new();
|
||||
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public (int, int) tuple;
|
||||
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public Vector3? nullable = null;
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-serialization-sample.png)
|
||||
|
||||
Currently, the following types can be edited in the Inspector:
|
||||
|
||||
- Primitive types
|
||||
- UnityEngine.Object
|
||||
- AnimationCurve
|
||||
- Gradient
|
||||
- Array
|
||||
- List<>
|
||||
- HashSet<>
|
||||
- Dictionary<,>
|
||||
- ValueTuple<>
|
||||
- Nullable<>
|
||||
- class/struct consisting of the above types
|
||||
|
||||
For technical details on serialization, please refer to [Alchemy's Serialization Process](alchemy-serialization-process.md).
|
40
docs/articles/en/serialize-reference.md
Normal file
40
docs/articles/en/serialize-reference.md
Normal file
@ -0,0 +1,40 @@
|
||||
# SerializeReference
|
||||
|
||||
Alchemy supports Unity's `[SerializeReference]`. By adding the `[SerializeReference]` attribute, you can edit interfaces or abstract classes in the Inspector.
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IExample { }
|
||||
|
||||
[Serializable]
|
||||
public sealed class ExampleA : IExample
|
||||
{
|
||||
public float alpha;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ExampleB : IExample
|
||||
{
|
||||
public Vector3 beta;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ExampleC : IExample
|
||||
{
|
||||
public GameObject gamma;
|
||||
}
|
||||
|
||||
public class SerializeReferenceExample : MonoBehaviour
|
||||
{
|
||||
[SerializeReference] public IExample example;
|
||||
[SerializeReference] public IExample[] exampleArray;
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-serialize-reference.png)
|
||||
|
||||
Interfaces and abstract classes are displayed as shown above, and you can select and create subclasses from the dropdown.
|
||||
|
||||
For more information about SerializeReference serialization, please refer to [Unity's official documentation](https://docs.unity3d.com/2020.3/ScriptReference/SerializeReference.html).
|
134
docs/articles/en/toc.yml
Normal file
134
docs/articles/en/toc.yml
Normal file
@ -0,0 +1,134 @@
|
||||
- name: Get Started
|
||||
- name: Alchemy Overview
|
||||
href: about.md
|
||||
- name: Installation
|
||||
href: installation.md
|
||||
|
||||
- name: Inspector
|
||||
- name: Inspector Extension with Attributes
|
||||
href: inspector-extension-with-attributes.md
|
||||
- name: Group Attributes
|
||||
href: group-attributes.md
|
||||
- name: Button Attribute
|
||||
href: button-attribute.md
|
||||
- name: SerializeReference
|
||||
href: serialize-reference.md
|
||||
- name: Attribute List
|
||||
items:
|
||||
- name: General
|
||||
- name: Assets Only
|
||||
href: attributes/assets-only.md
|
||||
- name: Button
|
||||
href: attributes/button.md
|
||||
- name: Disable Alchemy Editor
|
||||
href: attributes/disable-alchemy-editor.md
|
||||
- name: Hide Script Field
|
||||
href: attributes/hide-script-field.md
|
||||
- name: Indent
|
||||
href: attributes/indent.md
|
||||
- name: Inline Editor
|
||||
href: attributes/inline-editor.md
|
||||
- name: List View Settings
|
||||
href: attributes/list-view-settings.md
|
||||
- name: Order
|
||||
href: attributes/order.md
|
||||
- name: Read Only
|
||||
href: attributes/read-only.md
|
||||
- name: Show In Inspector
|
||||
href: attributes/show-in-inspector.md
|
||||
|
||||
- name: Conditionals
|
||||
- name: Disable If
|
||||
href: attributes/disable-if.md
|
||||
- name: Disable In Edit Mode
|
||||
href: attributes/disable-in-edit-mode.md
|
||||
- name: Disable In Play Mode
|
||||
href: attributes/disable-in-play-mode.md
|
||||
- name: Enable If
|
||||
href: attributes/enable-if.md
|
||||
- name: Hide If
|
||||
href: attributes/hide-if.md
|
||||
- name: Hide In Edit Mode
|
||||
href: attributes/hide-in-edit-mode.md
|
||||
- name: Hide In Play Mode
|
||||
href: attributes/hide-in-play-mode.md
|
||||
- name: Show If
|
||||
href: attributes/show-if.md
|
||||
|
||||
- name: Decoration
|
||||
- name: Blockquote
|
||||
href: attributes/blockquote.md
|
||||
- name: Help Box
|
||||
href: attributes/help-box.md
|
||||
- name: Hide Label
|
||||
href: attributes/hide-label.md
|
||||
- name: Horizontal Line
|
||||
href: attributes/horizontal-line.md
|
||||
- name: Label Text
|
||||
href: attributes/label-text.md
|
||||
- name: Title
|
||||
href: attributes/title.md
|
||||
|
||||
- name: Validation
|
||||
- name: Required
|
||||
href: attributes/required.md
|
||||
- name: Validate Input
|
||||
href: attributes/validate-input.md
|
||||
|
||||
- name: Events
|
||||
- name: On Inspector Destroy
|
||||
href: attributes/on-inspector-destroy.md
|
||||
- name: On Inspector Disable
|
||||
href: attributes/on-inspector-disable.md
|
||||
- name: On Inspector Enable
|
||||
href: attributes/on-inspector-enable.md
|
||||
- name: On Value Changed
|
||||
href: attributes/on-value-changed.md
|
||||
|
||||
- name: Groups
|
||||
- name: Box Group
|
||||
href: attributes/box-group.md
|
||||
- name: Foldout Group
|
||||
href: attributes/foldout-group.md
|
||||
- name: Group
|
||||
href: attributes/group.md
|
||||
- name: Horizontal Group
|
||||
href: attributes/horizontal-group.md
|
||||
- name: Tab Group
|
||||
href: attributes/tab-group.md
|
||||
|
||||
- name: Hierarchy
|
||||
- name: Toggles and Icons
|
||||
href: hierarchy-toggles-and-icons.md
|
||||
- name: Decorating Hierarchy
|
||||
href: decorating-hierarchy.md
|
||||
|
||||
- name: Editor Window
|
||||
- name: AlchemyEditorWindow
|
||||
href: alchemy-editor-window.md
|
||||
- name: Saving Editor Window Data
|
||||
href: saving-editor-window-data.md
|
||||
|
||||
- name: Serialization
|
||||
- name: Serialization Extension
|
||||
href: serialization-extension.md
|
||||
- name: Alchemy Serialization Process
|
||||
href: alchemy-serialization-process.md
|
||||
- name: Debugging Serialized Data
|
||||
href: debugging-serialized-data.md
|
||||
- name: Serialization Callback
|
||||
href: serialization-callback.md
|
||||
|
||||
- name: Extensions
|
||||
- name: Extending Alchemy Editor
|
||||
href: extending-alchemy-editor.md
|
||||
- name: Creating Custom Attribute
|
||||
href: creating-custom-attribute.md
|
||||
- name: Creating Custom Group Attribute
|
||||
href: creating-custom-group-attribute.md
|
||||
|
||||
- name: Others
|
||||
- name: Disable Default Editor
|
||||
href: disable-default-editor.md
|
||||
- name: Comparison with Other Libraries
|
||||
href: comparison-with-other-libraries.md
|
10
docs/articles/ja/about.md
Normal file
10
docs/articles/ja/about.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Alchemyとは
|
||||
|
||||
![header](../../images/header.png)
|
||||
|
||||
AlchemyはUnity向けの豊富なエディタ拡張の機能を提供するライブラリです。Inspectorを手軽に拡張するための30以上の属性が追加されるほか、Unity.Serializationパッケージと専用のSource Generatorを使用することで、通常のUnityではシリアル化できない型(`Dictionary`, `HashSet`, `Nullable`, `ValueTuple`, etc.)をシリアル化してInspectorから編集することを可能にします。
|
||||
|
||||
![img](../../images/img-v2.0.png)
|
||||
|
||||
またv2.0の新機能としてEditorWindow拡張とHierarchy拡張が追加されました。これらを用いることで、エディタでの開発フローを効率化するツールを簡単に作成できるようになります。
|
||||
|
53
docs/articles/ja/alchemy-editor-window.md
Normal file
53
docs/articles/ja/alchemy-editor-window.md
Normal file
@ -0,0 +1,53 @@
|
||||
# AlchemyEditorWindow
|
||||
|
||||
`EditorWindow`の代わりに`AlchemyEditorWindow`を継承することで、Alchemyの属性を用いてエディタウィンドウを作成することができるようになります。
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Editor;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
public class EditorWindowExample : AlchemyEditorWindow
|
||||
{
|
||||
[MenuItem("Window/Example")]
|
||||
static void Open()
|
||||
{
|
||||
var window = GetWindow<EditorWindowExample>("Example");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[HorizontalGroup]
|
||||
public class DatabaseItem
|
||||
{
|
||||
[LabelWidth(30f)]
|
||||
public float foo;
|
||||
|
||||
[LabelWidth(30f)]
|
||||
public Vector3 bar;
|
||||
|
||||
[LabelWidth(30f)]
|
||||
public GameObject baz;
|
||||
}
|
||||
|
||||
[ListViewSettings(ShowAlternatingRowBackgrounds = AlternatingRowBackground.All, ShowFoldoutHeader = false)]
|
||||
public List<DatabaseItem> items;
|
||||
|
||||
[Button, HorizontalGroup]
|
||||
public void Button1() { }
|
||||
|
||||
[Button, HorizontalGroup]
|
||||
public void Button2() { }
|
||||
|
||||
[Button, HorizontalGroup]
|
||||
public void Button3() { }
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-editor-window.png)
|
||||
|
||||
`AlchemyEditorWindow`を継承して作成したウィンドウのデータは、プロジェクトのProjectSettingsフォルダにjson形式で保存されます。詳細は[EditorWindowのデータを保存する](saving-editor-window-data.md)のページを参照してください。
|
80
docs/articles/ja/alchemy-serialization-process.md
Normal file
80
docs/articles/ja/alchemy-serialization-process.md
Normal file
@ -0,0 +1,80 @@
|
||||
# Alchemyのシリアル化プロセス
|
||||
|
||||
Alchemyでは、対象の型に`[AlchemySerialize]`属性を付加することで専用のSource Generatorが`ISerializationCallbackReceiver`を自動で実装します。この処理の中で`[AlchemySerializeField]`属性が付加されたフィールドを全て取得し、Unity.Serializationパッケージを用いてJson形式に変換します。ただし、UnityEngine.Objectのフィールドに関してはJson形式で扱うことができないため、単一のListに実体を保存しJsonにはそのindexを書き込みます。
|
||||
|
||||
例えば、以下のようなクラスがあったとします。
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Alchemy.Serialization;
|
||||
|
||||
[AlchemySerialize]
|
||||
public partial class AlchemySerializationExample : MonoBehaviour
|
||||
{
|
||||
[AlchemySerializeField, NonSerialized]
|
||||
public Dictionary<string, GameObject> dictionary = new();
|
||||
}
|
||||
```
|
||||
|
||||
これに対し、Alchemyは以下のようなコードを生成します。
|
||||
|
||||
```cs
|
||||
partial class AlchemySerializationExample : global::UnityEngine.ISerializationCallbackReceiver
|
||||
{
|
||||
[global::System.Serializable]
|
||||
sealed class AlchemySerializationData
|
||||
{
|
||||
[global::System.Serializable]
|
||||
public sealed class Item
|
||||
{
|
||||
[global::UnityEngine.HideInInspector] public bool isCreated;
|
||||
[global::UnityEngine.TextArea] public string data;
|
||||
}
|
||||
|
||||
public Item dictionary = new();
|
||||
|
||||
[global::UnityEngine.SerializeField] private global::System.Collections.Generic.List<UnityEngine.Object> unityObjectReferences = new();
|
||||
|
||||
public global::System.Collections.Generic.IList<UnityEngine.Object> UnityObjectReferences => unityObjectReferences;
|
||||
}
|
||||
|
||||
[global::UnityEngine.HideInInspector, global::UnityEngine.SerializeField] private AlchemySerializationData alchemySerializationData = new();
|
||||
|
||||
void global::UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
if (this is global::Alchemy.Serialization.IAlchemySerializationCallbackReceiver receiver) receiver.OnBeforeSerialize();
|
||||
alchemySerializationData.UnityObjectReferences.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
alchemySerializationData.dictionary.data = global::Alchemy.Serialization.Internal.SerializationHelper.ToJson(this.dictionary , alchemySerializationData.UnityObjectReferences);
|
||||
alchemySerializationData.dictionary.isCreated = true;
|
||||
}
|
||||
catch (global::System.Exception ex)
|
||||
{
|
||||
global::UnityEngine.Debug.LogException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void global::UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (alchemySerializationData.dictionary.isCreated)
|
||||
{
|
||||
this.dictionary = global::Alchemy.Serialization.Internal.SerializationHelper.FromJson<System.Collections.Generic.Dictionary<string, UnityEngine.GameObject>>(alchemySerializationData.dictionary.data, alchemySerializationData.UnityObjectReferences);
|
||||
}
|
||||
}
|
||||
catch (global::System.Exception ex)
|
||||
{
|
||||
global::UnityEngine.Debug.LogException(ex);
|
||||
}
|
||||
|
||||
if (this is global::Alchemy.Serialization.IAlchemySerializationCallbackReceiver receiver) receiver.OnAfterDeserialize();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
このような手法を取っているため`[AlchemySerializeField]`を使用するとシリアライズ/デシリアライズにかかる処理負荷が増加します。そのため可能な限り`[AlchemySerializeField]`の使用を避けることが推奨されます。
|
13
docs/articles/ja/attributes/assets-only.md
Normal file
13
docs/articles/ja/attributes/assets-only.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Assets Only Attribute
|
||||
|
||||
オブジェクトのフィールドに入力可能な参照をアセットに限定します。
|
||||
|
||||
![img](../../../images/img-attribute-assets-only.png)
|
||||
|
||||
```cs
|
||||
[AssetsOnly]
|
||||
public Object asset1;
|
||||
|
||||
[AssetsOnly]
|
||||
public GameObject asset2;
|
||||
```
|
14
docs/articles/ja/attributes/blockquote.md
Normal file
14
docs/articles/ja/attributes/blockquote.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Blockquote Attribute
|
||||
|
||||
Inspector上に引用句を表示します。
|
||||
|
||||
![img](../../../images/img-attribute-blockquote.png)
|
||||
|
||||
```cs
|
||||
[Blockquote("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")]
|
||||
public float foo;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Text | 引用句に表示するテキスト |
|
29
docs/articles/ja/attributes/box-group.md
Normal file
29
docs/articles/ja/attributes/box-group.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Box Group Attribute
|
||||
|
||||
複数のメンバーをボックスにまとめて表示するグループを作成します。
|
||||
|
||||
![img](../../../images/img-attribute-box-group.png)
|
||||
|
||||
```cs
|
||||
[BoxGroup("Group1")]
|
||||
public float foo;
|
||||
|
||||
[BoxGroup("Group1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[BoxGroup("Group1")]
|
||||
public GameObject baz;
|
||||
|
||||
[BoxGroup("Group1/Group2")]
|
||||
public float alpha;
|
||||
|
||||
[BoxGroup("Group1/Group2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[BoxGroup("Group1/Group2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| GroupPath | グループのパスを指定します。グループは`/`で区切ることでネストすることが可能です。 |
|
30
docs/articles/ja/attributes/button.md
Normal file
30
docs/articles/ja/attributes/button.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Button Attribute
|
||||
|
||||
メソッドを実行可能なボタンをInspectorに表示します。メソッドが引数を持つ場合には、引数を入力可能なフィールドが追加されます。
|
||||
|
||||
![img](../../../images/img-attribute-button.png)
|
||||
|
||||
```cs
|
||||
[Button]
|
||||
public void Foo()
|
||||
{
|
||||
Debug.Log("Foo");
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(int parameter)
|
||||
{
|
||||
Debug.Log("Foo: " + parameter);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(SampleClass parameter)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine();
|
||||
builder.Append("foo = ").AppendLine(parameter.foo.ToString());
|
||||
builder.Append("bar = ").AppendLine(parameter.bar.ToString());
|
||||
builder.Append("baz = ").Append(parameter.baz == null ? "Null" : parameter.baz.ToString());
|
||||
Debug.Log("Foo: " + builder.ToString());
|
||||
}
|
||||
```
|
15
docs/articles/ja/attributes/disable-alchemy-editor.md
Normal file
15
docs/articles/ja/attributes/disable-alchemy-editor.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Disable Alchemy Editor Attribute
|
||||
|
||||
対象のクラスのAlchemyEditorを無効化し、デフォルトのInspectorを使用して描画します。フィールドにこの属性を追加した場合、そのフィールドのみをデフォルトのPropertyFieldを用いて描画するように変更します。
|
||||
|
||||
![img](../../../images/img-attribute-disable-alchemy-editor.png)
|
||||
|
||||
```cs
|
||||
[DisableAlchemyEditor]
|
||||
public class DisableAlchemyEditorExample : MonoBehaviour
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
```
|
27
docs/articles/ja/attributes/disable-if.md
Normal file
27
docs/articles/ja/attributes/disable-if.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Disable If Attribute
|
||||
|
||||
対象のメンバーのbool値がtrueの場合、フィールドが編集不可能になります。
|
||||
|
||||
![img](../../../images/img-attribute-disable-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-disable-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool isDisabled;
|
||||
|
||||
public bool IsDisabled => isDisabled;
|
||||
public bool IsDisabledMethod() => isDisabled;
|
||||
|
||||
[DisableIf("isDisabled")]
|
||||
public int disableIfField;
|
||||
|
||||
[DisableIf("IsDisabled")]
|
||||
public int disableIfProperty;
|
||||
|
||||
[DisableIf("IsDisabledMethod")]
|
||||
public int disableIfMethod;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Condition | 条件の判定に使用するフィールド、プロパティまたはメソッドの名前 |
|
12
docs/articles/ja/attributes/disable-in-edit-mode.md
Normal file
12
docs/articles/ja/attributes/disable-in-edit-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Disable In Edit Mode Attribute
|
||||
|
||||
Edit Mode中はフィールドが編集不可能になります。
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-edit-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-edit-mode-player.png)
|
||||
|
||||
```cs
|
||||
[DisableInEditMode]
|
||||
public float foo;
|
||||
```
|
12
docs/articles/ja/attributes/disable-in-play-mode.md
Normal file
12
docs/articles/ja/attributes/disable-in-play-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Disable In Play Mode Attribute
|
||||
|
||||
Play Mode中はフィールドが編集不可能になります。
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-play-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-disable-in-play-mode-player.png)
|
||||
|
||||
```cs
|
||||
[DisableInPlayMode]
|
||||
public float foo;
|
||||
```
|
27
docs/articles/ja/attributes/enable-if.md
Normal file
27
docs/articles/ja/attributes/enable-if.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Enable If Attribute
|
||||
|
||||
対象のメンバーのbool値がtrueの場合にのみフィールドを編集可能になります。
|
||||
|
||||
![img](../../../images/img-attribute-enable-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-enable-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool isEnabled;
|
||||
|
||||
public bool IsEnabled => isEnabled;
|
||||
public bool IsEnabledMethod() => isEnabled;
|
||||
|
||||
[EnableIf("isEnabled")]
|
||||
public int enableIfField;
|
||||
|
||||
[EnableIf("IsEnabled")]
|
||||
public int enableIfProperty;
|
||||
|
||||
[EnableIf("IsEnabledMethod")]
|
||||
public int enableIfMethod;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Condition | 条件の判定に使用するフィールド、プロパティまたはメソッドの名前 |
|
29
docs/articles/ja/attributes/foldout-group.md
Normal file
29
docs/articles/ja/attributes/foldout-group.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Foldout Group Attribute
|
||||
|
||||
複数のメンバーを折りたたみ可能なグループを作成します。
|
||||
|
||||
![img](../../../images/img-attribute-foldout-group.png)
|
||||
|
||||
```cs
|
||||
[FoldoutGroup("Group1")]
|
||||
public float foo;
|
||||
|
||||
[FoldoutGroup("Group1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[FoldoutGroup("Group1")]
|
||||
public GameObject baz;
|
||||
|
||||
[FoldoutGroup("Group2")]
|
||||
public float alpha;
|
||||
|
||||
[FoldoutGroup("Group2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[FoldoutGroup("Group2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| GroupPath | グループのパスを指定します。グループは`/`で区切ることでネストすることが可能です。 |
|
29
docs/articles/ja/attributes/group.md
Normal file
29
docs/articles/ja/attributes/group.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Group Attribute
|
||||
|
||||
複数のメンバーをまとめて表示するグループを作成します。
|
||||
|
||||
![img](../../../images/img-attribute-group.png)
|
||||
|
||||
```cs
|
||||
[Group("Group1")]
|
||||
public float foo;
|
||||
|
||||
[Group("Group1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[Group("Group1")]
|
||||
public GameObject baz;
|
||||
|
||||
[Group("Group2")]
|
||||
public float alpha;
|
||||
|
||||
[Group("Group2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[Group("Group2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| GroupPath | グループのパスを指定します。グループは`/`で区切ることでネストすることが可能です。 |
|
21
docs/articles/ja/attributes/help-box.md
Normal file
21
docs/articles/ja/attributes/help-box.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Help Box Attribute
|
||||
|
||||
フィールドの上にメモや警告を追加します。
|
||||
|
||||
![img](../../../images/img-attribute-help-box.png)
|
||||
|
||||
```cs
|
||||
[HelpBox("Custom Info")]
|
||||
public float foo;
|
||||
|
||||
[HelpBox("Custom Warning", HelpBoxMessageType.Warning)]
|
||||
public Vector2 bar;
|
||||
|
||||
[HelpBox("Custom Error", HelpBoxMessageType.Error)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Message | ボックス内に表示するテキスト |
|
||||
| MessageType | メッセージの種類 |
|
28
docs/articles/ja/attributes/hide-if.md
Normal file
28
docs/articles/ja/attributes/hide-if.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Hide If Attribute
|
||||
|
||||
対象のメンバーのbool値がtrueの場合はInspectorに表示されなくなります。
|
||||
|
||||
![img](../../../images/img-attribute-hide-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-hide-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool hide;
|
||||
|
||||
public bool Hide => hide;
|
||||
public bool IsHideTrue() => hide;
|
||||
|
||||
[HideIf("hide")]
|
||||
public int hideIfField;
|
||||
|
||||
[HideIf("Hide")]
|
||||
public int hideIfProperty;
|
||||
|
||||
[HideIf("IsHideTrue")]
|
||||
public int hideIfMethod;
|
||||
```
|
||||
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Condition | 条件の判定に使用するフィールド、プロパティまたはメソッドの名前 |
|
12
docs/articles/ja/attributes/hide-in-edit-mode.md
Normal file
12
docs/articles/ja/attributes/hide-in-edit-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Hide In Edit Mode Attribute
|
||||
|
||||
Edit Mode中はフィールドが非表示になります。
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-edit-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-edit-mode-player.png)
|
||||
|
||||
```cs
|
||||
[HideInEditMode]
|
||||
public float foo;
|
||||
```
|
12
docs/articles/ja/attributes/hide-in-play-mode.md
Normal file
12
docs/articles/ja/attributes/hide-in-play-mode.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Hide In Play Mode Attribute
|
||||
|
||||
Play Mode中はフィールドが非表示になります。
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-play-mode-editor.png)
|
||||
|
||||
![img](../../../images/img-attribute-hide-in-play-mode-player.png)
|
||||
|
||||
```cs
|
||||
[HideInPlayMode]
|
||||
public float foo;
|
||||
```
|
16
docs/articles/ja/attributes/hide-label.md
Normal file
16
docs/articles/ja/attributes/hide-label.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Hide Label Attribute
|
||||
|
||||
フィールドのラベルを非表示にします。
|
||||
|
||||
![img](../../../images/img-attribute-hide-label.png)
|
||||
|
||||
```cs
|
||||
[HideLabel]
|
||||
public float foo;
|
||||
|
||||
[HideLabel]
|
||||
public Vector3 bar;
|
||||
|
||||
[HideLabel]
|
||||
public GameObject baz;
|
||||
```
|
15
docs/articles/ja/attributes/hide-script-field.md
Normal file
15
docs/articles/ja/attributes/hide-script-field.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Hide Script Field Attribute
|
||||
|
||||
対象のScriptフィールドを非表示にします。
|
||||
|
||||
![img](../../../images/img-attribute-hide-script-field.png)
|
||||
|
||||
```cs
|
||||
[HideScriptField]
|
||||
public class HideScriptFieldSample : MonoBehaviour
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
```
|
44
docs/articles/ja/attributes/horizontal-group.md
Normal file
44
docs/articles/ja/attributes/horizontal-group.md
Normal file
@ -0,0 +1,44 @@
|
||||
# Horizontal Attribute
|
||||
|
||||
複数のメンバーを水平方向に並べて表示するグループを作成します。
|
||||
|
||||
![img](../../../images/img-attribute-horizontal-group.png)
|
||||
|
||||
```cs
|
||||
[HorizontalGroup("Group1")]
|
||||
public int a;
|
||||
|
||||
[HorizontalGroup("Group1")]
|
||||
public int b;
|
||||
|
||||
[HorizontalGroup("Group1")]
|
||||
public int c;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box1")]
|
||||
public float foo;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box1")]
|
||||
public Vector3 bar;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box1")]
|
||||
public GameObject baz;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box2")]
|
||||
public float alpha;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[HorizontalGroup("Group2")]
|
||||
[BoxGroup("Group2/Box2")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| GroupPath | グループのパスを指定します。グループは`/`で区切ることでネストすることが可能です。 |
|
23
docs/articles/ja/attributes/horizontal-line.md
Normal file
23
docs/articles/ja/attributes/horizontal-line.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Horizontal Line Attribute
|
||||
|
||||
Inspectorに仕切り線を追加します。
|
||||
|
||||
![img](../../../images/img-attribute-horizontal-line.png)
|
||||
|
||||
```cs
|
||||
[HorizontalLine]
|
||||
public float foo;
|
||||
|
||||
[HorizontalLine(1f, 0f, 0f)]
|
||||
public Vector2 bar;
|
||||
|
||||
[HorizontalLine(1f, 0.5f, 0f, 0.5f)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| r | 線の色の赤成分 |
|
||||
| g | 線の色の緑成分 |
|
||||
| b | 線の色の青成分 |
|
||||
| a | 線の色のアルファ値 |
|
20
docs/articles/ja/attributes/indent.md
Normal file
20
docs/articles/ja/attributes/indent.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Indent Attribute
|
||||
|
||||
フィールドにインデントを追加します。
|
||||
|
||||
![img](../../../images/img-attribute-indent.png)
|
||||
|
||||
```cs
|
||||
[Indent]
|
||||
public float foo;
|
||||
|
||||
[Indent(2)]
|
||||
public Vector2 bar;
|
||||
|
||||
[Indent(3)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Indent | インデントの数 |
|
10
docs/articles/ja/attributes/inline-editor.md
Normal file
10
docs/articles/ja/attributes/inline-editor.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Inline Editor Attribute
|
||||
|
||||
対象のScriptableObjectやコンポーネントのInspectorをインラインで表示し、編集が可能になります。
|
||||
|
||||
![img](../../../images/img-attribute-inline-editor.png)
|
||||
|
||||
```cs
|
||||
[InlineEditor]
|
||||
public SampleScriptableObject sample;
|
||||
```
|
30
docs/articles/ja/attributes/label-text.md
Normal file
30
docs/articles/ja/attributes/label-text.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Label Text Attribute
|
||||
|
||||
フィールドのラベルのテキストを上書きします。
|
||||
|
||||
![img](../../../images/img-attribute-label-text.png)
|
||||
|
||||
```cs
|
||||
[LabelText("FOO!")]
|
||||
public float foo;
|
||||
|
||||
[LabelText("BAR!")]
|
||||
public Vector3 bar;
|
||||
|
||||
[LabelText("BAZ!")]
|
||||
public GameObject baz;
|
||||
|
||||
[Space]
|
||||
[LabelText("α")]
|
||||
public float alpha;
|
||||
|
||||
[LabelText("β")]
|
||||
public Vector3 beta;
|
||||
|
||||
[LabelText("γ")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Text | フィールドのラベルに表示するテキスト |
|
28
docs/articles/ja/attributes/list-view-settings.md
Normal file
28
docs/articles/ja/attributes/list-view-settings.md
Normal file
@ -0,0 +1,28 @@
|
||||
# List View Settings Attribute
|
||||
|
||||
コレクションの表示に関する設定を変更します。この属性を用いることで行を見やすくしたり、要素数/要素順をInspectorから変更不可能な配列を作成したりすることが可能になります。
|
||||
|
||||
![img](../../../images/img-attribute-list-view-settings.png)
|
||||
|
||||
```cs
|
||||
[ListViewSettings(ShowAlternatingRowBackgrounds = AlternatingRowBackground.All, ShowFoldoutHeader = false)]
|
||||
public int[] array1;
|
||||
|
||||
[ListViewSettings(Reorderable = false, ShowAddRemoveFooter = false, ShowBorder = false, ShowBoundCollectionSize = false)]
|
||||
public Vector3[] array2 = new Vector3[]
|
||||
{
|
||||
Vector3.zero,
|
||||
Vector3.one
|
||||
};
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| ShowAddRemoveFooter | 要素の追加/削除を行うフッターを表示するか |
|
||||
| ShowAlternatingRowBackgrounds | 一行ごとに背景色を変更するかどうか |
|
||||
| ShowBorder | 境界線を表示するか |
|
||||
| ShowBoundCollectionSize | 要素数を変更するフィールドを表示するか |
|
||||
| ShowFoldoutHeader | 折りたたみ可能なヘッダーを表示するか |
|
||||
| SelectionType | 要素の選択に関する設定 |
|
||||
| Reorderable | 要素を並び替え可能か |
|
||||
| ReorderMode | 並び替えの表示に関する設定 |
|
11
docs/articles/ja/attributes/on-inspector-destroy.md
Normal file
11
docs/articles/ja/attributes/on-inspector-destroy.md
Normal file
@ -0,0 +1,11 @@
|
||||
# On Inspector Destroy Attribute
|
||||
|
||||
Inspectorが破棄された際にメソッドを実行します。
|
||||
|
||||
```cs
|
||||
[OnInspectorDestroy]
|
||||
void OnInspectorDestroy()
|
||||
{
|
||||
Debug.Log("Destroy");
|
||||
}
|
||||
```
|
11
docs/articles/ja/attributes/on-inspector-disable.md
Normal file
11
docs/articles/ja/attributes/on-inspector-disable.md
Normal file
@ -0,0 +1,11 @@
|
||||
# On Inspector Disable Attribute
|
||||
|
||||
Inspectorが無効化された際にメソッドを実行します。
|
||||
|
||||
```cs
|
||||
[OnInspectorDisable]
|
||||
void OnInspectorDisable()
|
||||
{
|
||||
Debug.Log("Disable");
|
||||
}
|
||||
```
|
11
docs/articles/ja/attributes/on-inspector-enable.md
Normal file
11
docs/articles/ja/attributes/on-inspector-enable.md
Normal file
@ -0,0 +1,11 @@
|
||||
# On Inspector Enable Attribute
|
||||
|
||||
Inspectorが有効化された際にメソッドを実行します。
|
||||
|
||||
```cs
|
||||
[OnInspectorEnable]
|
||||
void OnInspectorEnable()
|
||||
{
|
||||
Debug.Log("Enable");
|
||||
}
|
||||
```
|
17
docs/articles/ja/attributes/on-value-changed.md
Normal file
17
docs/articles/ja/attributes/on-value-changed.md
Normal file
@ -0,0 +1,17 @@
|
||||
# On Value Changed Attribute
|
||||
|
||||
フィールドの値が変更された際に、指定された名前のメソッドを実行します。
|
||||
|
||||
```cs
|
||||
[OnValueChanged("OnValueChanged")]
|
||||
public int foo;
|
||||
|
||||
void OnValueChanged(int value)
|
||||
{
|
||||
Debug.Log(value);
|
||||
}
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| MethodName | 値の変更時に呼ばれるメソッドの名前 |
|
20
docs/articles/ja/attributes/order.md
Normal file
20
docs/articles/ja/attributes/order.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Order Attribute
|
||||
|
||||
フィールドの表示順を変更します。Orderのデフォルト値は0で、メンバーは昇順に表示されます。
|
||||
|
||||
![img](../../../images/img-attribute-order.png)
|
||||
|
||||
```cs
|
||||
[Order(2)]
|
||||
public float foo;
|
||||
|
||||
[Order(1)]
|
||||
public Vector3 bar;
|
||||
|
||||
[Order(0)]
|
||||
public GameObject baz;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Order | メンバーの表示順 |
|
19
docs/articles/ja/attributes/read-only.md
Normal file
19
docs/articles/ja/attributes/read-only.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Read Only Attribute
|
||||
|
||||
フィールドを編集不可能にします。
|
||||
|
||||
![img](../../../images/img-attribute-read-only.png)
|
||||
|
||||
```cs
|
||||
[ReadOnly]
|
||||
public float field = 2.5f;
|
||||
|
||||
[ReadOnly]
|
||||
public int[] array = new int[5];
|
||||
|
||||
[ReadOnly]
|
||||
public SampleClass classField;
|
||||
|
||||
[ReadOnly]
|
||||
public SampleClass[] classArray = new SampleClass[3];
|
||||
```
|
17
docs/articles/ja/attributes/required.md
Normal file
17
docs/articles/ja/attributes/required.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Required Attribute
|
||||
|
||||
フィールドにオブジェクトの参照が割り当てられていない場合に警告を表示します。
|
||||
|
||||
![img](../../../images/img-attribute-required.png)
|
||||
|
||||
```cs
|
||||
[Required]
|
||||
public GameObject requiredField1;
|
||||
|
||||
[Required("Custom message")]
|
||||
public Material requiredField2;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Message | 警告に表示するテキスト |
|
28
docs/articles/ja/attributes/show-if.md
Normal file
28
docs/articles/ja/attributes/show-if.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Show If Attribute
|
||||
|
||||
対象のメンバーのbool値がtrueの場合にのみInspectorに表示されます。
|
||||
|
||||
![img](../../../images/img-attribute-show-if-false.png)
|
||||
|
||||
![img](../../../images/img-attribute-show-if-true.png)
|
||||
|
||||
```cs
|
||||
public bool show;
|
||||
|
||||
public bool Show => show;
|
||||
public bool IsShowTrue() => show;
|
||||
|
||||
[ShowIf("show")]
|
||||
public int showIfField;
|
||||
|
||||
[ShowIf("Show")]
|
||||
public int showIfProperty;
|
||||
|
||||
[ShowIf("IsShowTrue")]
|
||||
public int showIfMethod;
|
||||
```
|
||||
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Condition | 条件の判定に使用するフィールド、プロパティまたはメソッドの名前 |
|
19
docs/articles/ja/attributes/show-in-inspector.md
Normal file
19
docs/articles/ja/attributes/show-in-inspector.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Show In Inspector Attribute
|
||||
|
||||
シリアライズされていないフィールドやプロパティをInspectorから編集可能にします。これらの値はシリアライズされず、変更は保存されないことに留意してください。
|
||||
|
||||
![img](../../../images/img-attribute-show-in-inspector.png)
|
||||
|
||||
```cs
|
||||
[NonSerialized, ShowInInspector]
|
||||
public int field;
|
||||
|
||||
[NonSerialized, ShowInInspector]
|
||||
public SampleClass classField = new();
|
||||
|
||||
[ShowInInspector]
|
||||
public int Getter => 10;
|
||||
|
||||
[field: NonSerialized, ShowInInspector]
|
||||
public string Property { get; set; } = string.Empty;
|
||||
```
|
30
docs/articles/ja/attributes/tab-group.md
Normal file
30
docs/articles/ja/attributes/tab-group.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Tab Group Attribute
|
||||
|
||||
複数のメンバーをタブに分割するグループを作成します。
|
||||
|
||||
![img](../../../images/img-attribute-tab-group.png)
|
||||
|
||||
```cs
|
||||
[TabGroup("Group1", "Tab1")]
|
||||
public float foo;
|
||||
|
||||
[TabGroup("Group1", "Tab2")]
|
||||
public Vector3 bar;
|
||||
|
||||
[TabGroup("Group1", "Tab3")]
|
||||
public GameObject baz;
|
||||
|
||||
[TabGroup("Group1", "Tab1")]
|
||||
public float alpha;
|
||||
|
||||
[TabGroup("Group1", "Tab2")]
|
||||
public Vector3 beta;
|
||||
|
||||
[TabGroup("Group1", "Tab3")]
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| GroupPath | グループのパスを指定します。グループは`/`で区切ることでネストすることが可能です。 |
|
||||
| TabName | メンバーが所属するタブの名前を指定します。 |
|
22
docs/articles/ja/attributes/title.md
Normal file
22
docs/articles/ja/attributes/title.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Title Attribute
|
||||
|
||||
Inspector上に区切り線付きのヘッダーを表示します。
|
||||
|
||||
![img](../../../images/img-attribute-title.png)
|
||||
|
||||
```cs
|
||||
[Title("Title1")]
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
|
||||
[Title("Title2", "Subtitle")]
|
||||
public float alpha;
|
||||
public Vector3 beta;
|
||||
public GameObject gamma;
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Title | ヘッダーに表示するテキスト |
|
||||
| Subtitle | タイトルの下に小さく表示されるテキスト |
|
28
docs/articles/ja/attributes/validate-input.md
Normal file
28
docs/articles/ja/attributes/validate-input.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Validate Input Attribute
|
||||
|
||||
指定された名前のメンバーの値がfalseである場合に警告を表示します。
|
||||
|
||||
![img](../../../images/img-attribute-validate-input.png)
|
||||
|
||||
```cs
|
||||
[ValidateInput("IsNotNull")]
|
||||
public GameObject obj;
|
||||
|
||||
[ValidateInput("IsZeroOrGreater", "foo must be 0 or greater.")]
|
||||
public int foo = -1;
|
||||
|
||||
static bool IsNotNull(GameObject go)
|
||||
{
|
||||
return go != null;
|
||||
}
|
||||
|
||||
static bool IsZeroOrGreater(int a)
|
||||
{
|
||||
return a >= 0;
|
||||
}
|
||||
```
|
||||
|
||||
| パラメータ | 説明 |
|
||||
| - | - |
|
||||
| Condition | 値の検証に使用するフィールド、プロパティまたはメソッドの名前 |
|
||||
| Message | 警告に表示するテキスト |
|
46
docs/articles/ja/button-attribute.md
Normal file
46
docs/articles/ja/button-attribute.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Button属性
|
||||
|
||||
メソッドに`[Button]`属性を追加することで、Inspector上にメソッドを実行するボタンを表示できます。
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Alchemy.Inspector;
|
||||
|
||||
[Serializable]
|
||||
public sealed class Example
|
||||
{
|
||||
public float foo;
|
||||
public Vector3 bar;
|
||||
public GameObject baz;
|
||||
}
|
||||
|
||||
public class ButtonAttributeExample : MonoBehaviour
|
||||
{
|
||||
[Button]
|
||||
public void Foo()
|
||||
{
|
||||
Debug.Log("Foo");
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(int parameter)
|
||||
{
|
||||
Debug.Log("Foo: " + parameter);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void Foo(Example parameter)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine();
|
||||
builder.Append("foo = ").AppendLine(parameter.foo.ToString());
|
||||
builder.Append("bar = ").AppendLine(parameter.bar.ToString());
|
||||
builder.Append("baz = ").Append(parameter.baz == null ? "Null" : parameter.baz.ToString());
|
||||
Debug.Log("Foo: " + builder.ToString());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
![img](../../images/img-button.png)
|
16
docs/articles/ja/comparison-with-other-libraries.md
Normal file
16
docs/articles/ja/comparison-with-other-libraries.md
Normal file
@ -0,0 +1,16 @@
|
||||
# 他ライブラリとの比較
|
||||
|
||||
Alchemyは他のエディタ拡張用のアセットと同等、またはそれ以上の非常に豊富な機能を搭載しています。ここではAlchemyと他のアセット/ライブラリの機能の比較を示します。
|
||||
|
||||
| | Alchemy | [Odin Inspector & Serializer](https://odininspector.com/) | [NaughtyAttributes](https://github.com/dbrizov/NaughtyAttributes) | [Tri Inspector](https://github.com/codewriter-packages/Tri-Inspector) | [Unity Editor Toolbox](https://github.com/arimger/Unity-Editor-Toolbox) |
|
||||
| - | - | - | - | - | - |
|
||||
| オープンソース | ✔︎ | ❌ | ✔︎ | ✔︎ | ✔︎ |
|
||||
| グループ化属性 | ✔︎ | ✔︎ | ✔︎ | ✔︎ | ✔︎ |
|
||||
| Button属性 | ✔︎ | ✔︎ | ✔︎ <br>(引数なし) | ✔︎ | ✔︎ <br>(引数なし) |
|
||||
| NonSerializedメンバーの編集 | ✔︎ | ✔︎ | ❌ | ✔︎ | ❌ |
|
||||
| SerializeReference対応 | ✔︎ | ✔︎ | ❌ | ✔︎ | ✔︎ |
|
||||
| シリアル化拡張 | ✔︎ <br>(partialが必要) | ✔︎ <br>(専用型を継承) | ❌ | ❌ | ❌ <br>(シリアル化可能な型の提供) |
|
||||
| UI Toolkit対応 | ✔︎ | ✔︎ | ❌ | ✔︎ | ❌ |
|
||||
| EditorWindow拡張 | ✔︎ | ✔︎ | ❌ | ❌ | ❌ |
|
||||
| Hierarchy拡張 | ✔︎ | ❌ | ❌ | ❌ | ✔︎ |
|
||||
|
48
docs/articles/ja/creating-custom-attribute.md
Normal file
48
docs/articles/ja/creating-custom-attribute.md
Normal file
@ -0,0 +1,48 @@
|
||||
# カスタム属性を作成する
|
||||
|
||||
`AlchemyAttributeDrawer`を使用することで、Alchemy上で動作する独自の属性を作成することが可能です。ここでは例として`HelpBoxAttribute`とそのDrawerの実装を示します。
|
||||
|
||||
まずは、フィールドやプロパティに追加する属性を定義します。
|
||||
|
||||
```cs
|
||||
using System;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public sealed class HelpBoxAttribute : Attribute
|
||||
{
|
||||
public HelpBoxAttribute(string message, HelpBoxMessageType messageType = HelpBoxMessageType.Info)
|
||||
{
|
||||
Message = message;
|
||||
MessageType = messageType;
|
||||
}
|
||||
|
||||
public string Message { get; }
|
||||
public HelpBoxMessageType MessageType { get; }
|
||||
}
|
||||
```
|
||||
|
||||
次に、定義した属性に対応するDrawerを作成します。Drawerを定義したcsファイルはEditorフォルダ以下に配置する必要があります。
|
||||
|
||||
```cs
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Editor;
|
||||
|
||||
[CustomAttributeDrawer(typeof(HelpBoxAttribute))]
|
||||
public sealed class HelpBoxDrawer : AlchemyAttributeDrawer
|
||||
{
|
||||
HelpBox helpBox;
|
||||
|
||||
public override void OnCreateElement()
|
||||
{
|
||||
var att = (HelpBoxAttribute)Attribute;
|
||||
helpBox = new HelpBox(att.Message, att.MessageType);
|
||||
|
||||
var parent = TargetElement.parent;
|
||||
parent.Insert(parent.IndexOf(TargetElement), helpBox);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`OnCreateElement()`メソッドを実装することで、対象のメンバーに対応したVisualElementを作成した際に処理を追加することができます。描画処理を上書きする通常の`PropertyDrawer`とは異なり、こちらはVisual Elementの作成後に後処理を追加する動作であることに注意してください。この仕組みによってAlchemyは複数のDrawerを組み合わせることを可能にしています。
|
||||
|
||||
また、定義したDrawerには`CustomAttributeDrawer`属性を追加し、引数に定義した属性の型を追加する必要があります。この属性をもとにAlchemyは要素の描画に必要なDrawerの検索を行います。
|
44
docs/articles/ja/creating-custom-group-attribute.md
Normal file
44
docs/articles/ja/creating-custom-group-attribute.md
Normal file
@ -0,0 +1,44 @@
|
||||
# カスタムグループ属性を作成する
|
||||
|
||||
`AlchemyGroupDrawer`を使用することで、フィールドをグループ化するための独自の属性を作成することが可能です。ここでは例として`FoldoutGroupAttribute`のそのDrawerの実装を示します。(説明のため実際に使用されている実装から省略した部分があります。)
|
||||
|
||||
まずは、グループの定義に使用する属性を定義します。この属性は`PropertyGroupAttribute`を継承する必要があります。
|
||||
|
||||
```cs
|
||||
using Alchemy.Inspector;
|
||||
|
||||
public sealed class FoldoutGroupAttribute : PropertyGroupAttribute
|
||||
{
|
||||
public FoldoutGroupAttribute() : base() { }
|
||||
public FoldoutGroupAttribute(string groupPath) : base(groupPath) { }
|
||||
}
|
||||
```
|
||||
|
||||
次に、定義した属性に対応するDrawerを作成します。Drawerを定義したcsファイルはEditorフォルダ以下に配置する必要があります。
|
||||
|
||||
```cs
|
||||
using UnityEngine.UIElements;
|
||||
using Alchemy.Editor;
|
||||
|
||||
[CustomGroupDrawer(typeof(FoldoutGroupAttribute))]
|
||||
public sealed class FoldoutGroupDrawer : AlchemyGroupDrawer
|
||||
{
|
||||
public override VisualElement CreateRootElement(string label)
|
||||
{
|
||||
var foldout = new Foldout()
|
||||
{
|
||||
style = {
|
||||
width = Length.Percent(100f)
|
||||
},
|
||||
text = label
|
||||
};
|
||||
|
||||
return foldout;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`CreateRootElement(string label)`メソッドを実装することで、各グループの親要素となるVisualElementの作成を行います。
|
||||
|
||||
また、定義したDrawerには`CustomGroupDrawer`属性を追加し、引数に定義した属性の型を追加する必要があります。この属性をもとにAlchemyはグループの描画に必要なDrawerの検索を行います。
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user