| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.ComponentModel; |
| | 5 | | using UnityEngine; |
| | 6 | | using Object = UnityEngine.Object; |
| | 7 | |
|
| | 8 | | namespace DCL |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// RenderProfileManifest is used to store and set the current used RenderProfileWorld. |
| | 12 | | /// |
| | 13 | | /// When a new RenderProfileWorld object is added to the project it must be added here as well. |
| | 14 | | /// </summary> |
| | 15 | | [CreateAssetMenu(menuName = "DCL/Rendering/Render Profile Manifest", fileName = "RenderProfileManifest", order = 0)] |
| | 16 | | public class RenderProfileManifest : ScriptableObject |
| | 17 | | { |
| | 18 | | private static RenderProfileManifest instance; |
| 2124 | 19 | | public static RenderProfileManifest i => GetOrLoad(ref instance, "Render Profile Manifest"); |
| | 20 | |
|
| | 21 | | public RenderProfileWorld defaultProfile; |
| | 22 | | public RenderProfileWorld nightProfile; |
| | 23 | | public RenderProfileWorld testProfile; |
| | 24 | |
|
| | 25 | | private RenderProfileWorld currentProfileValue; |
| | 26 | |
|
| | 27 | | public RenderProfileWorld currentProfile |
| | 28 | | { |
| 0 | 29 | | get { return currentProfileValue; } |
| | 30 | | set |
| | 31 | | { |
| 666 | 32 | | if (value == null || value == currentProfileValue) |
| 649 | 33 | | return; |
| | 34 | |
|
| 17 | 35 | | currentProfileValue = value; |
| 17 | 36 | | OnChangeProfile?.Invoke(value); |
| 16 | 37 | | } |
| | 38 | | } |
| | 39 | |
|
| | 40 | | public event Action<RenderProfileWorld> OnChangeProfile; |
| | 41 | |
|
| | 42 | | internal static T GetOrLoad<T>(ref T variable, string path) where T : Object |
| | 43 | | { |
| 2124 | 44 | | if (variable == null) |
| | 45 | | { |
| 2 | 46 | | variable = Resources.Load<T>(path); |
| | 47 | | } |
| | 48 | |
|
| 2124 | 49 | | return variable; |
| | 50 | | } |
| | 51 | |
|
| | 52 | | public void Initialize(RenderProfileWorld initProfile = null) |
| | 53 | | { |
| 666 | 54 | | currentProfile = initProfile != null ? initProfile : defaultProfile; |
| | 55 | |
|
| 666 | 56 | | if (currentProfile == null) |
| | 57 | | { |
| 0 | 58 | | Debug.Log("Default profile should never be null!"); |
| 0 | 59 | | return; |
| | 60 | | } |
| | 61 | |
|
| 666 | 62 | | currentProfile.avatarProfile.currentProfile = currentProfile.avatarProfile.inWorld; |
| 666 | 63 | | currentProfile.Apply(); |
| 666 | 64 | | } |
| | 65 | | } |
| | 66 | | } |