LoadFromJson(string)
Load a GraphicsStateCollection from the provided JSON-formatted string.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
public bool LoadFromJson(string json)
Parameters
The JSON-formatted string that represents a serialized GraphicsStateCollection object.
Returns
Type | Description |
|---|---|
| bool | True if the collection was successfully loaded, false otherwise. |
Remarks
The file extension of GraphicsStateCollection is *.graphicsstate.
Additional Resources: GraphicsStateCollection.SaveToFile, GraphicsStateCollection.LoadFromFile.
using System.IO;using UnityEngine;using UnityEngine.Rendering;public class LoadFromJsonExample : MonoBehaviour{ public GraphicsStateCollection graphicsStateCollection; public string jsonFilePath; void Start() { graphicsStateCollection = new GraphicsStateCollection(); string serializedJson = File.ReadAllText(jsonFilePath); if (graphicsStateCollection.LoadFromJson(serializedJson)) { Debug.Log("graphicsStateCollection contains " + graphicsStateCollection.totalGraphicsStateCount + " graphics states."); } }}
Additional Resources: GraphicsStateCollection.SaveToFile.