| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using DCL; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// This bridge is used for toggling the current RenderProfile from kernel |
| | 9 | | /// </summary> |
| | 10 | | public class RenderProfileBridge : MonoBehaviour |
| | 11 | | { |
| | 12 | | public enum ID |
| | 13 | | { |
| | 14 | | DEFAULT, |
| | 15 | | HALLOWEEN, |
| | 16 | | XMAS, |
| | 17 | | NIGHT |
| | 18 | | } |
| | 19 | |
|
| | 20 | | [System.Serializable] |
| | 21 | | public class Model |
| | 22 | | { |
| | 23 | | public ID id; |
| | 24 | | } |
| | 25 | |
|
| 0 | 26 | | public static RenderProfileBridge i { get; private set; } |
| | 27 | |
|
| 246 | 28 | | public void Awake() { i = this; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Called from kernel. Toggles the current WorldRenderProfile used by explorer. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="json">Model in json format</param> |
| | 34 | | public void SetRenderProfile(string json) |
| | 35 | | { |
| 0 | 36 | | ID id = JsonUtility.FromJson<Model>(json).id; |
| 0 | 37 | | SetRenderProfile(id); |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Toggles the current WorldRenderProfile used by explorer. |
| | 42 | | /// </summary> |
| | 43 | | /// <param name="id">Which profile by id</param> |
| | 44 | | public void SetRenderProfile(ID id) |
| | 45 | | { |
| | 46 | | RenderProfileWorld newProfile; |
| | 47 | | switch (id) |
| | 48 | | { |
| | 49 | | default: |
| 0 | 50 | | newProfile = RenderProfileManifest.i.defaultProfile; |
| 0 | 51 | | break; |
| | 52 | | case ID.HALLOWEEN: |
| | 53 | | case ID.XMAS: |
| | 54 | | case ID.NIGHT: |
| 0 | 55 | | newProfile = RenderProfileManifest.i.nightProfile; |
| | 56 | | break; |
| | 57 | | } |
| | 58 | |
|
| 0 | 59 | | RenderProfileManifest.i.currentProfile = newProfile; |
| 0 | 60 | | RenderProfileManifest.i.currentProfile.Apply(); |
| 0 | 61 | | } |
| | 62 | | } |