| | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | 3 | | // See the LICENSE file in the project root for more information. |
| | 4 | |
|
| | 5 | | #if !UNITY_DOTSRUNTIME |
| | 6 | |
|
| | 7 | | using System; |
| | 8 | | using System.Text; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.SceneManagement; |
| | 11 | |
|
| | 12 | | namespace GDX.Developer.Reports.Resource.Sections |
| | 13 | | { |
| | 14 | | /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception> |
| | 15 | | public readonly struct ApplicationSection |
| | 16 | | { |
| | 17 | | /// <summary> |
| | 18 | | /// The name of the scene that was known to the <see cref="UnityEngine.SceneManagement" /> as being the acti |
| | 19 | | /// when this <see cref="ApplicationSection" /> was created. |
| | 20 | | /// </summary> |
| | 21 | | public readonly string ActiveScene; |
| | 22 | |
|
| | 23 | | /// <summary> |
| | 24 | | /// The time of creation for the <see cref="ApplicationSection" />. |
| | 25 | | /// </summary> |
| | 26 | | public readonly DateTime Created; |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// The platform that the <see cref="ApplicationSection" /> was created on. |
| | 30 | | /// </summary> |
| | 31 | | public readonly RuntimePlatform Platform; |
| | 32 | |
|
| | 33 | | public ApplicationSection(string activeScene, DateTime created, RuntimePlatform platform) |
| 6 | 34 | | { |
| 6 | 35 | | ActiveScene = activeScene; |
| 6 | 36 | | Created = created; |
| 6 | 37 | | Platform = platform; |
| 6 | 38 | | } |
| | 39 | |
|
| | 40 | | public static ApplicationSection Get() |
| 6 | 41 | | { |
| 6 | 42 | | return new ApplicationSection( |
| | 43 | | SceneManager.GetActiveScene().name, |
| | 44 | | DateTime.Now, |
| | 45 | | Application.platform); |
| 6 | 46 | | } |
| | 47 | |
|
| | 48 | | public void Output(ResourceReportContext context, StringBuilder builder) |
| 4 | 49 | | { |
| 4 | 50 | | builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Active Scene", ActiveScene)); |
| 4 | 51 | | builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Platform", Platform.ToString())); |
| 4 | 52 | | builder.AppendLine(ResourceReport.CreateKeyValuePair(context, "Created", |
| | 53 | | Created.ToString(Localization.LocalTimestampFormat))); |
| 4 | 54 | | } |
| | 55 | | } |
| | 56 | | } |
| | 57 | | #endif // !UNITY_DOTSRUNTIME |