#That means `serializedObject` is null

1 messages · Page 1 of 1 (latest)

lavish yoke
#

oh so then thats even worse

#

that was your code

meager bramble
#

So it is exactly as I have it?

lavish yoke
#

to the t

#

well here

#
    void ConnectionHandles()
    {
        using var serializedObject = new SerializedObject(structure);
        SerializedProperty connectionsProperty = serializedObject.FindProperty("connections");

        foreach (SerializedProperty c in connectionsProperty)
        {
            SerializedProperty positionProperty = c.FindPropertyRelative("position");

            positionProperty.vector3Value = TransformHandles(positionProperty.vector3Value, default);
        }
        serializedObject.ApplyModifiedProperties();
    }
meager bramble
#

Is structure null...?

lavish yoke
#

nope

#

it never is

#

structure is just (Structure)target

meager bramble
#

Oh ffs this is a Editor?

lavish yoke
#

and target is never null and target is of type structure

#

yeah this is editor

#

that why I came to editor channel

meager bramble
#

Oh, it already has a serializedObject

#

No need to make one

lavish yoke
#

ok so then what

meager bramble
#

Just remove the using var serializedObject = new SerializedObject(structure); from the start

lavish yoke
#

OHHHHH i get it!!!!!

meager bramble
#

That might be screwing it up because serializedObject is already defined

#

Odd that it wouldn't throw an error...

lavish yoke
#

there are still errors

#

so what do I use findproperty on?

meager bramble
lavish yoke
#

NullReferenceException: Object reference not set to an instance of an object

#

On this line: SerializedProperty connectionsProperty = serializedObject.FindProperty("connections");

meager bramble
#

Please paste the full script here https://gdl.space/
Along with the structure class in another

lavish yoke
#

there you go

#

First class is structure, second is editor, third is the connection point I want to undo

meager bramble
#

Gotta share the links. It isn't a live share thing

lavish yoke
meager bramble
#

[Serializable]

lavish yoke
#

translate?

meager bramble
#

Ya gotta add the [Serializable] attribute to the StructureConnection class so Unity can actually serialize it

lavish yoke
#

AHH it works! Ok I see, I think now my brain understands the concepts here

#

Thank you so much!!! I have learned alot