Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

289
Vistas
ScriptableObject data modified from code in editor mode, but containing asset file not changed

I have a ScriptableObject reference in a MonoBehaviour class.

Modify its values with CustomEditor button.

Save It.

Values seems changed. Even selected ScriptableObject Inspector displays data modified.

But asset file on disk don't have any data. And there's no data available from code of any another MonoBehaviour instance.

Here is a code snippet used to save my ScriptableObject.

public TextAsset text;
[SerializeField]
//Thats My Scriptable Object
public PathFramesList pathFramesList;
[SerializeField]
public List<List<ICurveData>> frameDatasList = new List<List<ICurveData>>();
// Called By CustomEditor Button
public void ReadData()
{
    #region BlahBlahBlah generating some data to save

    var separator = new string[] { "%" };
    var framesUnparsedData = text.text.Split(separator, StringSplitOptions.None);
    foreach (var f in framesUnparsedData)
        frameDatasList.Add(ParseFrame(f));
    var result = new ICurveData[frameDatasList.Count][];
    for (int i = 0; i < frameDatasList.Count; i++)
        result[i] = frameDatasList[i].ToArray();

    #endregion

    #region Trying to save data

    pathFramesList.frameDatasList = result; // Set data to object
    EditorUtility.SetDirty(pathFramesList); // Even This didn't help
    AssetDatabase.SaveAssets(); // Looks it doesn't work
    AssetDatabase.Refresh(); // Hoped this will help, whatever it do

    #endregion

}

And that's my ScriptableObjectClass And Its CustomEditor

[CreateAssetMenu(fileName = "ParsedPathData", menuName = "Create Path Data Asset")]
[System.Serializable]
public class PathFramesList : ScriptableObject
{
    [SerializeField]
    public ICurveData[][] frameDatasList;
}

#if UNITY_EDITOR
[CustomEditor(typeof(PathFramesList))]
public class PathFramesListEditor : Editor
{
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PathFramesList pathFrameList = (PathFramesList)target;
        if(pathFrameList.frameDatasList == null)
        {
            GUILayout.TextField("Frames Count is 0");
        }
        else
        {
            // It still has all data
            GUILayout.TextField("Frames Count is " + pathFrameList.frameDatasList.Length, 200);
        }
        if(GUILayout.Button("SaveAsset"))
        {
            // Tried to force saving with this) Didn't help
            
            EditorUtility.SetDirty(target);
            EditorUtility.SetDirty(serializedObject.targetObject);
            serializedObject.Update();
            serializedObject.ApplyModifiedProperties();
            AssetDatabase.SaveAssets();
        }
    }
}
#endif
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Ok.
Looks like scriptable objects files just can't store interface implementations examples.
Any else data was written to file well,
Correct me, please, if i'm wrong.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda