{
  "id": "unity/scriptableobject-constructor-called",
  "signature": "InvalidOperationException: It is not allowed to create a ScriptableObject from the constructor",
  "signature_zh": "InvalidOperationException: 不允许从构造函数创建 ScriptableObject",
  "regex": "InvalidOperationException: It is not allowed to create a ScriptableObject from the constructor",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A ScriptableObject instance was created using the 'new' keyword in a constructor instead of ScriptableObject.CreateInstance.",
  "root_cause_type": "generic",
  "root_cause_zh": "在构造函数中使用了 'new' 关键字创建 ScriptableObject 实例，应使用 ScriptableObject.CreateInstance。",
  "versions": [
    {
      "version": "Unity 2022.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "ScriptableObject must be created via CreateInstance, not by new, regardless of serialization attributes.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "ScriptableObject requires explicit initialization via CreateInstance to set up internal Unity engine state.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace 'new MyScriptableObject()' with 'ScriptableObject.CreateInstance<MyScriptableObject>()'.",
      "success_rate": 0.98,
      "how": "Replace 'new MyScriptableObject()' with 'ScriptableObject.CreateInstance<MyScriptableObject>()'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need to initialize fields, create a static factory method that calls CreateInstance and then sets properties.",
      "success_rate": 0.95,
      "how": "If you need to initialize fields, create a static factory method that calls CreateInstance and then sets properties.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Replace 'new MyScriptableObject()' with 'ScriptableObject.CreateInstance<MyScriptableObject>()'.",
    "If you need to initialize fields, create a static factory method that calls CreateInstance and then sets properties."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/ScriptReference/ScriptableObject.CreateInstance.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.93,
  "resolvable": "true",
  "first_seen": "2024-03-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}