Game.Prefabs.DummySOPrefab
Assembly:
Assembly-CSharp (default for user scripts) — if you place this class in a mod assembly, it will be compiled into that assembly. For Cities: Skylines 2 mod projects, put it in your mod's assembly.
Namespace:
Game.Prefabs
Type:
class
Base:
UnityEngine.ScriptableObject
Summary:
A minimal ScriptableObject defined with a CreateAssetMenu attribute so you can create data assets from the Unity Editor. As written, the class contains no fields or behavior; it serves as a placeholder or starting point for defining prefab-related data assets (for example, to store references, settings, or metadata for a prefab used by the game or a mod). The CreateAssetMenu parameters specify the default file name ("Prefab") and the menu path ("Colossal/Prefabs/New Prefab") that will appear in the Editor's "Create" menu.
Fields
- This class declares no fields.
Add serialized fields (public or [SerializeField] private) to store the data you need (Prefab references, configuration values, identifiers, etc.) so the asset can hold useful content for your mod.
Properties
- This class declares no properties.
If you need controlled access or computed values, add properties that wrap serialized fields or provide runtime-only data.
Constructors
public DummySOPrefab()
No explicit constructor is defined; the class uses the default parameterless constructor inherited from ScriptableObject. Create instances at runtime with ScriptableObject.CreateInstance() or create persistent assets in the Editor (see usage examples).
Methods
- This class declares no methods.
You can add Unity lifecycle methods (OnEnable, OnDisable) or custom helper methods. For editor-only asset creation/manipulation, use UnityEditor APIs in editor scripts.
Usage Example
Create an asset via the Unity Editor: 1. In the Project window, right-click -> Create -> Colossal -> Prefabs -> New Prefab (per the CreateAssetMenu attribute). 2. This will create a "Prefab.asset" ScriptableObject of type DummySOPrefab that you can rename and populate (once you add serialized fields).
Create and save the asset via an editor script (Editor folder required):
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using Game.Prefabs;
public static class DummyPrefabAssetCreator
{
[MenuItem("Assets/Create/Colossal/Prefabs/Create Dummy Prefab Asset")]
public static void CreateDummyAsset()
{
var asset = ScriptableObject.CreateInstance<DummySOPrefab>();
AssetDatabase.CreateAsset(asset, "Assets/Prefabs/NewDummyPrefab.asset");
AssetDatabase.SaveAssets();
Selection.activeObject = asset;
}
}
#endif
Example of referencing the ScriptableObject from a MonoBehaviour (runtime usage):
using UnityEngine;
using Game.Prefabs;
public class ExampleUser : MonoBehaviour
{
[SerializeField] private DummySOPrefab prefabAsset;
void Start()
{
if (prefabAsset != null)
{
// Use data saved on prefabAsset (after you add fields to DummySOPrefab)
}
}
}
Notes and recommendations for Cities: Skylines 2 modding - ScriptableObject assets are a good way to store mod configuration, prefab metadata, or references that designers can edit in the Editor without recompiling code. - Add [Serializable] fields to DummySOPrefab to store prefab GameObject references (GameObject or Prefab), identifiers, parameters, etc. - If you need to ship assets with your mod, include them in the final mod package and ensure paths/locations match how your mod loads resources. - Keep Editor-only code inside Editor folders and wrap with #if UNITY_EDITOR to avoid including UnityEditor API in runtime builds.