FadeGroupScope
A fade group element.
Example
FadeGroupContainer _fgc;
void OnEnable() {
_fgc = new FadeGroupContainer(this, "Title");
}
void Draw() {
using(var scope = new FadeGroupScope(_fgc[, isCheckbox])) {
if (scope.Visible) {
// content
}
scope.OnVisibilityChanged = opened => {
// if you need to change a value when visibility is changed
};
}
}
Save the opened status temporary
void OnEnable() {
_fgc = new FadeGroupContainer(this, "Title", target != null ? target.GetHashCode() : -1);
}
If the user switches to another inspector and reopens this inspector, the fade group visibility is kept.
You need that if you have a color field in your fade group because color window and color picker "is another inspector" and reload the current inspector(reset unserialized members).
FadeGroupContainerWeakList
Helper used to create FadeGroupContainer dynamically.
FadeGroupContainerWeakList _fgcwl;
void OnEnable() {
_fgcwl = new FadeGroupContainerWeakList(this);
}
void Draw() {
// if myObject == null, data of the scope will be automatically deleted. (use a WeakReference(myObject))
using(var scope = _fgcwl.GetScope(myObject, "Title")) {
if (scope.Visible) {
// draw content
}
}
using(var scope = _fgcwl.GetScope(myObject2, "Title 2" [, isCheckbox = false, hashCode = -1])) {
if (scope.Visible) {
// draw content
}
}
}