Display a UI list
- Most UI parts only get their data during runtime
- UI parts need to be styled in the editor (= before runtime)
- UI editing should be done with real time preview in the editor
- The items in UI list should look the same
- Save a list item prototype as a prefab (drag&drop in the editor)
- Set that prefab as the reference in the script managing the list
- During runtime, instantiate the referenced prefab as needed
However, this needs a prefab file, which seems like an unnecessary additional point of failure. Just one annoying example: More often than not I forget to click "Apply" after editing such a prototype - which only becomes apparent at runtime.
- In the script managing the list, set the list item prototype as a reference
Awake(), create a prefab and store it in a class field
- During runtime, instantiate the prefab from the class field
I got the suggested solution working with
PrefabUtility.CreatePrefab(). The only issue with that is that it still saves a prefab file. I currently just save those to a temp directory, but that is a workaround.
Is it possible to have a prefab which does not exist as a file, but still allows copying with