Updating Editor with runtime updated Text Assets

Ok so… I started off with a long explanation of what I’m doing but it boils down to this…

  • I have an in-game level editor for
    standalone builds.
  • I save and load level and spawning
    data to XML files.
  • The same XML files are used by my spawn manager as text assets for mobile builds(no in-game editing)
  • When editing and testing levels from within the Unity Editor, I have an interface that works in concert with the spawn manager for more robust editing options.

I have never really messed with creating any of my own custom editor stuff as I never had the need, but I find my self ‘possibly’ needing some advice to make this code work exactly how I want.

I realize this question is fairly convoluted but… I’m trying to figure out if several things are possible, and if so, how should I go about them.

While working within the Unity Editor

  • I have found the Editor functions like SetDirty and AssetDatabase functions like Import or Save Assets. I assume I can use these to tell unity to save or update my text assets in a custom editor script, but how do I access this from my spawn manager? And can this be done while in play mode?
  • While in play mode can I force a ‘reload’ of a text asset? eg. If I have saved out the reference XML file and “restarted” the level that uses the corresponding data. And while in play mode, is it possible to “save out” that text asset data using the asset itself instead of manually?

Sorry if I’m not being very clear. ;-(

  • TextAssets are read-only; you will not be able to change them directly.
  • Place them in a Resouces folder and you can load and reload them as you wish.

You can use UnityEditor functions in any MonoBehaviour; but only in the Editor (best to put that inside #if UNITY_EDITOR / #endif)

Use System.IO.File.* to write to your text assets.

GLHF :slight_smile: