Unity's GUIUtility.GetStateObject changes based on the structure of the GUI, for example when expanding or collapsing foldouts. Even with hints, tracking the state objects goes awry. This is a simpler implementation, meant to be used with object hashes generated by the call site, which at least has insight into what parts of the object will be stable enough to track.
T GetStateObjectOrDefault<T>(int hash)
Attempts to get the state object associated with the hash, else returns a default constructed copy of the state object.
Returns:The state object associated with the hash, or a default constructed object of type T.
int hash : The hash to fetch the state object.
If no object is associated with hash then a default constructed one is inserted.