BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Avatar / Scripts / OvrAvatarSettings.cs

OvrAvatarSettings.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
OvrAvatarSettings.cs 1.9 KiB Download Raw
1using UnityEngine;
2using System.Collections;
3
4#if UNITY_EDITOR
5 [UnityEditor.InitializeOnLoad]
6#endif
7public sealed class OvrAvatarSettings : ScriptableObject {
8 public static string AppID
9 {
10 get { return Instance.ovrAppID; }
11 set { Instance.ovrAppID = value; }
12 }
13
14 public static string MobileAppID
15 {
16 get { return Instance.ovrGearAppID; }
17 set { Instance.ovrGearAppID = value; }
18 }
19
20 private static OvrAvatarSettings instance;
21 public static OvrAvatarSettings Instance
22 {
23 get
24 {
25 if (instance == null)
26 {
27 instance = Resources.Load<OvrAvatarSettings>("OvrAvatarSettings");
28
29 // This can happen if the developer never input their App Id into the Unity Editor
30 // Use a dummy object with defaults for the getters so we don't have a null pointer exception
31 if (instance == null)
32 {
33 instance = ScriptableObject.CreateInstance<OvrAvatarSettings>();
34
35#if UNITY_EDITOR
36 // Only in the editor should we save it to disk
37 string properPath = System.IO.Path.Combine(UnityEngine.Application.dataPath, "Resources");
38 if (!System.IO.Directory.Exists(properPath))
39 {
40 UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources");
41 }
42
43 string fullPath = System.IO.Path.Combine(
44 System.IO.Path.Combine("Assets", "Resources"),
45 "OvrAvatarSettings.asset"
46 );
47 UnityEditor.AssetDatabase.CreateAsset(instance, fullPath);
48#endif
49 }
50 }
51 return instance;
52 }
53
54 set
55 {
56 instance = value;
57 }
58 }
59
60 [SerializeField]
61 private string ovrAppID = "";
62
63 [SerializeField]
64 private string ovrGearAppID = "";
65}