- Home /
Question by
FloppyGaming · Oct 25, 2021 at 03:32 PM ·
prefabinspectorcustom editorprefab-instanceoverride
Custom editor values set in prefab editor not set in prefab asset
Hello everyone. I have made a prefab House
with a GridModel
component added to it. I have written a custom editor for it, but for some reason when I edit the variable in the Prefab Mode inspector, the changes aren't applied to the prefab in the Project window and vice versa. How can I solve this issue?
GridModel.cs
public class GridModel : MonoBehaviour, IGridModel
{
public Vector2Int dimensions;
}
GridModelEditor.cs
[CustomEditor(typeof(GridModel))]
public class GridModelEditor : Editor
{
private GridModel gridModel;
void OnEnable()
{
gridModel = (GridModel)target;
}
public override void OnInspectorGUI()
{
gridModel.dimensions = EditorGUILayout.Vector2IntField("Size", gridModel.dimensions);
}
}
Comment