LoadFromJson(string)
Load a GraphicsStateCollection from the provided JSON-formatted string.
Read time 1 minuteLast updated 20 hours 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.
Note: In a Player, a collection loaded from JSON doesn't resolve its compute shader variants, so GraphicsStateCollection.WarmUp skips them and GraphicsStateCollection.GetComputeVariants returns variants whose is . To warm up compute shaders in a Player, reference the imported .graphicsstate asset instead.
shadernullAdditional 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.