Foldout
See the FoldoutDemo.cs.
using Gridrand.RimGui.Manual.Utility;
using System;
namespace Gridrand.RimGui.Manual
{
/// <summary>
/// Foldout demo.
/// </summary>
class FoldoutDemo : ManualBase, IManual
{
bool isOpenTextStatelessFoldout;
int hash = Guid.NewGuid().GetHashCode();
public FoldoutDemo(ManualBaseResource p) : base(p)
{
}
public void Draw()
{
Gui.Heading("Foldouts");
// Returns true if expanded.
if (Gui.Foldout())
{
Gui.TextColorTexture(Assets.SampleTexture);
}
if (Gui.FoldoutButton("FoldoutButton"))
{
Gui.TextColorTexture(Assets.SampleTexture);
}
// Since the Id changes when the label is different, the WidgetId is specified and fixed.
// This allows the open/close state to remain fixed even if the label changes.
if (Gui.FoldoutButton("FoldoutButton:" + Time.FrameCount % 100 / 10, new WidgetId(hash)))
{
Gui.TextColorTexture(Assets.SampleTexture);
}
if (Gui.Foldout("Foldout"))
{
Gui.TextColorTexture(Assets.SampleTexture);
}
isOpenTextStatelessFoldout = Gui.StatelessFoldout("StatelessFoldout", isOpenTextStatelessFoldout);
if (isOpenTextStatelessFoldout)
{
Gui.TextColorTexture(Assets.SampleTexture);
}
}
}
}