Skip to main content

ChooseRandomChild

A class in Root.Township, the global namespace.

Editor tool: turns on one weighted random child of this object (or none), using RandomChildWeight for weights.

Constructors​

MemberWhat it is
ChooseRandomChild()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

2 private and internal fields
MemberWhat it is
private bool btnRandomizeInspector button that randomises all nested instances.
private float noneWeightWeight for choosing no child at all.

Methods​

2 private and internal methods
MemberWhat it is
private void OnValidate()When the button is pressed, randomises this and every nested ChooseRandomChild.
private void RandomizeChildren()Picks one child by weight (default 1) and activates only it; noneWeight is the chance to pick none.