Custom Editor Handle Changes Not Persisting in Play Mode.

Really hoping that somebody can just help me make sense of this. I’m trying to make a custom handle that will act as a bounding box for the actors moving around in it. Like an animal pen. I pretty much followed the documentation for BoxBoundsHandles and made some changes to get the behavior I want. (Following the transform gizmo, etc.)

The issue is, as you’ll see in the console screenshot, that as soon as I press play, the changes I’m making to the bounds seem to reset to these values and I don’t know why.

They don’t change in the scene view, the bounding box stays the same size.

Here is the code for reference (I’ve made some sloppy changes to it trying to figure out what is going on.):

public class HatcheryBounds : Editor
    private BoxBoundsHandle m_BoundsHandle = new BoxBoundsHandle();

    protected virtual void OnSceneGUI()
        Hatchery hatchery = (Hatchery)target;

        // copy the target object's data to the handle = hatchery.transform.position;
        m_BoundsHandle.size = hatchery.Extents;
        // draw the handle

        if (EditorGUI.EndChangeCheck())
            // record the target object before setting new values so changes can be undone/redone
            Undo.RecordObject(target, "Change Hatchery Bounds");

            // copy the handle's updated data back to the target object
            Debug.Log("Hatchery bounds started as: " + hatchery.bounds);
            Bounds newBounds = new Bounds();
            newBounds.size = m_BoundsHandle.size;
            hatchery.Extents = newBounds.size;
            hatchery.transform.position =;
            hatchery.bounds = newBounds;
            Debug.Log("Hatcher bounds changed to: " + hatchery.bounds);

I discovered that the source of this problem was with the default values that I was setting up the hatchery object with:
Where I was initially setting it something like:

Bounds m_Bounds = new Bounds(,;

Changing it to:

 void Start()
            bounds = new Bounds(transform.position, extents);
            Debug.Log("Hatchery bounds are: " + bounds);
            for (int i = 0; i < maxFish; i++)

This seems to have fixed the problem.
I understand this is because I misunderstood the order in which Unity sets variables. So on start, rather than keeping the variables I had set in the inspector, it was resetting to the ‘default’ because I never told it to read the values…

That doesn’t sound quite right, anybody feel free to correct me or explain it better.