Saving Objects Created by Editor Extensions

Asked 1 years ago, Updated 1 years ago, 70 views

In the editor extension, click
from the button displayed using the custom window. I'm writing a script to generate Gameobject and change the settings of the object.

Even if you save a scene after generating a GameObject, you can still see the generated object or
Changes made from the script will not be saved.

After generation, if you make any changes to the data, such as moving any Gameobject from the scene view, all changes are saved.
If you generate or modify GameObjects from an editor script, you can expect
If the UnityEditor does not have a change mark and savescene does not save it,
I felt that

Is there a way to execute the modified mark from the script so that it is saved by pressing save screen?
I've looked through it, but I'm sorry if it's already been passed.

unity3d

2022-09-30 19:08

1 Answers

There was a similar post on Unity's forum the other day, and people in Unity showed how to resolve it.

Custom Editor problem in Unity 5.3 | Unity Community

One is calling Undo.RecordObject(), and the other is using SerializedObject or SerializedProperty.

Based on the comments at the link above, I could read that Unity recommends using SerializedObject or SerializedProperty.

Here is an example implementation:

Unity-Technology/UI/Source/UnityEditor.UI/UI/ButtonEditor.cs—Bitbacket

Implementation of Unity UI.Button editor extension.It's short but concise and easy to understand.

Expand Inspector with SerializedProperty

Here are some information in Japanese as well.


2022-09-30 19:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.