Skip to content

Commit

Permalink
added images to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
larsolm committed Feb 10, 2020
1 parent fd2cd96 commit f9d518b
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class GroupSample : MonoBehaviour
{
[MessageBox("The [Group] attribute displays fields together in a frame like view.", MessageBoxType.Info, Location = TraitLocation.Above)]

[Group("One")] public int Int1;
[Group("One")] public float Float1;
[Group("Two")] [Maximum(100)] public float Float2;
[Group("One")] public bool Bool1;
[Group("Two")] public bool Bool2;
[Group("Two")] public int Int2;
[Group("Group One")] public int Int1;
[Group("Group One")] public float Float1;
[Group("Group Two")] [Maximum(100)] public float Float2;
[Group("Group One")] public bool Bool1;
[Group("Group Two")] public bool Bool2;
[Group("Group Two")] public int Int2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,5 @@ public class Hippo : IAnimal
[SerializeReference]
[Reference]
public IAnimal AnimalReference;

[SerializeReference]
[Reference]
public IAnimal AnimalReference2;
}
}
Binary file added Documentation~/images/combo-box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/dictionary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/enum-buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/min-max-slider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/object-picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/slider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/tabs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/type-picker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ private bool ListCanAdd()
| ReorderCallback | The string name of a method (parameterless) or (int to) or (int from, int to) to call when an item has been reordered in the list | `null` |
| ChangeCallback | The string name of a method (parameterless) to call when the list changes | `null` |

![List](/Documentation~/images/list.png)

#### Dictionary

Add this to a SerializedDictionary derived type to show a dictionary editor (by default dictionary editing is unsupported by Unity). This has similar features/functionality as ListAttribute.
Expand Down Expand Up @@ -92,6 +94,8 @@ private void DictionaryItemRemoved(string key)

> **NOTE:** Normally dictionaries don't have defined ordering, however, serializing dictionaries requires the key/value pairs to be stored in lists and are thus ordered.
![Dictionary](/Documentation~/images/dictionary.png)

#### ComboBox

Add this to a string field to display a ComboBox control in which you can select from dropdown list of values or enter your own custom value.
Expand All @@ -107,6 +111,8 @@ public string ComboBox;
| OptionsSource | The string name of a List<string> returning method (parameterless), field, or property, that defines the list of options | `null` |
| AutoUpdate | Whether the options should automatically update if the values change (may affect performance) | `true` |

![Combo Box](/Documentation~/images/combo-box.png)

#### EnumButtons

Apply to an *Enum* field to show selectable buttons instead of a dropdown list. An optional bool can be specified to override the default behavior of the enum being selectable as flags or not (the default is based on whether the _[Flags]_ attribute is set on the declared enum type).
Expand All @@ -132,6 +138,8 @@ public TestEnum Flags;
| ------------- | ------------- | --------- |
| Flags | Whether multiple options can be selected as a flags enum | `true` if enum class has the *Flags* attribute, `false` otherwise |

![Enum Buttons](/Documentation~/images/enum-buttons.png)

#### Euler

A simple attribute to apply to a *Quaternion* field to display and assign the *Quaternion* in Euler angles (like the default *Transform* inspector does).
Expand Down Expand Up @@ -163,19 +171,23 @@ public Subclass Frame;
| ------------- | ------------- | --------- |
| IsCollapsable | Whether the frame can be collapsed or not | `true` |

![Frame](/Documentation~/images/frame.png)

#### Group

Add this attribute to any number of fields to display them together as a group with the header label specified in the constructor despite being defined out of order in the class.

```c#
[Group("One")] public int Int1;
[Group("One")] public float Float1;
[Group("Two")] [Maximum(100)] public float Float2;
[Group("One")] public bool Bool1;
[Group("Two")] public bool Bool2;
[Group("Two")] public int Int2;
[Group("Group One")] public int Int1;
[Group("Group One")] public float Float1;
[Group("Group Two")] [Maximum(100)] public float Float2;
[Group("Group One")] public bool Bool1;
[Group("Group Two")] public bool Bool2;
[Group("Group Two")] public int Int2;
```

![Group](/Documentation~/images/group.png)

#### Inline

Add this to a class or struct type with a *Serializable* attribute to show the fields of the class or struct inline rather than in the default foldout. Member labels can be optionally shown which is useful if the class has one value field.
Expand Down Expand Up @@ -204,6 +216,8 @@ Add this to a UnityEngine.Object derived field to show a searchable popup listin
public ScriptableObject Asset;
```

![Object Picker](/Documentation~/images/object-picker.png)

#### TypePicker

Add this to a string field to show a searchable popup listing (like the 'AddComponent window') of types derived from the selected type. Since the *Type* class itself is not serializable this will store the selected type's [AssemmblyQualifiedName](https://docs.microsoft.com/en-us/dotnet/api/system.type.assemblyqualifiedname?view=netframework-4.8) so that the desired type can be looked up with ```Type.GetType(assemblyQualifiedName)``` method.
Expand All @@ -218,6 +232,8 @@ public string Type;
| BaseType | The type to use as the base type to select from | required |
| ShowAbstract | Whether to display abstract types in the picker | `false` |

![Type Picker](/Documentation~/images/type-picker.png)

#### Popup

Add this to an int, float, or string field to show a popup instead of the default text box. The constructor takes two parameters: an array of floats/ints/strings that are the values to select and assign, and an optional array of strings that are shown as the labels for each value. These can also be retreived from a method, property, or field returning a List&lt;T&gt; or a PopupValues&lt;T&gt; if string option names are desired.
Expand All @@ -233,6 +249,8 @@ public float FloatPopup;
public string StringPopup;
```

![Popup](/Documentation~/images/popup.png)

#### Reference

Add this attribte to a field in addition to Unity's *[SerializeReference]* attribute to enable creating and editing of any valid subtype for the field.
Expand All @@ -258,6 +276,8 @@ public class ReferenceTypeTwo : IReferenceType
public IReferenceType Reference;
```

![Reference](/Documentation~/images/reference.png)

#### Tabs

Add this attribute to any number of fields to display them together in a tab like view. The first parameter specifies the group of fields to display together and the second is the title of the tab to display the field on.
Expand All @@ -271,6 +291,8 @@ Add this attribute to any number of fields to display them together in a tab lik
[Tabs("Tabs", "Two")] public int Int2;
```

![Tabs](/Documentation~/images/tabs.png)

#### Slider

Apply to an *int*, *float*, or *Vector2* field to display the value as a slider with a minimum and maximum. Applying this to a *Vector2* displays a MinMaxSlider corresponding to the x and y values repectively. The minimum and maximum values can also be retreived from a method, property, or field of the corresponding type.
Expand All @@ -286,6 +308,9 @@ public float SliderFloat
public Vector2 MinMaxSlider;
```

![Slider](/Documentation~/images/slider.png)
![Min Max Slider](/Documentation~/images/min-max-slider.png)

### Property Trait Attributes

These attributes are added to serializable fields in editable classes (*MonoBehaviours* or *ScriptableObjects*) to enable custom validation display and execution for the field. Unlike normal property attributes in Unity, multiple of these can be applied to a single field. Most attributes can have their properties retrieved from another field, property, or method through reflection by specifying the associated string name. All attributes are in the ```PiRhoSoft.Utilities``` namespace.
Expand Down

0 comments on commit f9d518b

Please sign in to comment.